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(); #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/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 } }