|  |  | 
 |  |  | using Newtonsoft.Json.Linq; | 
 |  |  | using Pub_Class; | 
 |  |  | using System; | 
 |  |  | using System.Collections.Generic; | 
 |  |  | using System.Data; | 
 |  |  | 
 |  |  | { | 
 |  |  |     public class Sc_MESEndWorkBillController : ApiController | 
 |  |  |     { | 
 |  |  |         public DBUtility.ClsPub.Enum_BillStatus BillStatus;//单据状态(新增,修改,浏览,更新单价,变更) | 
 |  |  |  | 
 |  |  |         private json objJsonResult = new json(); | 
 |  |  |         public DataSet ds = new DataSet(); | 
 |  |  |         public WebServer webserver = new WebServer(); | 
 |  |  |         //获取系统参数 | 
 |  |  |         Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); | 
 |  |  |         Pub_Class.ClsXt_SystemParameterMain oSystemParameterMain = new Pub_Class.ClsXt_SystemParameterMain(); | 
 |  |  |  | 
 |  |  |         public DAL.ClsSc_MESEndWorkBill BillNew = new DAL.ClsSc_MESEndWorkBill();   //对应单据类 | 
 |  |  |         public DAL.ClsSc_MESEndWorkBill BillOld = new DAL.ClsSc_MESEndWorkBill();   //对应单据类 | 
 |  |  |  | 
 |  |  |         #region 完工单 | 
 |  |  |  | 
 |  |  | 
 |  |  |         /// <returns></returns> | 
 |  |  |         [Route("Sc_MESEndWorkBill/DeltetMESEndWorkBill")] | 
 |  |  |         [HttpGet] | 
 |  |  |         public object DeltetMESEndWorkBill(string HInterID) | 
 |  |  |         public object DeltetMESEndWorkBill(string HInterID,string UserName) | 
 |  |  |         { | 
 |  |  |             DBUtility.ClsPub.CurUserName = UserName; | 
 |  |  |             //编辑权限 | 
 |  |  |             if (!DBUtility.ClsPub.Security_Log("MES_MESEndWorkBill_Delete", 1, true, DBUtility.ClsPub.CurUserName)) | 
 |  |  |             if (!DBUtility.ClsPub.Security_Log_second("MES_MESEndWorkBill_Delete", 1, false, DBUtility.ClsPub.CurUserName)) | 
 |  |  |             { | 
 |  |  |                 objJsonResult.code = "0"; | 
 |  |  |                 objJsonResult.count = 0; | 
 |  |  | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  |                 //审核权限 | 
 |  |  |                 if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, true, CurUserName)) | 
 |  |  |                 if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName)) | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  | 
 |  |  |                     } | 
 |  |  |                     else | 
 |  |  |                     { | 
 |  |  |                         objJsonResult.code = "1"; | 
 |  |  |                         objJsonResult.count = 1; | 
 |  |  |                         objJsonResult.code = "0"; | 
 |  |  |                         objJsonResult.count = 0; | 
 |  |  |                         objJsonResult.Message = "审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo; | 
 |  |  |                         objJsonResult.data = null; | 
 |  |  |                         return objJsonResult; | 
 |  |  | 
 |  |  |                     } | 
 |  |  |                     else | 
 |  |  |                     { | 
 |  |  |                         objJsonResult.code = "1"; | 
 |  |  |                         objJsonResult.count = 1; | 
 |  |  |                         objJsonResult.code = "0"; | 
 |  |  |                         objJsonResult.count = 0; | 
 |  |  |                         objJsonResult.Message = "反审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo; | 
 |  |  |                         objJsonResult.data = null; | 
 |  |  |                         return objJsonResult; | 
 |  |  | 
 |  |  |         [HttpPost] | 
 |  |  |         public object SaveGetMESEndFrom([FromBody] JObject msg) | 
 |  |  |         { | 
 |  |  |             var _value = msg["msg"].ToString(); | 
 |  |  |             string msg1 = _value.ToString(); | 
 |  |  |             string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); | 
 |  |  |             string msg2 = sArray[0].ToString(); | 
 |  |  |             string UserName = sArray[1].ToString(); | 
 |  |  |             string refSav = sArray[2].ToString(); | 
 |  |  |             DBUtility.ClsPub.CurUserName = UserName; | 
 |  |  |  | 
 |  |  |             //保存权限 | 
 |  |  |             if (!DBUtility.ClsPub.Security_Log("MES_MESEndWorkBill_Edit", 1, true, DBUtility.ClsPub.CurUserName)) | 
 |  |  |             if (!DBUtility.ClsPub.Security_Log_second("MES_MESEndWorkBill_Edit", 1, false, DBUtility.ClsPub.CurUserName)) | 
 |  |  |             { | 
 |  |  |                 objJsonResult.code = "0"; | 
 |  |  |                 objJsonResult.count = 0; | 
 |  |  | 
 |  |  |                 return objJsonResult; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             var _value = msg["msg"].ToString(); | 
 |  |  |             string msg1 = _value.ToString(); | 
 |  |  |             string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); | 
 |  |  |             string msg2 = sArray[0].ToString(); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |             string UserName = ""; | 
 |  |  |             ListModels oListModels = new ListModels(); | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  | 
 |  |  |                 lsmain = oListModels.getObjectByJson_Gy_MESEndWorkBillMain(msg2); | 
 |  |  |                 foreach (Models.ClsSc_MESEndWorkBillMain oItem in lsmain) | 
 |  |  |                 { | 
 |  |  |                     if (refSav == "Add") | 
 |  |  |                     { | 
 |  |  |                         //单据号是否重复 | 
 |  |  |                         if (BillNew.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, BillOld.omodel.HInterID)) | 
 |  |  |                         { | 
 |  |  |                             objJsonResult.code = "0"; | 
 |  |  |                             objJsonResult.count = 0; | 
 |  |  |                             objJsonResult.Message = "单据号重复!不允许保存!"; | 
 |  |  |                             objJsonResult.data = 1; | 
 |  |  |                             return objJsonResult; | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                     if (refSav == "Update") | 
 |  |  |                     { | 
 |  |  |                         if (BillOld.ShowBill(oItem.HInterID, ref s) == false) | 
 |  |  |                         { | 
 |  |  |                             objJsonResult.code = "0"; | 
 |  |  |                             objJsonResult.count = 0; | 
 |  |  |                             objJsonResult.Message = "此单据有误!"; | 
 |  |  |                             objJsonResult.data = 1; | 
 |  |  |                             return objJsonResult; | 
 |  |  |                         } | 
 |  |  |                         //判断是否可编辑 | 
 |  |  |                         if (BillOld.omodel.HChecker != "" && BillOld.omodel.HChecker != null) | 
 |  |  |                         { | 
 |  |  |                             objJsonResult.code = "0"; | 
 |  |  |                             objJsonResult.count = 0; | 
 |  |  |                             objJsonResult.Message = "此单据已经被审核,不允许修改!"; | 
 |  |  |                             objJsonResult.data = 1; | 
 |  |  |                             return objJsonResult; | 
 |  |  |                         } | 
 |  |  |                         if (BillOld.omodel.HBillStatus > 1) | 
 |  |  |                         { | 
 |  |  |                             objJsonResult.code = "0"; | 
 |  |  |                             objJsonResult.count = 0; | 
 |  |  |                             objJsonResult.Message = "此单据处于不可编辑状态,不允许修改!"; | 
 |  |  |                             objJsonResult.data = 1; | 
 |  |  |                             return objJsonResult; | 
 |  |  |                         } | 
 |  |  |                         if (!DBUtility.Xt_BaseBillFun.Fun_AllowEditBill(BillOld, ref s)) | 
 |  |  |                         { | 
 |  |  |                             objJsonResult.code = "0"; | 
 |  |  |                             objJsonResult.count = 0; | 
 |  |  |                             objJsonResult.Message = s + ",不允许修改"; | 
 |  |  |                             objJsonResult.data = 1; | 
 |  |  |                             return objJsonResult; | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     //oItem.HMaker = ""; | 
 |  |  |                     UserName = oItem.HMaker;  //制单人 | 
 |  |  |                     DBUtility.ClsPub.CurUserName = oItem.HMaker; | 
 |  |  | 
 |  |  |                         string sReturn = ""; | 
 |  |  |                         if (oSystemParameter.ShowBill(ref sReturn) == true) | 
 |  |  |                         { | 
 |  |  |                             if (oSystemParameterMain.Sc_MESEndWorkBill_AutoCheck == "Y") //系统参数  自动审核  | 
 |  |  |                             if (oSystemParameter.omodel.Sc_MESEndWorkBill_AutoCheck == "Y") //系统参数  自动审核  | 
 |  |  |                             { | 
 |  |  |                                 objJsonResult.Verify = "Y"; | 
 |  |  |                             } | 
 |  |  | 
 |  |  |                 } | 
 |  |  |                 if (bResult) | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.code = "1"; | 
 |  |  |                     objJsonResult.count = 1; | 
 |  |  |                     objJsonResult.Message = "保存成功!"; | 
 |  |  |                     //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单"); |