1
yxj
2023-04-13 e4647b3bc4aca9690261df83f9055abdf8c17406
WebAPI/Controllers/BaseSet/Gy_CustomerController.cs
@@ -42,7 +42,22 @@
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                string sql1 = string.Format(@"select * from h_v_Gy_CustomerList where 组织名称='" + Organization + "'");
                string sql1 = "";
                //客户制定
                string sErr = "";
                if (oSystemParameter.ShowBill(ref sErr))
                {
                    if (oSystemParameter.omodel.WMS_CampanyName == "乔一")
                    {
                         sql1 = string.Format(@"select * from h_v_Gy_CustomerList where 1=1");
                    }
                    else
                    {
                         sql1 = string.Format(@"select * from h_v_Gy_CustomerList where 组织名称='" + Organization + "'");
                    }
                }
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn(sql1 + sWhere + " order by 客户代码 ", "h_v_Gy_CustomerList");
@@ -285,7 +300,7 @@
                    ",HEmpID,HCreditDate,HCreditRatingDate,HMaxCreditRatingDate" +
                    ",HMonthUseQty,HForecastCreditRating,HCreditLevelID,HCountAccrualRating" +
                    ",HSubsidyAccrualRating,HCreditRating,HMaxCreditRating" +
                    ",HCusTypeID) " +
                    ",HCusTypeID,HCREATEORGID,HUSEORGID) " +
                    " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + HShortNumber + "'," + HParentID +
                    ", " + HLevel + ",0,'" + HStopflag + "','" + HRemark + "'" +
                    ",'" + HShortName + "','" + HAddress + "','" + HLinkMan + "','" + HLinkPhone + "','" + HMobilePhone + "'" +
@@ -295,7 +310,7 @@
                    "," + HEmpID + "," + HCreditDate + "," + HCreditRatingDate + "," + HMaxCredRatingDate +
                    "," + HMonthUseQty + "," + HForecastCreditRating + "," + HCreditLevelID + "," + HCountAccrualRating +
                    "," + HSubsidyAccrualRating + "," + HCreditRating + "," + HMaxCreditRating +
                    ", " + HCusTypeID + ")");
                    ", " + HCusTypeID + ","+ HCreateOrgID + ","+ HUseOrgID + ")");
                //修改上级为非末级代码
                oCN.RunProc("Update Gy_Customer set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
                oCN.Commit();
@@ -326,10 +341,12 @@
            {
                var model = oMain["model"].ToString();
                var custLocationModel = oMain["model"]["HCustLocationEntry"].ToString();
                var custContactModel = oMain["model"]["HCustContactEntry"].ToString();
                //反序列化
                model = "[" + model + "]";
                List<Customer> lsmain = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Customer>>(model);
                List<Model.ClsGy_CustLocation_Model> custLocationls = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsGy_CustLocation_Model>>(custLocationModel);
                List<Model.ClsGy_COMMONCONTACT_Model> custContactls = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsGy_COMMONCONTACT_Model>>(custContactModel);
                string sql = string.Empty;
                oCN.BeginTran();
                sql = $"delete gy_Customer where HItemID = {lsmain[0].HItemID}";
@@ -379,10 +396,30 @@
                }
                sql = "set identity_insert Gy_CustLocation off";
                oCN.RunProc(sql);
                //客户_收货方联系人
                sql = $"delete Gy_COMMONCONTACT where HCUSTID = {lsmain[0].HItemID}";
                oCN.RunProc(sql);
                sql = "set identity_insert Gy_COMMONCONTACT on";
                oCN.RunProc(sql);
                foreach (var item in custContactls)
                {
                    sql = $@"insert into Gy_COMMONCONTACT(HItemID,HCUSTID,HNumber,HName,HShortNumber,HParentID,HLevel,HEndFlag,HStopflag,
                    HRemark,HHelpCode,HUseFlag,HMakeTime,HMakeEmp,HCheckEmp,HCheckTime,HModifyEmp,HModifyTime,HStopEmp,HStopTime,
                    HUSEORGID,HCREATEORGID)
                  values({item.HItemID},{item.HCUSTID},'{item.HNumber}','{item.HName}','{item.HShortNumber}',{item.HParentID},{item.HLevel}
           ,{Convert.ToString(item.HEndFlag ? 1 : 0)},{Convert.ToString(item.HStopflag ? 1 : 0) },'{item.HRemark}','{item.HHelpCode}','{item.HUseFlag}'
            ,'{item.HMakeTime}','{item.HMakeEmp}','{item.HCheckEmp}','{item.HCheckTime}','{item.HModifyEmp}'
            ,'{item.HModifyTime}','{item.HStopEmp}','{item.HStopTime}',{item.HUSEORGID},{item.HCREATEORGID})";
                    oCN.RunProc(sql);
                }
                sql = "set identity_insert Gy_COMMONCONTACT off";
                oCN.RunProc(sql);
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "新增单据成功!";
                objJsonResult.Message = "新增基础资料成功!";
                //objJsonResult.data = null;
                return objJsonResult;
            }