New file |
| | |
| | | using Newtonsoft.Json.Linq; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Data; |
| | | using System.Linq; |
| | | using System.Web; |
| | | using System.Web.Http; |
| | | using WebAPI.Models; |
| | | |
| | | namespace WebAPI.Controllers.SCGL |
| | | { |
| | | public class Cg_PODemandPlanBillController : ApiController |
| | | { |
| | | private json objJsonResult = new json(); |
| | | public DataSet ds = new DataSet(); |
| | | public WebServer webserver = new WebServer(); |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | Cg_PODemandPlanBillMain omdelMian = new Cg_PODemandPlanBillMain(); |
| | | List<Cg_PODemandPlanBillSub> omodelsub = new List<Cg_PODemandPlanBillSub>(); |
| | | |
| | | #region ææè®¡åå å表 |
| | | [Route("Cg_PODemandPlanBill/Cg_PODemandPlanBillList")] |
| | | [HttpGet] |
| | | public object Cg_PODemandPlanBillList(string sWhere, string user) |
| | | { |
| | | try |
| | | { |
| | | //æ¥çæé |
| | | if (!DBUtility.ClsPub.Security_Log("Cg_PODemandPlanBill_Query", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "æ æ¥çæéï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ds = oCN.RunProcReturn("select * from h_v_JIT_Cg_PODemandPlanBillList where 1=1" + sWhere + "order by hmainid desc ", "h_v_JIT_Cg_PODemandPlanBillList"); |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "Sucessï¼"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exceptionï¼" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region ææè®¡åå æ·»å /ä¿®æ¹ |
| | | [Route("Cg_PODemandPlanBill/AddPODemandPlanBillList")] |
| | | [HttpPost] |
| | | public object AddPODemandPlanBillList([FromBody] JObject sMainSub) |
| | | { |
| | | 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; |
| | | } |
| | | |
| | | public json AddBillMain(string msg1) |
| | | { |
| | | string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg2 = sArray[0].ToString(); |
| | | string msg3 = sArray[1].ToString(); |
| | | |
| | | int hentryid = int.Parse(sArray[2].ToString());//å表ç顺åºid |
| | | int OperationType = int.Parse(sArray[3].ToString());//æ°æ®ç±»å 1æ·»å 3ä¿®æ¹ |
| | | string user = sArray[4].ToString(); |
| | | try |
| | | { |
| | | if (!DBUtility.ClsPub.Security_Log("Cg_PODemandPlanBill_Edit", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "æ ä¿åæéï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | omdelMian = Newtonsoft.Json.JsonConvert.DeserializeObject<Cg_PODemandPlanBillMain>(msg2); |
| | | string BillType = "4608"; |
| | | |
| | | |
| | | if (OperationType == 1)//æ°å¢ |
| | | { |
| | | //主表 |
| | | oCN.RunProc("insert into Cg_PODemandPlanBillMain(HInterID,HBillNo,HYear,HPeriod,HBillType" + |
| | | ",HBillSubType,HDate,HBillStatus,HMaker,HMakeDate" + |
| | | ",HSubORGID ,HAddress,HPURCHASEORGID,HSupplierID ,HSettleCurrId" + |
| | | ",HRemark,HExplanation)" + |
| | | $"values({omdelMian.HInterID}, '{omdelMian.HBillNo}', {DateTime.Now.Year}, {DateTime.Now.Month}, '{BillType}'" + |
| | | $", '{BillType}','{omdelMian.HDate}',1, '{omdelMian.HMaker}',GETDATE()," + |
| | | $"{omdelMian.HSubORGID},'{omdelMian.HAddress}',{omdelMian.HPURCHASEORGID}, {omdelMian.HSupplierID}, {omdelMian.HSettleCurrId}" + |
| | | $",'{omdelMian.HRemark}','{omdelMian.HExplanation}')"); |
| | | } |
| | | else if (OperationType == 3) |
| | | { |
| | | //ä¿®æ¹ |
| | | oCN.RunProc($"update Cg_PODemandPlanBillMain set HUpDater='{omdelMian.HMaker}',HUpDateDate=GETDATE()" + |
| | | $",HSubORGID={omdelMian.HSubORGID},HAddress='{omdelMian.HAddress}',HPURCHASEORGID={omdelMian.HPURCHASEORGID}" + |
| | | $",HSupplierID={omdelMian.HSupplierID},HSettleCurrId={omdelMian.HSettleCurrId}" + |
| | | $",HRemark='{omdelMian.HRemark}',HExplanation='{omdelMian.HExplanation}' where HInterID={omdelMian.HInterID}"); |
| | | } |
| | | //ä¿åå表 |
| | | objJsonResult = AddBillSub(msg3, hentryid); |
| | | 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, int hentryid) |
| | | { |
| | | if (hentryid != -1) |
| | | { |
| | | //è·åè¡¨æ ¼æ°æ® |
| | | ds = oCN.RunProcReturn($"select * from h_v_JIT_Cg_PODemandPlanBillList where åæ®å·='{omdelMian.HBillNo}'", "h_v_JIT_Cg_PODemandPlanBillList"); |
| | | //å é¤å表 |
| | | oCN.RunProc("delete from Cg_PODemandPlanBillSub where HInterID='" + omdelMian.HInterID.ToString() + "' and HEntryID='" + hentryid + "'"); |
| | | } |
| | | |
| | | |
| | | omodelsub = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Cg_PODemandPlanBillSub>>(msg3); |
| | | int i = 1; |
| | | //æå
¥å表 |
| | | foreach (Models.Cg_PODemandPlanBillSub oSub in omodelsub) |
| | | { |
| | | oCN.RunProc("insert into Cg_PODemandPlanBillSub(HInterID,HEntryID,HLaterReason,HMaterID,HMaterName" + |
| | | ", HMaterModel, HUnitID, HErpClsID, HQty, HRemark" + |
| | | ", HPURCHASEORGID, HStatus, HFixleadTime, HDayPlanBillNo, HSourceInterID" + |
| | | ", HSourceEntryID, HSourceBillNo, HSourceBillType, HWorkShopID, HDayPlanDate" + |
| | | ", HRelationQty1, HPOOrderInterID, HPOOrderEntryID, HPOOrderBillNo, HPOOrderBillSEQ" + |
| | | ", HWWOrderInterID, HWWOrderEntryID, HWWOrderBillNo, HPurchaseDeptID, HCloseTypeSub" + |
| | | ", HCloseMan, HEntryCloseDate, HSendQty, HReciveQty, HCloseStatus" + |
| | | ", HRemoveQty, HSeOrderBillNo, HUnReciveQty, HPOOrderBillDate, HPOOrderBillDeliveryDate" + |
| | | ", HPOOrderBillRemark, HPOOrderBillNote)" + |
| | | $"values({omdelMian.HInterID}, {(hentryid == -1 ? i : omodelsub.Count == 1 ? hentryid : i == 1 ? hentryid : (i + ds.Tables[0].Rows.Count - 1))}, '{oSub.HLaterReason}', {(oSub.HMaterID == null ? 0 : oSub.HMaterID)}, '{oSub.HMaterName}'" + |
| | | $", '{oSub.HMaterModel}', {(oSub.HUnitID == null ? 0 : oSub.HUnitID)}, '{oSub.HErpClsID}', {(oSub.HQty == null ? 0 : oSub.HQty)}, '{oSub.HRemark}'" + |
| | | $", {(oSub.HPURCHASEORGID == null ? 0 : oSub.HPURCHASEORGID)}, '{oSub.HStatus}', {(oSub.HFixleadTime == null ? 0 : oSub.HFixleadTime)}, '{oSub.HDayPlanBillNo}', {oSub.HSourceInterID}" + |
| | | $", {oSub.HSourceEntryID}, '{oSub.HSourceBillNo}', '{oSub.HSourceBillType}', {(oSub.HWorkShopID == null ? 0 : oSub.HWorkShopID)}, '{oSub.HDayPlanDate}'" + |
| | | $", {(oSub.HRelationQty1 == null ? 0 : oSub.HRelationQty1)}, {(oSub.HPOOrderInterID == null ? 0 : oSub.HPOOrderInterID)},{(oSub.HPOOrderEntryID == null ? 0 : oSub.HPOOrderEntryID)}, '{oSub.HPOOrderBillNo}',{(oSub.HPOOrderBillSEQ == null ? 0 : oSub.HPOOrderBillSEQ)}" + |
| | | $",{(oSub.HWWOrderInterID == null ? 0 : oSub.HWWOrderInterID)},{(oSub.HWWOrderEntryID == null ? 0 : oSub.HWWOrderEntryID)}, '{oSub.HWWOrderBillNo}',{(oSub.HPurchaseDeptID == null ? 0 : oSub.HPurchaseDeptID)}, '{(oSub.HCloseTypeSub == true ? 1 : 0)}'" + |
| | | $", '{oSub.HCloseMan}','{oSub.HEntryCloseDate}',{(oSub.HSendQty == null ? 0 : oSub.HSendQty)},{(oSub.HReciveQty == null ? 0 : oSub.HReciveQty)}, '{(oSub.HCloseStatus == true ? 1 : 0)}'" + |
| | | $",{(oSub.HRemoveQty == null ? 0 : oSub.HRemoveQty)}, '{oSub.HSeOrderBillNo}',{(oSub.HUnReciveQty == null ? 0 : oSub.HUnReciveQty)}, '{oSub.HPOOrderBillDate}', '{oSub.HPOOrderBillDeliveryDate}'" + |
| | | $", '{oSub.HPOOrderBillRemark}', '{oSub.HPOOrderBillNote}')"); |
| | | i++; |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = null; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ææè®¡åå å é¤ |
| | | [Route("Cg_PODemandPlanBill/DelPODemandPlanBillList")] |
| | | [HttpGet] |
| | | public object DelPODemandPlanBillList(string HInterID, string HEntryID, string User) |
| | | { |
| | | try |
| | | { |
| | | //å 餿é |
| | | if (!DBUtility.ClsPub.Security_Log_second("Cg_PODemandPlanBill_Drop", 1, false, User)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "æ æéå é¤ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ds = oCN.RunProcReturn("select * from h_v_JIT_Cg_PODemandPlanBillList where 1=1 and hmainid=" + HInterID, "h_v_JIT_Cg_PODemandPlanBillList"); |
| | | |
| | | if (ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | if (ds.Tables[0].Rows[0]["åæ®ç¶æ"].ToString() != "1") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "å½ååæ®ä¸è½å é¤ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | oCN.BeginTran();//å¼å¯äºå¡ |
| | | |
| | | if (ds.Tables[0].Rows.Count == 1) |
| | | { |
| | | oCN.RunProc($"delete from Cg_PODemandPlanBillMain where HInterID={HInterID}"); |
| | | } |
| | | oCN.RunProc($"delete from Cg_PODemandPlanBillSub where HInterID={HInterID} and HEntryID={HEntryID}"); |
| | | |
| | | oCN.Commit();//ç»æäºå¡ |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "å 餿åï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | 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; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region ææè®¡åå å
³é |
| | | [Route("Cg_PODemandPlanBill/ClosePODemandPlanBillList")] |
| | | [HttpGet] |
| | | public object ClosePODemandPlanBillList(string HInterID, string User) |
| | | { |
| | | try |
| | | { |
| | | //å
³éæé |
| | | if (!DBUtility.ClsPub.Security_Log_second("Cg_PODemandPlanBill_Close", 1, false, User)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "æ æéå
³éï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ds = oCN.RunProcReturn("select * from h_v_JIT_Cg_PODemandPlanBillList where 1=1 and hmainid=" + HInterID, "h_v_JIT_Cg_PODemandPlanBillList"); |
| | | |
| | | if (ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | if (ds.Tables[0].Rows[0]["åæ®ç¶æ"].ToString() == "2") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "å½ååæ®æ£å¨å®¡æ ¸,ä¸è½å
³éï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | oCN.BeginTran();//å¼å¯äºå¡ |
| | | |
| | | oCN.RunProc($"update Cg_PODemandPlanBillMain set HBillStatus=3,HCloseMan='{User}',HCloseDate=getdate() where HInterID={HInterID}"); |
| | | |
| | | oCN.Commit();//ç»æäºå¡ |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "å
³éæåï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | 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; |
| | | } |
| | | } |
| | | #endregion |
| | | } |
| | | } |