| | |
| | | using System; |
| | | using DBUtility; |
| | | using Newtonsoft.Json.Linq; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Data; |
| | | using System.Linq; |
| | |
| | | { |
| | | public class Sc_JIT_ComplementGoodBillController : ApiController |
| | | { |
| | | ClsXt_BaseBillMain omdelMian = new ClsXt_BaseBillMain(); |
| | | List<Gy_WorkWarehouseBillMainSub> omodelsub = new List<Gy_WorkWarehouseBillMainSub>(); |
| | | List<Cg_PODemandPlanConfigBillSub> omodelPODsub = new List<Cg_PODemandPlanConfigBillSub>(); |
| | | List<JIT_NeedMaterPlanConfigBillSub> omodelNeedsub = new List<JIT_NeedMaterPlanConfigBillSub>(); |
| | | private json objJsonResult = new json(); |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | DataSet ds; |
| | | |
| | | #region 日计划平台基础资料 车间仓库对照列表 |
| | | #region 日计划平台基础资料 车间仓库对照 |
| | | |
| | | #region 车间仓库对照列表 |
| | | [Route("Sc_JIT_ComplementGoodBill/ComplementGoodBillList")] |
| | | [HttpGet] |
| | | public object ComplementGoodBillList(string sWhere, string user) |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region 车间仓库对照 添加/修改 |
| | | [Route("Sc_JIT_ComplementGoodBill/AddComplementGoodBillList")] |
| | | [HttpPost] |
| | | public object AddComplementGoodBillList([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("JIT_ComplementGoodBill_Edit", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无保存权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | omdelMian = Newtonsoft.Json.JsonConvert.DeserializeObject<ClsXt_BaseBillMain>(msg2); |
| | | string BillType = "4612"; |
| | | |
| | | |
| | | if (OperationType == 1)//新增 |
| | | { |
| | | //主表 |
| | | oCN.RunProc("insert into Gy_WorkWarehouseBillMain(HInterID,HBillNo,HYear,HPeriod,HBillType,HBillSubType,HDate,HBillStatus,HMaker,HMakeDate,HOrgId)" + |
| | | $"values({omdelMian.HInterID}, '{omdelMian.HBillNo}',{DateTime.Now.Year}, {DateTime.Now.Month}, '{BillType}', '{BillType}', GETDATE(), 1, '{omdelMian.HMaker}', GETDATE(),{omdelMian.HPRDORGID})"); |
| | | } |
| | | else if (OperationType == 3) |
| | | { |
| | | //修改 |
| | | oCN.RunProc("UpDate Gy_WorkWarehouseBillMain set " + |
| | | " HOrgId='" + omdelMian.HPRDORGID + "'" + |
| | | ",HUpDater='" + omdelMian.HMaker + "'" + |
| | | ",HUpDateDate='" + DateTime.Now+ "'" + |
| | | " where HInterID=" + omdelMian.HInterID.ToString()); |
| | | |
| | | //删除子表 |
| | | oCN.RunProc("delete from Gy_WorkWarehouseBillMainSub where HInterID='" + omdelMian.HInterID.ToString() + "' and HEntryID='" + hentryid + "'"); |
| | | } |
| | | //保存子表 |
| | | 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) |
| | | { |
| | | omodelsub = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Gy_WorkWarehouseBillMainSub>>(msg3); |
| | | int i = 1; |
| | | //插入子表 |
| | | foreach (Models.Gy_WorkWarehouseBillMainSub oSub in omodelsub) |
| | | { |
| | | oCN.RunProc("insert into Gy_WorkWarehouseBillMainSub(HInterID,HEntryID,HRemark,HWorkShopID," + |
| | | "HWorkShopName,HWHID,HWHName) " + |
| | | "values(" |
| | | + omdelMian.HInterID.ToString() + "," + (hentryid == -1 ? i : hentryid) + ",'" + oSub.HRemark + "'," + (oSub.HWorkShopID==null?0:oSub.HWorkShopID) |
| | | + ",'" +oSub.HWorkShopName + "'," + (oSub.HWHID==null?0: oSub.HWHID) + ",'" + oSub.HWHName.ToString()+ "') "); |
| | | i++; |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = null; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 车间仓库对照删除 |
| | | [Route("Sc_JIT_ComplementGoodBill/DelComplementGoodBillList")] |
| | | [HttpGet] |
| | | public object DelComplementGoodBillList(string HInterID, string HEntryID, string User) |
| | | { |
| | | try |
| | | { |
| | | //删除权限 |
| | | if (!DBUtility.ClsPub.Security_Log_second("JIT_ComplementGoodBill_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_Gy_WorkWarehouseBillList where 1=1 and hmainid=" + HInterID, "h_v_JIT_Gy_WorkWarehouseBillList"); |
| | | |
| | | 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 Gy_WorkWarehouseBillMain where HInterID={HInterID}"); |
| | | } |
| | | oCN.RunProc($"delete from Gy_WorkWarehouseBillMainSub 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 |
| | | |
| | | #endregion |
| | | |
| | | #region 日计划平台基础资料 提料计划信息 |
| | | |
| | | #region 提料计划信息列表 |
| | | [Route("Sc_JIT_ComplementGoodBill/PODemandPlanConfigBillList")] |
| | | [HttpGet] |
| | | public object PODemandPlanConfigBillList(string sWhere, string user) |
| | | { |
| | | try |
| | | { |
| | | //查询权限 |
| | | if (!DBUtility.ClsPub.Security_Log_second("Cg_PODemandPlanConfigBill_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_PODemandPlanConfigBillList where 1=1 " + sWhere + " order by hmainid desc ", "h_v_JIT_Cg_PODemandPlanConfigBillList"); |
| | | |
| | | 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 = e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 提料计划信息 添加/修改 |
| | | [Route("Sc_JIT_ComplementGoodBill/AddPODemandPlanConfigBillList")] |
| | | [HttpPost] |
| | | public object AddPODemandPlanConfigBillList([FromBody] JObject sMainSub) |
| | | { |
| | | var _value = sMainSub["sMainSub"].ToString(); |
| | | string msg1 = _value.ToString(); |
| | | oCN.BeginTran(); |
| | | //保存主表 |
| | | objJsonResult = AddPODBillMain(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 AddPODBillMain(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_PODemandPlanConfigBill_Edit", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无保存权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | omdelMian = Newtonsoft.Json.JsonConvert.DeserializeObject<ClsXt_BaseBillMain>(msg2); |
| | | string BillType = "4611"; |
| | | |
| | | |
| | | if (OperationType == 1)//新增 |
| | | { |
| | | //主表 |
| | | oCN.RunProc("insert into Cg_PODemandPlanConfigBillMain(HInterID,HBillNo,HYear,HPeriod,HBillType,HBillSubType,HDate,HBillStatus,HMaker,HMakeDate,HOrgId)" + |
| | | $"values({omdelMian.HInterID}, '{omdelMian.HBillNo}',{DateTime.Now.Year}, {DateTime.Now.Month}, '{BillType}', '{BillType}', GETDATE(), 1, '{omdelMian.HMaker}', GETDATE(), {omdelMian.HPRDORGID})"); |
| | | } |
| | | else if (OperationType == 3) |
| | | { |
| | | //修改 |
| | | oCN.RunProc("UpDate Cg_PODemandPlanConfigBillMain set " + |
| | | " HOrgId='" + omdelMian.HPRDORGID + "'" + |
| | | ",HUpDater='" + omdelMian.HMaker + "'" + |
| | | ",HUpDateDate='" + DateTime.Now + "'" + |
| | | " where HInterID=" + omdelMian.HInterID.ToString()); |
| | | |
| | | //删除子表 |
| | | oCN.RunProc("delete from Cg_PODemandPlanConfigBillSub where HInterID='" + omdelMian.HInterID.ToString() + "' and HEntryID='" + hentryid + "'"); |
| | | } |
| | | //保存子表 |
| | | objJsonResult = AddPODBillSub(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 AddPODBillSub(string msg3, int hentryid) |
| | | { |
| | | omodelPODsub = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Cg_PODemandPlanConfigBillSub>>(msg3); |
| | | int i = 1; |
| | | //插入子表 |
| | | foreach (Models.Cg_PODemandPlanConfigBillSub oSub in omodelPODsub) |
| | | { |
| | | oCN.RunProc("insert into Cg_PODemandPlanConfigBillSub(HInterID,HEntryID,HRemark,HSupplierID,HSupplierName,HMaterID," + |
| | | "HMaterName, HMaterModel, HJITMaterGroup, HJITSafeStock, HJITMaterDemand, HJITBatchQty, HDeliveryPeriod, " + |
| | | "HLeadTime, HLeadTime_Sec, HDeliveryMode, HDeliveryDaysCtrl)values" + |
| | | $"({omdelMian.HInterID}, {(hentryid == -1 ? i : hentryid) }, '{oSub.HRemark}', {(oSub.HSupplierID==null?0: oSub.HSupplierID)}, '{oSub.HSupplierName}', {(oSub.HMaterID == null ? 0 : oSub.HMaterID)}," + |
| | | $" '{oSub.HMaterName}', '{oSub.HMaterModel}', '{oSub.HJITMaterGroup}', {(oSub.HJITSafeStock == null ? 0 : oSub.HJITSafeStock)}, {(oSub.HJITMaterDemand == null ? 0 : oSub.HJITMaterDemand)},{(oSub.HJITBatchQty == null ? 0 : oSub.HJITBatchQty)},{(oSub.HDeliveryPeriod == null ? 0 : oSub.HDeliveryPeriod)}," + |
| | | $" {(oSub.HLeadTime == null ? 0 : oSub.HLeadTime)}, {(oSub.HLeadTime_Sec == null ? 0 : oSub.HLeadTime_Sec)}, '{oSub.HDeliveryMode}', {(oSub.HDeliveryDaysCtrl == null ? 0 : oSub.HDeliveryDaysCtrl)}) "); |
| | | i++; |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = null; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 提料计划信息删除 |
| | | [Route("Sc_JIT_ComplementGoodBill/DelPODemandPlanConfigBillList")] |
| | | [HttpGet] |
| | | public object DelPODemandPlanConfigBillList(string HInterID, string HEntryID, string User) |
| | | { |
| | | try |
| | | { |
| | | //删除权限 |
| | | if (!DBUtility.ClsPub.Security_Log_second("Cg_PODemandPlanConfigBill_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_PODemandPlanConfigBillList where 1=1 and hmainid=" + HInterID, "h_v_JIT_Cg_PODemandPlanConfigBillList"); |
| | | |
| | | 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_PODemandPlanConfigBillMain where HInterID={HInterID}"); |
| | | } |
| | | oCN.RunProc($"delete from Cg_PODemandPlanConfigBillSub 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 |
| | | |
| | | #endregion |
| | | |
| | | #region 日计划平台基础资料 要料计划信息 |
| | | |
| | | #region 要料计划信息列表 |
| | | [Route("Sc_JIT_ComplementGoodBill/NeedMaterPlanConfigBillList")] |
| | | [HttpGet] |
| | | public object NeedMaterPlanConfigBillList(string sWhere, string user) |
| | | { |
| | | try |
| | | { |
| | | //查询权限 |
| | | if (!DBUtility.ClsPub.Security_Log_second("JIT_NeedMaterPlanConfigBill_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_NeedMaterPlanConfigBillList where 1=1 " + sWhere + " order by hmainid desc ", "h_v_JIT_NeedMaterPlanConfigBillList"); |
| | | |
| | | 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 = e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 要料计划信息列表 添加/修改 |
| | | [Route("Sc_JIT_ComplementGoodBill/AddNeedMaterPlanConfigBillList")] |
| | | [HttpPost] |
| | | public object AddNeedMaterPlanConfigBillList([FromBody] JObject sMainSub) |
| | | { |
| | | var _value = sMainSub["sMainSub"].ToString(); |
| | | string msg1 = _value.ToString(); |
| | | oCN.BeginTran(); |
| | | //保存主表 |
| | | objJsonResult = AddNeedBillMain(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 AddNeedBillMain(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("JIT_NeedMaterPlanConfigBill_Edit", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无保存权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | omdelMian = Newtonsoft.Json.JsonConvert.DeserializeObject<ClsXt_BaseBillMain>(msg2); |
| | | string BillType = "4615"; |
| | | |
| | | |
| | | if (OperationType == 1)//新增 |
| | | { |
| | | //主表 |
| | | |
| | | oCN.RunProc("insert into JIT_NeedMaterPlanConfigBillMain(HInterID,HBillNo,HYear,HPeriod,HBillType,HBillSubType,HDate,HBillStatus,HMaker,HMakeDate,HOrgId)" + |
| | | $"values({omdelMian.HInterID}, '{omdelMian.HBillNo}',{DateTime.Now.Year}, {DateTime.Now.Month}, '{BillType}', '{BillType}', GETDATE(), 1, '{omdelMian.HMaker}', GETDATE(), {omdelMian.HPRDORGID})"); |
| | | } |
| | | else if (OperationType == 3) |
| | | { |
| | | //修改 |
| | | oCN.RunProc("UpDate JIT_NeedMaterPlanConfigBillMain set " + |
| | | " HOrgId='" + omdelMian.HPRDORGID + "'" + |
| | | ",HUpDater='" + omdelMian.HMaker + "'" + |
| | | ",HUpDateDate='" + DateTime.Now + "'" + |
| | | " where HInterID=" + omdelMian.HInterID.ToString()); |
| | | |
| | | //删除子表 |
| | | oCN.RunProc("delete from JIT_NeedMaterPlanConfigBillSub where HInterID='" + omdelMian.HInterID.ToString() + "' and HEntryID='" + hentryid + "'"); |
| | | } |
| | | //保存子表 |
| | | objJsonResult = AddNeedBillSub(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 AddNeedBillSub(string msg3, int hentryid) |
| | | { |
| | | omodelNeedsub = Newtonsoft.Json.JsonConvert.DeserializeObject<List<JIT_NeedMaterPlanConfigBillSub>>(msg3); |
| | | int i = 1; |
| | | //插入子表 |
| | | foreach (Models.JIT_NeedMaterPlanConfigBillSub oSub in omodelNeedsub) |
| | | { |
| | | oCN.RunProc("insert into JIT_NeedMaterPlanConfigBillSub(HInterID,HEntryID,HRemark,HWorkShopID,HWorkShopName,HMaterID," + |
| | | "HMaterName, HMaterModel, HJITMaterGroup, HJITSafeStock, HJITMaterDemand, HJITBatchQty, HDeliveryPeriod, " + |
| | | "HLeadTime, HLeadTime_Sec, HDeliveryMode, HDeliveryDaysCtrl)values" + |
| | | $"({omdelMian.HInterID}, {(hentryid == -1 ? i : hentryid) }, '{oSub.HRemark}', {(oSub.HWorkShopID == null ? 0 : oSub.HWorkShopID)}, '{oSub.HWorkShopName}', {(oSub.HMaterID == null ? 0 : oSub.HMaterID)}," + |
| | | $" '{oSub.HMaterName}', '{oSub.HMaterModel}', '{oSub.HJITMaterGroup}', {(oSub.HJITSafeStock == null ? 0 : oSub.HJITSafeStock)}, {(oSub.HJITMaterDemand == null ? 0 : oSub.HJITMaterDemand)},{(oSub.HJITBatchQty == null ? 0 : oSub.HJITBatchQty)},{(oSub.HDeliveryPeriod == null ? 0 : oSub.HDeliveryPeriod)}," + |
| | | $" {(oSub.HLeadTime == null ? 0 : oSub.HLeadTime)}, {(oSub.HLeadTime_Sec == null ? 0 : oSub.HLeadTime_Sec)}, '{oSub.HDeliveryMode}', {(oSub.HDeliveryDaysCtrl == null ? 0 : oSub.HDeliveryDaysCtrl)}) "); |
| | | i++; |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = null; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 要料计划信息删除 |
| | | [Route("Sc_JIT_ComplementGoodBill/DelNeedMaterPlanConfigBillList")] |
| | | [HttpGet] |
| | | public object DelNeedMaterPlanConfigBillList(string HInterID, string HEntryID, string User) |
| | | { |
| | | try |
| | | { |
| | | //删除权限 |
| | | if (!DBUtility.ClsPub.Security_Log_second("JIT_NeedMaterPlanConfigBill_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_NeedMaterPlanConfigBillList where 1=1 and hmainid=" + HInterID, "h_v_JIT_NeedMaterPlanConfigBillList"); |
| | | |
| | | 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 JIT_NeedMaterPlanConfigBillMain where HInterID={HInterID}"); |
| | | } |
| | | oCN.RunProc($"delete from JIT_NeedMaterPlanConfigBillSub 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 |
| | | |
| | | #endregion |
| | | |
| | | |
| | | } |
| | | } |