| | |
| | | using System; |
| | | using DBUtility; |
| | | using Model; |
| | | using Newtonsoft.Json.Linq; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Data; |
| | | using System.Linq; |
| | |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region è°æ¨å ä¿å/ç¼è¾åè½ |
| | | [Route("Kf_MoveStockRequestBill/Kf_MoveStockRequestBillEdit")] |
| | | [HttpPost] |
| | | public object MoveStockRequestBillEdit([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<ClsKf_MoveStockRequestBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsKf_MoveStockRequestBillMain>>(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 HSupID = mainList[0].HSupID;//徿¥åä½ |
| | | long HEmpID = mainList[0].HEmpID;//ä¸å¡å |
| | | long HDeptID = mainList[0].HDeptID;//é¨é¨ |
| | | long HWHID = mainList[0].HWHID;//è°å
¥ä»åº |
| | | long HSCWHID = mainList[0].HSCWHID;//è°åºä»åº |
| | | long HMangerID = mainList[0].HMangerID;//主管 |
| | | long HSecManagerID = mainList[0].HSecManagerID;//éªæ¶å |
| | | long HKeeperID = mainList[0].HKeeperID;//ä¿ç®¡å |
| | | string HMaker = user;//å¶å人 |
| | | string HExplanation = mainList[0].HExplanation;//æè¦ |
| | | string HInnerBillNo = mainList[0].HInnerBillNo;//å
é¨åæ®å· |
| | | |
| | | string HBillType = mainList[0].HBillType; |
| | | string HBillSubType = mainList[0].HBillSubType; |
| | | long HBillStatus = mainList[0].HBillStatus; |
| | | string HMakeDate = mainList[0].HMakeDate; |
| | | string HChecker = mainList[0].HChecker; |
| | | string HCheckDate = mainList[0].HCheckDate; |
| | | string HUpDater = mainList[0].HUpDater; |
| | | string HUpDateDate = mainList[0].HUpDateDate; |
| | | string HDeleteMan = mainList[0].HDeleteMan; |
| | | string HDeleteDate = mainList[0].HDeleteDate; |
| | | string HCloseMan = mainList[0].HCloseMan; |
| | | string HCloseDate = mainList[0].HCloseDate; |
| | | long HERPInterID = mainList[0].HERPInterID; |
| | | string HERPBillType = mainList[0].HERPBillType; |
| | | long HSTOCKINORGID = mainList[0].HSTOCKINORGID; |
| | | long HSTOCKOUTORGID = mainList[0].HSTOCKOUTORGID; |
| | | string HStockStyle = mainList[0].HStockStyle; |
| | | string HOWNERTYPEHEADID = mainList[0].HOWNERTYPEHEADID; |
| | | string HTRANSTYPE = mainList[0].HTRANSTYPE; |
| | | string HOWNERTYPEINID = mainList[0].HOWNERTYPEINID; |
| | | string HBUSINESSTYPE = mainList[0].HBUSINESSTYPE; |
| | | |
| | | ds = oCn.RunProcReturn("select * from h_v_IF_MoveStockRequestBillList where hmainid=" + HInterID + " and åæ®å·='" + HBillNo + "'", "h_v_IF_MoveStockRequestBillList"); |
| | | |
| | | if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//æ°å¢ |
| | | { |
| | | //主表 |
| | | oCn.RunProc(@"Insert Into Kf_MoveStockRequestBillMain |
| | | (HInterID,HBillNo,HDate,HBillType,HBillSubType,HBillStatus,HYear,HPeriod |
| | | ,HSupID,HWHID,HSCWHID,HEmpID,HMangerID,HSecManagerID,HKeeperID,HDeptID |
| | | ,HMaker,HMakeDate,HChecker,HCheckDate,HUpDater,HUpDateDate |
| | | ,HDeleteMan,HDeleteDate,HCloseMan,HCloseDate |
| | | ,HRemark,HExplanation,HInnerBillNo,HERPInterID,HERPBillType |
| | | ,HSTOCKINORGID,HSTOCKOUTORGID,HStockStyle |
| | | ,HOWNERTYPEHEADID,HTRANSTYPE,HOWNERTYPEINID,HBUSINESSTYPE) |
| | | values(" + HInterID + ",'" + HBillNo + "','" + HDate + "','" + 1243 + "','" + |
| | | HBillSubType + "'," + HBillStatus + "," + DateTime.Now.Year + "," + DateTime.Now.Month + "," + HSupID + |
| | | "," + HWHID + "," + HSCWHID + "," + HEmpID + "," + HMangerID + "," + HSecManagerID + |
| | | "," + HKeeperID + "," + HDeptID + ",'" + HMaker + "','" + HMakeDate + "','" + HChecker + "','" + HCheckDate + "','" + HUpDater + "','" + |
| | | HUpDateDate + "','" + HDeleteMan + "','" + HDeleteDate + "','" + HCloseMan + "','" + HCloseDate + "','" |
| | | + HRemark + "','" + HExplanation + "','" + HInnerBillNo + "'," + HERPInterID + ",'" + HERPBillType + "'," |
| | | + HSTOCKINORGID + "," + HSTOCKOUTORGID + ",'" + HStockStyle + "','" + HOWNERTYPEHEADID + "','" + HTRANSTYPE + "','" |
| | | + HOWNERTYPEINID + "','" + HBUSINESSTYPE + "'" + ")"); |
| | | } |
| | | else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0) |
| | | { //ä¿®æ¹ |
| | | oCn.RunProc("update Kf_MoveStockRequestBillMain set " + |
| | | "HRemark='" + HRemark + "', HChecker='" + HMaker + "', HCheckDate=getdate()" + "' where HInterID=" + HInterID); |
| | | |
| | | //å é¤å表 |
| | | oCn.RunProc("delete from Kf_MoveStockRequestBillSub 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<ClsKf_MoveStockRequestBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsKf_MoveStockRequestBillSub>>(msg3); |
| | | |
| | | int i = 0; |
| | | foreach (ClsKf_MoveStockRequestBillSub 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 Kf_MoveStockRequestBillSub", "Kf_MoveStockRequestBillSub"); |
| | | 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 Kf_MoveStockRequestBillSub |
| | | (HInterID,HEntryID,HBillNo_bak,HRemark,HMTONo,HPlanMode,HERPInterID,HERPEntryID |
| | | ,HMaterID,HUnitID,HSecUnitID,HPropertyID,HAuxPropID,HBatchNO |
| | | ,HWHID,HSCWHID,HSPID,HSCSPID |
| | | ,HQtyMust,HQty,HRelationQty,HRelationMoney,HSecUnitRate,HPrice,HMoney,HOutPrice,HOutMoney |
| | | ,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType |
| | | ,HICMOInterID,HICMOEntryID,HICMOBillNo,HPOOrderInterID,HPOOrderEntryID,HPOOrderBillNo,HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo |
| | | ,HSTOCKORGID,HOWNERID,HOWNERTYPEID,HSTOCKORGINID,HOWNERINID,HOWNERTYPEINID,HPRODUCEDATE,HExpiryDate,HBASEUNITID,HEXTAUXUNITID,HSECQTY) |
| | | values({HInterID},{NewHEntryID},'{oSub.HBillNo_bak}','{oSub.HRemark}','{oSub.HMTONo}' |
| | | ,'{oSub.HPlanMode}',{oSub.HERPInterID},{oSub.HERPEntryID},{oSub.HMaterID},{oSub.HUnitID},{oSub.HSecUnitID},{oSub.HPropertyID},{oSub.HAuxPropID},'{oSub.HBatchNO}',{oSub.HWHID},{oSub.HSCWHID},{oSub.HSPID},{oSub.HSCSPID},{oSub.HQtyMust},{(oSub.HQty == null ? 0 : oSub.HQty)},{oSub.HRelationQty},{oSub.HRelationMoney},{oSub.HSecUnitRate},{oSub.HPrice},{oSub.HMoney},{oSub.HOutPrice},{oSub.HOutMoney} |
| | | ,{oSub.HSourceInterID},{oSub.HSourceEntryID},'{oSub.HSourceBillNo}','{oSub.HSourceBillType}',{oSub.HICMOInterID},{oSub.HICMOEntryID},'{oSub.HICMOBillNo}',{oSub.HPOOrderInterID},{oSub.HPOOrderEntryID} |
| | | ,'{oSub.HPOOrderBillNo}',{oSub.HSeOrderInterID},{oSub.HSeOrderEntryID},'{oSub.HSeOrderBillNo}',{oSub.HSTOCKORGID},{oSub.HOWNERID},'{oSub.HOWNERTYPEID}',{oSub.HSTOCKORGINID},{oSub.HOWNERINID} |
| | | ,'{oSub.HOWNERTYPEINID}','{oSub.HPRODUCEDATE}','{oSub.HExpiryDate}',{oSub.HBASEUNITID},{oSub.HEXTAUXUNITID},{oSub.HSECQTY})"); |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = null; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | ///å é¤åè½ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [Route("Kf_MoveStockRequestBill/DeltetKf_MoveStockRequestBill")] |
| | | [HttpGet] |
| | | public object DeltetKf_MoveStockRequestBill(string HInterID) |
| | | { |
| | | try |
| | | { |
| | | oCn.BeginTran(); |
| | | oCn.RunProc("Delete From Kf_MoveStockRequestBillMain where HInterID = " + HInterID); |
| | | oCn.RunProc("Delete From Kf_MoveStockRequestBillSub where HInterID = " + HInterID); |
| | | 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 = "Exceptionï¼" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | } |
| | | } |