| | |
| | | using Newtonsoft.Json; |
| | | using Model; |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Linq; |
| | | using Pub_Class; |
| | | using System; |
| | |
| | | } |
| | | } |
| | | |
| | | #region éå®è®¢å ä¿å/ç¼è¾åè½ |
| | | [Route("Xs_SeOrder/SeOrderBillEdit")] |
| | | [HttpPost] |
| | | public object SeOrderBillEdit([FromBody] JObject sMainSub) |
| | | { |
| | | try |
| | | { |
| | | var _value = sMainSub["sMainSub"].ToString(); |
| | | string msg1 = _value.ToString(); |
| | | oCN.BeginTran(); |
| | | //ä¿å主表 |
| | | objJsonResult = AddBillMain(msg1); |
| | | if (objJsonResult.code == "0") |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = objJsonResult.Message; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | oCN.Commit(); |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "åæ®ä¿åæåï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "ä¿å失败ï¼" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | public json AddBillMain(string msg1) |
| | | { |
| | | string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg2 = sArray[0].ToString(); //ä¸»è¡¨æ°æ® |
| | | string msg3 = sArray[1].ToString(); //åè¡¨æ°æ® |
| | | int OperationType = int.Parse(sArray[2].ToString()); // æ°æ®ç±»å 1æ·»å 3ä¿®æ¹ |
| | | string user = sArray[3].ToString(); |
| | | string msg_allVal = sArray[4].ToString(); //主表+åè¡¨æææ°æ® |
| | | |
| | | try |
| | | { |
| | | msg2 = "[" + msg2.ToString() + "]"; |
| | | List<ClsXs_SeOrderBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsXs_SeOrderBillMain>>(msg2); |
| | | |
| | | long HInterID = mainList[0].HInterID;//éå
¥typeå¾å°çåæ®ID |
| | | string HBillNo = mainList[0].HBillNo;//éå
¥typeå¾å°çåæ®å· |
| | | long HPRDORGID = mainList[0].HPRDORGID;//ç»ç» |
| | | DateTime HDate = mainList[0].HDate;//æ¥æ |
| | | string HRemark = mainList[0].HRemark;//夿³¨ |
| | | long HCusID = mainList[0].HCusID;//å®¢æ· |
| | | long HEmpID = mainList[0].HEmpID;//ä¸å¡å |
| | | long HDeptID = mainList[0].HDeptID;//é¨é¨ |
| | | long HCurID = mainList[0].HCurID;//å¸å« |
| | | Single HExRate = mainList[0].HExRate;//æ±ç |
| | | long HManagerID = mainList[0].HManagerID;//主管 |
| | | long HSellSID = mainList[0].HSellSID;//é宿¹å¼ |
| | | long HSSID = mainList[0].HSSID;//ç»ç®æ¹å¼ |
| | | DateTime HSSDate = mainList[0].HSSDate;//ç»ç®æ¥æ |
| | | string HMaker = user;//å¶å人 |
| | | string HAddress = mainList[0].HAddress;//å°å |
| | | |
| | | List<ClsXs_SeOrderBillMain> mainList2 = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsXs_SeOrderBillMain>>(msg2); |
| | | DateTime dt = DateTime.Now; |
| | | long HYear = mainList2[0].HYear == null ? 0 : mainList2[0].HYear; |
| | | long HPeriod = mainList2[0].HPeriod == null ? 0 : mainList2[0].HPeriod; |
| | | string HBillType = mainList2[0].HBillType == null ? "''" : mainList2[0].HBillType; |
| | | string HBillSubType = mainList2[0].HBillSubType == null ? "''" : mainList2[0].HBillSubType; |
| | | int HBillStatus = mainList2[0].HBillStatus == null ? 0 : mainList2[0].HBillStatus; |
| | | string HChecker = mainList2[0].HChecker == null ? "''" : mainList2[0].HChecker; |
| | | string HCheckDate = mainList2[0].HCheckDate == null ? "''" : mainList2[0].HCheckDate; |
| | | string HMakeDate = mainList2[0].HMakeDate == null ? "''" : mainList2[0].HMakeDate; |
| | | string HCloseMan = mainList2[0].HCloseMan == null ? "''" : mainList2[0].HCloseMan; |
| | | string HCloseDate = mainList2[0].HCloseDate == null ? "''" : mainList2[0].HCloseDate; |
| | | long HERPInterID = mainList2[0].HERPInterID == null ? 0 : mainList2[0].HERPInterID; |
| | | string HERPBillType = mainList2[0].HERPBillType == null ? "''" : mainList2[0].HERPBillType; |
| | | long HSALEORGID = mainList2[0].HSALEORGID == null ? 0 : mainList2[0].HSALEORGID; |
| | | |
| | | ds = oCN.RunProcReturn("select * from h_v_IF_SeOrderBillList where hmainid=" + HInterID + " and åæ®å·='" + HBillNo + "'", "h_v_IF_SeOrderBillList"); |
| | | |
| | | if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//æ°å¢ |
| | | { |
| | | DataSet Ds; |
| | | Int64 NewHInterID = 1; |
| | | Ds = oCN.RunProcReturn("select MAX(HInterID)HInterID from Xs_SeOrderBillMain", "Xs_SeOrderBillMain"); |
| | | if (Ds.Tables[0].Rows.Count != 0 && ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"].ToString()) != 0) |
| | | { |
| | | NewHInterID = ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"].ToString()); |
| | | NewHInterID += 1; |
| | | } |
| | | //主表 |
| | | oCN.RunProc(@"Insert Into Xs_SeOrderBillMain |
| | | (HBillType,HInterID,HBillNo,HDate |
| | | ,HYear,HPeriod,HRemark,HMaker,HMakeDate |
| | | ,HEmpID,HCusID |
| | | ,HBillSubType,HAddress,HSSDate,HSSID,HSellSID,HCurID,HExRate, HManagerID,HDeptID |
| | | ,HExplanation,HCheckFlow,HBillStatus,HInnerBillNo |
| | | ,HICMOFlag,HChangeMan,HSALEORGID,HERPInterID,HERPBillType) |
| | | values(" + "1401," + HInterID + ",'" + HBillNo + "','" + HDate + "','" + |
| | | DateTime.Now.Year + "','" + DateTime.Now.Month + "','" + HRemark + "','" + HMaker + "','" + HMakeDate + |
| | | "'," + HEmpID + "," + HCusID + ",'" + HBillType + "','" + HAddress + "','" + HSSDate + |
| | | "'," + HSSID + "," + HSellSID + "," + HCurID + "," + HExRate + "," + HManagerID + "," + HDeptID + ",'" + "''" + "'," + "0," + HBillStatus + ",'" + "''" + "'," + |
| | | 0 + ",'" + "''" + "'," + "0," + HERPInterID + ",'" + HERPBillType + "')"); |
| | | } |
| | | else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0) |
| | | { //ä¿®æ¹ |
| | | oCN.RunProc("update Xs_SeOrderBillMain set " + |
| | | "HRemark='" + HRemark + "', HChecker='" + HMaker + "', HCheckDate=getdate()" + |
| | | ", HEmpID=" + HEmpID + ", HCusID=" + HCusID + ",HAddress='" + HAddress + "',HDeptID=" + HDeptID |
| | | + ",HCurID=" + HCurID + ",HExRate=" + HExRate + ",HManagerID=" + HManagerID + ",HSellSID=" + HSellSID |
| | | + ",HSSID=" + HSSID + ",HSSDate='" + HSSDate + "' where HInterID=" + HInterID); |
| | | |
| | | //å é¤å表 |
| | | oCN.RunProc("delete from Xs_SeOrderBillSub where HInterID='" + HInterID + "'"); |
| | | } |
| | | //ä¿åå表 |
| | | objJsonResult = AddBillSub(msg3, HInterID, OperationType); |
| | | |
| | | if (objJsonResult.code == "0") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = objJsonResult.Message; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = null; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exceptionï¼" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | public json AddBillSub(string msg3, long HInterID, int OperationType) |
| | | { |
| | | List<ClsXs_SeOrderBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsXs_SeOrderBillSub>>(msg3); |
| | | |
| | | List<ClsXs_SeOrderBillSub> DetailColl2 = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsXs_SeOrderBillSub>>(msg3); |
| | | |
| | | long HSourceInterID = DetailColl2[0].HSourceInterID == null ? 0 : DetailColl2[0].HSourceInterID; |
| | | long HSourceEntryID = DetailColl2[0].HSourceEntryID == null ? 0 : DetailColl2[0].HSourceEntryID; |
| | | string HSourceBillNo = DetailColl2[0].HSourceBillNo == null ? "''" : DetailColl2[0].HSourceBillNo; |
| | | string HSourceBillType = DetailColl2[0].HSourceBillType == null ? "''" : DetailColl2[0].HSourceBillType; |
| | | double HRelationQty = DetailColl2[0].HRelationQty == null ? 0 : DetailColl2[0].HRelationQty; |
| | | long HPropertyID = DetailColl2[0].HPropertyID == null ? 0 : DetailColl2[0].HPropertyID; |
| | | string HBatChNo = DetailColl2[0].HBatChNo == null ? "''" : DetailColl2[0].HBatChNo; |
| | | long HAuxPropID = DetailColl2[0].HAuxPropID == null ? 0 : DetailColl2[0].HAuxPropID; |
| | | string HMTONo = DetailColl2[0].HMTONo == null ? "''" : DetailColl2[0].HMTONo; |
| | | long HERPInterID = DetailColl2[0].HERPInterID == null ? 0 : DetailColl2[0].HERPInterID; |
| | | long HERPEntryID = DetailColl2[0].HERPEntryID == null ? 0 : DetailColl2[0].HERPEntryID; |
| | | decimal HBackRelationQty = DetailColl2[0].HBackRelationQty == null ? 0 : DetailColl2[0].HBackRelationQty; |
| | | long HWhID = DetailColl2[0].HWhID == null ? 0 : DetailColl2[0].HWhID; |
| | | long HSPID = DetailColl2[0].HSPID == null ? 0 : DetailColl2[0].HSPID; |
| | | |
| | | int i = 0; |
| | | foreach (ClsXs_SeOrderBillSub oSub in DetailColl) |
| | | { |
| | | i++; |
| | | if (oSub.HQty <= 0 || oSub.HQty == null) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + i + "è¡ï¼æ°éä¸è½ä¸º0æè
å°äº0"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | if (oSub.HMaterID == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + i + "è¡ï¼ç©æä¸è½ä¸ºç©º"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //if (oSub.HSourceID == 0) |
| | | //{ |
| | | // objJsonResult.code = "0"; |
| | | // objJsonResult.count = 0; |
| | | // objJsonResult.Message = "第" + i + "è¡ï¼çäº§èµæºä¸è½ä¸ºç©º"; |
| | | // objJsonResult.data = null; |
| | | // return objJsonResult; |
| | | //} |
| | | |
| | | if (oSub.HUnitID == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + i + "è¡ï¼è®¡éåä½ä¸è½ä¸ºç©º"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | DataSet Cs; |
| | | Int64 NewHEntryID = 1; |
| | | Cs = oCN.RunProcReturn("select MAX(HEntryID)HEntryID from Xs_SeOrderBillSub", "Xs_SeOrderBillSub"); |
| | | if (Cs.Tables[0].Rows.Count != 0 && ClsPub.isLong(Cs.Tables[0].Rows[0]["HEntryID"].ToString()) != 0) |
| | | { |
| | | NewHEntryID = ClsPub.isLong(Cs.Tables[0].Rows[0]["HEntryID"].ToString()); |
| | | NewHEntryID += 1; |
| | | } |
| | | |
| | | oCN.RunProc($@"Insert into Xs_SeOrderBillSub |
| | | (HInterID,HENTRYID,HQty,HMaterID,HUnitID,HRemark |
| | | ,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType |
| | | ,HRelationQty,HRelationMoney,HPrice,HTaxPrice,HMoney,HDiscountRate |
| | | ,HRelTaxPrice,HTaxRate,HTaxMoney,HlineTotal,HlineTotalBB,HDate,HOutStockQty,HInvoiceQty) |
| | | values({HInterID},{NewHEntryID},{(oSub.HQty == null ? 0 : oSub.HQty)} |
| | | ,{oSub.HMaterID},{oSub.HUnitID},'{oSub.HRemark}',{HSourceInterID},{HSourceEntryID},{HSourceBillNo},{HSourceBillType},{HRelationQty},0,{oSub.HPrice},{oSub.HTaxPrice},{oSub.HMoney},{oSub.HDiscountRate},{oSub.HRelTaxPrice},{oSub.HTaxRate},{oSub.HTaxMoney},{oSub.HlineTotal},{oSub.HlineTotalBB},getdate(),0,0)"); |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = null; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | ///å é¤åè½ |
| | | /// </summary> |