| | |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region ç产å
¥åºå å®¡æ ¸åæ¥æä»¶ è°ç¨æ¥å£ |
| | | [Route("Kf_ProductInBill/Kf_ProductInBillSaveApi")] |
| | | [HttpPost] |
| | | public object Kf_ProductInBillSaveApi([FromBody] JObject sMainSub) |
| | | { |
| | | try |
| | | { |
| | | oCn.BeginTran(); |
| | | LogService.Write("ç产å
¥åºå忥,ä¿åæ¹æ³æ§è¡ï¼" + sMainSub.ToString()); |
| | | |
| | | var model = sMainSub["model"].ToString(); |
| | | var entry = sMainSub["model"]["HENTRY"].ToString(); |
| | | |
| | | model = "[" + model.ToString() + "]"; |
| | | List<ClsKf_ProductInBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsKf_ProductInBillMain>>(model); |
| | | List<ClsKf_ProductInBillSub> subList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsKf_ProductInBillSub>>(entry); |
| | | |
| | | |
| | | // 夿 æ°æ®åºä¸æ¯å¦åå¨idååæ®å·ç¸ççæåæ®ï¼åå¨ï¼åé建ï¼åªæidå·ç¸çï¼åç³è¯·æ°çidå· |
| | | var ds1 = oCn.RunProcReturn($@" |
| | | select hmainid HInterID, åæ®å· HBillNO from h_v_Kf_ProductInBillList where hmainid = {mainList[0].HInterID} |
| | | ", "h_v_Kf_ProductInBillList"); |
| | | |
| | | if (ds1.Tables[0].Rows.Count > 0 && ds1.Tables[0].Rows[0]["HInterID"] != null) |
| | | { |
| | | if (string.Equals(ds1.Tables[0].Rows[0]["HBillNo"].ToString(), mainList[0].HBillNo, StringComparison.OrdinalIgnoreCase)) |
| | | { |
| | | string sql = string.Empty; |
| | | sql = $"delete Kf_ICStockBillMain where HinterID = {mainList[0].HInterID}"; |
| | | oCn.RunProc(sql); |
| | | sql = $"delete Kf_ICStockBillSub where HinterID = {mainList[0].HInterID}"; |
| | | oCn.RunProc(sql); |
| | | } |
| | | else |
| | | { |
| | | // éæ°ç³è¯·HInterID |
| | | var HInterID_Exch = DBUtility.ClsPub.CreateBillID("1202", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | mainList[0].HInterID = HInterID_Exch; |
| | | |
| | | foreach (var oSub in subList) |
| | | { |
| | | oSub.HInterID = HInterID_Exch; |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | // 主表 |
| | | oCn.RunProc($@"Insert Into Kf_ICStockBillMain |
| | | (HInterID,HYear,HPeriod,HBillType,HBillSubType,HDate |
| | | ,HBillNo,HBillStatus,HSupID,HManagerID,HEmpID,HDeptID,HSecManagerID,HKeeperID,HRemark,HMaker,HMakeDate,HCurID,HExRate,HWHID,HInnerBillNo,HExplanation |
| | | ,HChecker, HCheckDate, HSTOCKORGID) |
| | | values( |
| | | '{mainList[0].HInterID}', |
| | | '{mainList[0].HYear}', |
| | | '{mainList[0].HPeriod}', |
| | | '{mainList[0].HBillType}', |
| | | '{mainList[0].HBillSubType}', |
| | | '{mainList[0].HDate}', |
| | | '{mainList[0].HBillNo}', |
| | | {mainList[0].HBillStatus}, |
| | | '{mainList[0].HSupID}', |
| | | '{mainList[0].HManagerID}', |
| | | '{mainList[0].HEmpID}', |
| | | '{mainList[0].HDeptID}', |
| | | '{mainList[0].HSecManagerID}', |
| | | '{mainList[0].HKeeperID}', |
| | | '{mainList[0].HRemark}', |
| | | '{mainList[0].HMaker}', |
| | | '{mainList[0].HMakeDate}', |
| | | '{mainList[0].HCurID}', |
| | | '{mainList[0].HExRate}', |
| | | '{mainList[0].HWHID}', |
| | | '{mainList[0].HInnerBillNo}', |
| | | '{mainList[0].HExplanation}', |
| | | '{mainList[0].HChecker}', |
| | | '{mainList[0].HCheckDate}', |
| | | {mainList[0].HSTOCKORGID} |
| | | ) |
| | | "); |
| | | // å表 |
| | | foreach (var osub in subList) |
| | | { |
| | | |
| | | oCn.RunProc($@"Insert into Kf_ICStockBillSub |
| | | (HInterID,HEntryID,HMaterID,HUnitID,HQtyMust,HQty,HPrice |
| | | ,HMoney,HWHID,HSPID,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HPOOrderInterID |
| | | ,HPOOrderEntryID,HPOORderBillNo,HSecUnitID,HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo,HRelationQty,HSecUnitRate,HPropertyID) |
| | | values ( |
| | | '{osub.HInterID}', |
| | | '{osub.HEntryID}', |
| | | '{osub.HMaterID}', |
| | | '{osub.HUnitID}', |
| | | '{osub.HQtyMust}', |
| | | '{osub.HQty}', |
| | | '{osub.HPrice}', |
| | | '{osub.HMoney}', |
| | | '{osub.HWHID}', |
| | | '{osub.HSPID}', |
| | | '{osub.HRemark}', |
| | | '{osub.HSourceInterID}', |
| | | '{osub.HSourceEntryID}', |
| | | '{osub.HSourceBillNo}', |
| | | '{osub.HSourceBillType}', |
| | | '{osub.HPOOrderInterID}', |
| | | '{osub.HPOOrderEntryID}', |
| | | '{osub.HPOOrderBillNo}', |
| | | '{osub.HSecUnitID}', |
| | | '{osub.HSeOrderInterID}', |
| | | '{osub.HSeOrderEntryID}', |
| | | '{osub.HSeOrderBillNo}', |
| | | '{osub.HRelationQty}', |
| | | '{osub.HSecUnitRate}', |
| | | '{osub.HPropertyID}' |
| | | ) |
| | | "); |
| | | } |
| | | |
| | | //ç产å
¥åºåæ°å¢åå¡«ç产订åå
³èæ°é |
| | | oCn.RunProc("exec h_p_Kf_UpDateRelation_ProductInToICMO_Add " + mainList[0].HInterID); |
| | | |
| | | //ç产å
¥åºåæ°å¢åå¡«çäº§æ±æ¥åå
³èæ°é |
| | | oCn.RunProc("exec h_p_Kf_UpDateRelation_ProductInToICMOReport_Add " + mainList[0].HInterID); |
| | | |
| | | oCn.Commit(); |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "åæ®ä¿åæåï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LogService.Write("ç产å
¥åºå忥å¼å¸¸,ä¿åæ¹æ³æ§è¡å®æå¼å¸¸ï¼" + e.Message.ToString()); |
| | | |
| | | oCn.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "ä¿å失败ï¼" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | } |
| | | } |