|
|
@@ -761,22 +761,22 @@ func (this *OilContractController) ImportUpdate() {
|
|
|
Column := this.GetString("Column")
|
|
|
Id := this.GetString("Id")
|
|
|
SupplierId := this.GetString("SupplierId")
|
|
|
- SupplierName := this.GetString("SupplierName")
|
|
|
|
|
|
var supp supplier.OilSupplier
|
|
|
+ var con contract.OilContract
|
|
|
svc := supplier.GetOilSupplierService(utils.DBE)
|
|
|
svc.GetEntityById(SupplierId, &supp)
|
|
|
sql := ""
|
|
|
var err error
|
|
|
+ var errinfo ErrorInfo
|
|
|
where := "1=1"
|
|
|
if Column == "ContractClass" {
|
|
|
if Id != "0" {
|
|
|
where += " and Id = " + Id + " and ImportStatus = 0 and ClassName = '" + Class + "'"
|
|
|
- sql = "update OilContract set SupplierName = '" + supp.SupplierName + "', " + Column + " = '" + Value + "' where " + where
|
|
|
} else {
|
|
|
where += " and ImportStatus = 0 and ClassName = '" + Class + "' and " + Column + " = ''"
|
|
|
- sql = "update OilContract set " + Column + " = '" + Value + "' where " + where
|
|
|
}
|
|
|
+ sql = "update OilContract set " + Column + " = '" + Value + "' where " + where
|
|
|
_, err = utils.DBE.Query(sql)
|
|
|
}
|
|
|
if Column == "SupplierId" {
|
|
|
@@ -794,7 +794,7 @@ func (this *OilContractController) ImportUpdate() {
|
|
|
svc.GetEntityByWhere("Base_Organize", "Id = "+Value, &org)
|
|
|
if Id != "0" {
|
|
|
where += " and Id = " + Id + " and ImportStatus = 0 and ImportSecondUnit = '" + Class + "'"
|
|
|
- sql = "update OilContract set SecondUnitName = '" + org.Fullname + "',SupplierName = '" + supp.SupplierName + "', " + Column + " = " + Value + " where " + where
|
|
|
+ sql = "update OilContract set SecondUnitName = '" + org.Fullname + "', " + Column + " = " + Value + " where " + where
|
|
|
} else {
|
|
|
//where += " and ImportStatus = 0 and ImportSecondUnit = '" + Class + "' and " + Column + " = 0"
|
|
|
where += " and ImportStatus = 0 and ImportSecondUnit = '" + Class + "'"
|
|
|
@@ -805,21 +805,35 @@ func (this *OilContractController) ImportUpdate() {
|
|
|
|
|
|
if Column == "Status" {
|
|
|
where += " and Id = " + Id + " and ImportStatus = 0"
|
|
|
- sql := "update OilContract set SupplierName = '" + supp.SupplierName + "', " + Column + " = " + Value + " where " + where
|
|
|
+ sql := "update OilContract set " + Column + " = " + Value + " where " + where
|
|
|
_, err = utils.DBE.Query(sql)
|
|
|
}
|
|
|
- if Column == "SupplierName" {
|
|
|
+ if Column == "ContractNo" {
|
|
|
+ svc.GetEntityByWhere("OilContract", "ContractNo = '" + Value + "' and Id != " + Id, &con)
|
|
|
+ if Value == "" {
|
|
|
+ errinfo.Message = "修改失败!合同编号不能为空"
|
|
|
+ errinfo.Code = -1
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if con.Id > 0 {
|
|
|
+ errinfo.Message = "修改失败!合同编号不能重复"
|
|
|
+ errinfo.Code = -1
|
|
|
+ this.Data["json"] = &errinfo
|
|
|
+ this.ServeJSON()
|
|
|
+ return
|
|
|
+ }
|
|
|
where += " and Id = " + Id + " and ImportStatus = 0"
|
|
|
- sql := "update OilContract set SupplierName = '" + SupplierName + "', " + Column + " = " + Value + " where " + where
|
|
|
+ sql := "update OilContract set " + Column + " = '" + Value + "' where " + where
|
|
|
_, err = utils.DBE.Query(sql)
|
|
|
}
|
|
|
if Column == "SettleStatus" {
|
|
|
where += " and Id = " + Id + " and ImportStatus = 0"
|
|
|
- sql := "update OilContract set SupplierName = '" + supp.SupplierName + "', " + Column + " = '" + Value + "' where " + where
|
|
|
+ sql := "update OilContract set " + Column + " = '" + Value + "' where " + where
|
|
|
_, err = utils.DBE.Query(sql)
|
|
|
}
|
|
|
|
|
|
- var errinfo ErrorInfo
|
|
|
if err == nil {
|
|
|
errinfo.Message = "修改成功!"
|
|
|
errinfo.Code = 0
|