From c7964cefb465dfa8e33d96eae2de331e1e9772a2 Mon Sep 17 00:00:00 2001
From: yusijie <ysj@hz-kingdee.com>
Date: 星期三, 19 十月 2022 10:55:34 +0800
Subject: [PATCH] 动态列

---
 WebAPI/Controllers/CJGL/Cj_StationEntrustOutBillController.cs |  661 +++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 597 insertions(+), 64 deletions(-)

diff --git a/WebAPI/Controllers/CJGL/Cj_StationEntrustOutBillController.cs b/WebAPI/Controllers/CJGL/Cj_StationEntrustOutBillController.cs
index 1691687..046411a 100644
--- a/WebAPI/Controllers/CJGL/Cj_StationEntrustOutBillController.cs
+++ b/WebAPI/Controllers/CJGL/Cj_StationEntrustOutBillController.cs
@@ -1,4 +1,5 @@
-锘縰sing Newtonsoft.Json.Linq;
+锘縰sing Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
 using Pub_Class;
 using System;
 using System.Collections;
@@ -14,49 +15,69 @@
     public class Cj_StationEntrustOutBillController : ApiController
     {
         public DBUtility.ClsPub.Enum_BillStatus BillStatus;
+        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
 
         private json objJsonResult = new json();
         SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
         DataSet ds;
 
 
-        /// <summary>
-        /// 杩斿洖濮斿宸ュ簭鎺ユ敹鍗曞垪琛�
-        ///鍙傛暟锛歴tring sql銆�
-        ///杩斿洖鍊硷細object銆�
-        /// </summary>
+        #region 杩斿洖濮斿宸ュ簭鎺ユ敹鍗曞垪琛�
         [Route("Cj_StationEntrustOutBill/list")]
         [HttpGet]
-        public object list(string sWhere)
+        public object list(string sWhere,string user)
         {
             try
             {
+                List<object> columnNameList = new List<object>();
+                //鍒ゆ柇鏄惁鏈夋煡璇㈡潈闄�
+                if (!DBUtility.ClsPub.Security_Log("MES_StationEntrustOutBill_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡璇㈡潈闄�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
                 if (sWhere == null || sWhere.Equals(""))
                 {
-                    ds = oCN.RunProcReturn("select * from h_v_MES_StationEntrustOutBillList " + sWhere+ " order by 鎺ユ敹鏃堕棿 desc", "h_v_MES_StationEntrustOutBillList");
+                    ds = oCN.RunProcReturn("select * from h_v_MES_StationEntrustOutBillList ", "h_v_MES_StationEntrustOutBillList");
+                    //order by hmainid desc 鎺掑簭涓㈠埌鏁版嵁搴撻噷杩涜澶勭悊
                 }
                 else
                 {
                     string sql1 = "select * from h_v_MES_StationEntrustOutBillList where 1 = 1 ";
-                    string sql = sql1 + sWhere;
+                    string sql = sql1 + sWhere+ " order by hmainid desc";
                     ds = oCN.RunProcReturn(sql, "h_v_MES_StationEntrustOutBillList");
                 }
-                if (ds == null || ds.Tables[0].Rows.Count == 0)
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
                 {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "false锛�";
-                    objJsonResult.data = null;
-                    return objJsonResult;
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
                 }
-                else
-                {
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "Sucess锛�";
-                    objJsonResult.data = ds.Tables[0];
-                    return objJsonResult;
-                }
+
+
+                //if (ds.Tables[0].Rows.Count != 0 || ds != null)
+                //{
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.list = columnNameList;
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+                //}
+                //else
+                //{
+                //objJsonResult.code = "0";
+                //objJsonResult.count = 0;
+                //objJsonResult.Message = "鏃犳暟鎹�";
+                //objJsonResult.data = null;
+                //return objJsonResult;
+                //}
             }
             catch (Exception e)
             {
@@ -67,23 +88,35 @@
                 return objJsonResult;
             }
         }
+        #endregion
 
-        /// <summary>
-        /// 鏂板鍗曟嵁-淇濆瓨鎸夐挳
-        ///鍙傛暟锛歴tring sql銆�
-        ///杩斿洖鍊硷細object銆�
-        /// </summary>
+        #region 鏂板鍗曟嵁-淇濆瓨鎸夐挳
         [Route("Cj_StationEntrustOutBill/AddBill")]
         [HttpPost]
         public object AddBill([FromBody] JObject oMain)
         {
             var _value = oMain["oMain"].ToString();
             string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
             try
             {
                 //閮ㄩ棬鍩虹璧勬枡鍙嶅簭鍒楀寲
-                msg1 = "[" + msg1.ToString() + "]";
-                List<StationBill> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<StationBill>>(msg1);
+               string msg2 = "[" + sArray[0].ToString() + "]";
+                string user = sArray[1].ToString();
+
+                //鍒ゆ柇鏄惁鏈夌紪杈戞潈闄�
+                if (!DBUtility.ClsPub.Security_Log("MES_StationEntrustOutBill_Edit", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犵紪杈戞潈闄�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                List<StationBill> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<StationBill>>(msg2);
+                long HMainInterID = 0;
+                HMainInterID = list[0].HMainInterID;
                 string eventType = list[0].eventType;
                 long HInterID = list[0].HInterID;//閫掑叆type寰楀埌鐨勫崟鎹甀D
                 int HYear = 2021;
@@ -136,6 +169,7 @@
                 double HMainSourceInterID = 0;
                 string HMainSourceBillNo = "";
                 string HMainSourceBillType = "3792";
+                long HPRDOrgID = list[0].HPRDOrgID;//缁勭粐ID
                 if (HProcExchInterID <= 0)
                 {
                     objJsonResult.code = "0";
@@ -168,14 +202,14 @@
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
-                if (HInnerBillNo == "")
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "鍙戣揣鍙锋病鏈夎緭鍏ワ紒";
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
+                //if (HInnerBillNo == "")
+                //{
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "鍙戣揣鍙锋病鏈夎緭鍏ワ紒";
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
                 if (HProcID <= 0)
                 {
                     objJsonResult.code = "0";
@@ -204,18 +238,18 @@
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = "鎺ユ敹涓暟涓嶈兘灏忎簬绛変簬0锛�";
+                    objJsonResult.Message = "鍚堟牸鏁伴噺涓嶈兘灏忎簬绛変簬0锛�";
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
-                if (HWasterQty < 0)
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "涓嶅悎鏍兼暟涓嶈兘灏忎簬0锛�";
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
+                //if (HWasterQty < 0)
+                //{
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "涓嶅悎鏍兼暟涓嶈兘灏忎簬0锛�";
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
                 if (HTaxRate < 0)
                 {
                     objJsonResult.code = "0";
@@ -228,6 +262,7 @@
                 oCN.BeginTran();
                 if ("Add".Equals(eventType))
                 {
+                    //楠岃瘉鍗曟嵁鍙锋槸鍚﹂噸澶�
                     if (!AllowbillNo(HBillNo))
                     {
                         oCN.RollBack();
@@ -245,7 +280,7 @@
                     ",HProcExchBillNo,HMaterID,HProcID,HICMOQty,HPlanQty,HStationOutTime,HSourceID" +
                     ",HGroupID,HDeptID,HEmpID,HBarCode,HAddr,HBarCodeMaker,HBarCodeMakeDate" +
                     ",HSupID,HTaxRate,HQty,HPrice,HMoney,HPrice_BHS,HMoney_BHS,HBadCount" +
-                    ",HMainSourceInterID,HMainSourceBillNo,HMainSourceBillType,HProcNo,HOrderProcNO,HLastSubProc,HWWWorkOrderBillNo,HWWWorkOrderInterID,HWWWorkOrderEntryID" +
+                    ",HMainSourceInterID,HMainSourceBillNo,HMainSourceBillType,HProcNo,HOrderProcNO,HLastSubProc,HWWWorkOrderBillNo,HWWWorkOrderInterID,HWWWorkOrderEntryID,HMainInterID,HPRDOrgID" +
                     ") " +
                     " values('" + BillType + "','" + BillType + "'," + HInterID + ",'" + HBillNo + "'," + HBillStatus + ",getdate(),'" + HMaker + "',getdate()" +
                     "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HInnerBillNo + "','" + HSourceName + "'," + HPieceQty + "," + HWasterQty + "," + HPlanPieceQty + "," + HBadPNL +
@@ -253,7 +288,7 @@
                     ",'" + HProcExchBillNo + "'," + HMaterID + "," + HProcID + "," + HICMOQty + "," + HPlanQty + ",getdate()," + HSourceID +
                     "," + HGroupID + "," + HDeptID + "," + HEmpID + ",'" + HBarCode + "','" + HAddr + "','" + HBarCodeMaker + "',getdate()" +
                     "," + HSupID + "," + HTaxRate + "," + HQty + "," + HPrice + "," + HMoney + "," + HPrice_BHS + "," + HMoney_BHS + "," + HBadCount +
-                    "," + HMainSourceInterID + ",'" + HMainSourceBillNo + "','" + HMainSourceBillType + "'," + HProcNo + ",'" + HOrderProcNO + "'," + Convert.ToString(HLastSubProc ? 1 : 0) + ",'" + HWWWorkOrderBillNo + "'," + HWWWorkOrderInterID + "," + HWWWorkOrderEntryID +
+                    "," + HMainSourceInterID + ",'" + HMainSourceBillNo + "','" + HMainSourceBillType + "'," + HProcNo + ",'" + HOrderProcNO + "'," + Convert.ToString(HLastSubProc ? 1 : 0) + ",'" + HWWWorkOrderBillNo + "'," + HWWWorkOrderInterID + "," + HWWWorkOrderEntryID + "," + HMainInterID + "," + HPRDOrgID +
                     ") ");
                 }
                 else if ("Modify".Equals(eventType))
@@ -311,18 +346,30 @@
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
-                if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) == "2")
-                {
-                    oCN.RollBack();
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
+                //if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) == "2")
+                //{
+                //    oCN.RollBack();
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
                 oCN.RunProc("exec h_p_Mes_ProcessExchangeRelationQty_Out " + HInterID.ToString() + ",1");
                 oCN.RunProc("exec h_p_WW_EntrustWorkOrderRelationQty_Out " + HInterID.ToString() + ",1");
                 oCN.Commit();
+                string sReturn = "";
+                if (oSystemParameter.ShowBill(ref sReturn) == true)
+                {
+                    if (oSystemParameter.omodel.MES_StationEntrustOutBill_SaveAutoAddnew == "Y") //绯荤粺鍙傛暟  鑷姩瀹℃牳 
+                    {
+                        objJsonResult.Verify = "Y";
+                    }
+                    else
+                    {
+                        objJsonResult.Verify = "N";
+                    }
+                }
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
                 objJsonResult.Message = "鏂板鍗曟嵁鎴愬姛锛�";
@@ -338,6 +385,8 @@
                 return objJsonResult;
             }
         }
+
+        //楠岃瘉鍗曟嵁鍙锋槸鍚﹂噸澶�
         private bool AllowbillNo(string HBillNo)
         {
             ds = oCN.RunProcReturn("select HBillNo from Sc_StationOutBillMain where  HBillNo = '" + HBillNo + "'", "Sc_StationOutBillMain");
@@ -347,11 +396,9 @@
             }
             return false;
         }
-        /// <summary>
-        /// 缂栬緫椤甸潰鏍规嵁id鑾峰彇濮斿宸ュ簭鎺ユ敹鍗曚俊鎭�
-        ///鍙傛暟锛歴tring sql銆�
-        ///杩斿洖鍊硷細object銆�
-        /// </summary>
+        #endregion
+
+        #region 缂栬緫椤甸潰鏍规嵁id鑾峰彇濮斿宸ュ簭鎺ユ敹鍗曚俊鎭�
         [Route("Cj_StationEntrustOutBill/GetStationEntrustOutBill")]
         [HttpGet]
         public object GetStationEntrustOutBill(int HInterID)
@@ -385,7 +432,493 @@
                 return objJsonResult;
             }
         }
+        #endregion
 
-        //
+        #region 鏍规嵁id鍒犻櫎濮斿鎺ユ敹鍗�
+        [Route("Cj_StationEntrustOutBill/del_StationEntrustOutBill")]
+        [HttpGet]
+        public object del_StationEntrustOutBill(long HInterID, string HDeleteMan)
+        {
+            try
+            {
+
+                //缂栬緫鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("MES_StationEntrustOutBill_Delete", 1, false, HDeleteMan))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                DAL.ClsSc_StationEntrustOutBill oBill = new DAL.ClsSc_StationEntrustOutBill();
+                if (oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo))
+                {
+                    if (oBill.omodel.HMaker != HDeleteMan && (HDeleteMan != "admin" && HDeleteMan != "Admin"))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍙兘鍒犻櫎鏈汉鐨勫崟鎹紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (oBill.omodel.HChecker != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁宸茬粡瀹℃牳,涓嶈兘鍒犻櫎锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+                    DataSet ds;
+                    //鍒ゆ柇鏄惁瀛樺湪 鐩稿悓鍗曟嵁鍙� 鐨勯鏂欏崟 鍒ゆ柇鐢熶骇璁㈠崟鏄惁宸茬粨妗堬紝瑕佹眰璁″垝鎵嬪伐鍙嶇粨妗�    
+                    ds = oCn.RunProcReturn("exec h_p_MES_StationOutBill_DelCtrl  '" + oBill.omodel.HBillNo + "'", "h_p_MES_StationOutBill_DelCtrl");
+                    if (ds == null)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍒ゆ柇鍏宠仈澶辫触锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (ds.Tables[0].Rows.Count > 0 && Pub_Class.ClsPub.isInt(ds.Tables[0].Rows[0][0]) == 2)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = Pub_Class.ClsPub.isStrNull(ds.Tables[0].Rows[0][1]);
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    //鍐欏叆鍒犻櫎鏃ュ織 
+                    string WorkList = "鍒犻櫎濮斿鎺ユ敹鍗曪細" + oBill.omodel.HBillNo;
+                    if (!oBill.DeleteBill(oBill.omodel.HInterID, oBill.omodel.HProcExchInterID, oBill.omodel.HProcExchEntryID, ref DBUtility.ClsPub.sExeReturnInfo))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍒犻櫎鎴愬姛锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁鏈壘鍒帮紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "寮傚父锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 缂栬緫鍓嶅垽鏂�
+        [Route("Cj_StationEntrustOutBill/set_ShowBillJudge")]
+        [HttpGet]
+        public object set_ShowBillJudge(string HBillNo, string CurUserName, long HInterID)
+        {
+            try
+            {
+                ds = oCN.RunProcReturn("exec h_p_MES_StationOutBill_DelCtrl  '" + HBillNo + "'", "h_p_MES_StationOutBill_DelCtrl");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍒ゆ柇鍏宠仈澶辫触锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else if (ds.Tables[0].Rows.Count > 0 && Pub_Class.ClsPub.isInt(ds.Tables[0].Rows[0][0]) == 2)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = Pub_Class.ClsPub.isStrNull(ds.Tables[0].Rows[0][1]);
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                //鍒ゆ柇鏉冮檺
+                if (!ClsPub.Security_Log("MES_StationEntrustOutBill_Edit", 1, false, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                ////鍒ゆ柇璇ョ敤鎴峰悕鏄惁鏈夎宸ョ珯鏉冮檺
+                //if (BillNew.CheckCenterIDByUser(DBUtility.ClsPub.isLong(66865)) == false)
+                //{
+                //    MessageBox.Show("娌℃湁璇ュ伐绔欐潈闄愶紒", "鎻愮ず");
+                //    return;
+                //}
+                ////妫�鏌ユ槸鍚﹀紑绁�
+                //string d = "";
+                //if (BillOld.CheckIsKP(BillOld.omodel.HInterID, ref d) == false)
+                //{
+                //    MessageBox.Show(d, "鎻愮ず");
+                //    return;
+                //}
+                string s = "";
+                DAL.ClsSc_StationEntrustOutBill BillOld = new DAL.ClsSc_StationEntrustOutBill();
+                if (BillOld.ShowBill(HInterID, ref s) == false)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "姝ゅ崟鎹湁閿欒锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //鍒ゆ柇鏄惁鍙紪杈�
+                if (BillOld.omodel.HChecker != "")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "姝ゅ崟鎹凡缁忚瀹℃牳锛屼笉鍏佽淇敼锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 瀹℃牳
+        [Route("Cj_StationEntrustOutBill/set_CheckBill")]
+        [HttpGet]
+        public object set_CheckBill(int HInterID, string CurUserName)
+        {
+            try
+            {
+                string ModRightNameCheck = "MES_StationEntrustOutBill_Check";
+                //瀹℃牳鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, false, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                if (HInterID == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁ID涓�0锛屼笉鑳藉鏍革紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                DAL.ClsSc_StationEntrustOutBill oBill = new DAL.ClsSc_StationEntrustOutBill();
+                //鏌ョ湅鏄惁宸插鏍�,鍏抽棴,浣滃簾
+                if (oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo))
+                {
+                    if (oBill.omodel.HChecker.Trim() != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘鍐嶆瀹℃牳";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //瀹℃牳
+                if (Cj_StationEntrustOutBillCheckBill(HInterID, CurUserName, ref DBUtility.ClsPub.sExeReturnInfo))
+                {
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "瀹℃牳鎴愬姛!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "瀹℃牳澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        //瀹℃牳
+        public bool Cj_StationEntrustOutBillCheckBill(Int64 lngBillKey, string CurUserName, ref string sReturn)
+        {
+            try
+            {
+                string HChecker = CurUserName;
+                string HCheckDate = DBUtility.ClsPub.GetServerDate(-1);
+                oCN.BeginTran();
+                ds = oCN.RunProcReturn("Select * from Sc_StationOutBillMain Where HInterID=" + lngBillKey.ToString(), "Sc_StationOutBillMain");
+                if (ds.Tables[0].Rows.Count == 0)
+                {
+                    sReturn = "鍗曟嵁鏈壘鍒帮紒";
+                    return false;
+                }
+                oCN.RunProc(" Update Sc_StationOutBillMain set HChecker='" + HChecker + "',HCheckDate='" + HCheckDate + "' Where HInterID=" + lngBillKey.ToString());
+                oCN.RunProc("exec h_p_Mes_ProcessExchangeRelationQty_Check_Out " + lngBillKey.ToString() + ",1");
+                //鍒ゆ柇鏄惁鏄� 鏈亾宸ュ簭 
+                DataSet ds1;
+                ds1 = oCN.RunProcReturn(" select HLastProc,HFstProc from Sc_ProcessExchangeBillMain a  " +
+                    " inner join Sc_ProcessExchangeBillSub b on a.HInterID=b.HInterID  " +
+                    " Where a.HInterID=(Select HProcExchInterID from Sc_StationOutBillMain Where HInterID=" + lngBillKey + ") " +
+                    " and b.HEntryID=(Select HProcExchEntryID from Sc_StationOutBillMain Where HInterID=" + lngBillKey + ")", "Sc_ProcessExchangeBillMain");
+                if (ds1 == null || ds1.Tables[0].Rows.Count == 0)
+                {
+                }
+                else if (Pub_Class.ClsPub.isStrNull(ds1.Tables[0].Rows[0]["HFstProc"]) == "鏄�")
+                {
+                }
+                sReturn = sReturn + " 瀹℃牳鍔熻兘锛�";
+                oCN.Commit();
+                return true;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                oCN.RollBack();
+                return false; ;
+            }
+        }
+        #endregion
+
+        #region 鍙嶅鏍�
+        [Route("Cj_StationEntrustOutBill/set_AbandonCheck")]
+        [HttpGet]
+        public object set_AbandonCheck(int HInterID, string CurUserName)
+        {
+            try
+            {
+                string ModRightNameCheck = "MES_StationEntrustOutBill_Check";
+                //瀹℃牳鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, false, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍙嶅鏍稿け璐ワ紒鏃犳潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (HInterID == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁ID涓�0锛屼笉鑳藉弽瀹℃牳锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                DAL.ClsSc_StationEntrustOutBill oBill = new DAL.ClsSc_StationEntrustOutBill();
+                //鏌ョ湅鏄惁宸插鏍�,鍏抽棴,浣滃簾
+                if (oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo))
+                {
+                    if (oBill.omodel.HChecker.Trim() == "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶉渶瑕佸弽瀹℃牳!";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //鍙嶅鏍�
+                if (Cj_StationEntrustOutBillAbandonCheckBill(HInterID, CurUserName, ref DBUtility.ClsPub.sExeReturnInfo))
+                {
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍙嶅鏍告垚鍔�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鍙嶅鏍稿け璐ワ紒" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        //鍙嶅鏍�
+        public bool Cj_StationEntrustOutBillAbandonCheckBill(Int64 lngBillKey, string CurUserName, ref string sReturn)
+        {
+            if (Cj_StationEntrustOutBillisUse(lngBillKey, ref sReturn))
+            {
+                return false;
+            }
+            try
+            {
+                string HChecker = CurUserName;
+                string HCheckDate = DBUtility.ClsPub.GetServerDate(-1);
+                oCN.BeginTran();
+                ds = oCN.RunProcReturn("Select * from Sc_StationOutBillMain Where HInterID=" + lngBillKey.ToString(), "Sc_StationOutBillMain");
+                if (ds.Tables[0].Rows.Count == 0)
+                {
+                    sReturn = "鍗曟嵁鏈壘鍒帮紒";
+                    return false;
+                }
+
+                oCN.RunProc(" Update Sc_StationOutBillMain set HChecker='',HCheckDate=null Where HInterID=" + lngBillKey.ToString());
+                oCN.RunProc("exec h_p_Mes_ProcessExchangeRelationQty_Check_Out " + lngBillKey.ToString() + ",-1");
+                //鍒ゆ柇鏄惁鏄� 棣栭亾宸ュ簭
+                DataSet ds1;
+                ds1 = oCN.RunProcReturn("select HLastProc,HFstProc " +
+                    " from Sc_ProcessExchangeBillMain a " +
+                    " inner join Sc_ProcessExchangeBillSub b on a.HInterID=b.HInterID " +
+                    " Where a.HInterID=(Select HProcExchInterID from Sc_StationOutBillMain Where HInterID=" + lngBillKey + ") " +
+                    " and b.HEntryID=(Select HProcExchEntryID from Sc_StationOutBillMain Where HInterID=" + lngBillKey + ")", "Sc_ProcessExchangeBillMain");
+                if (ds1 == null || ds1.Tables[0].Rows.Count == 0)
+                {
+                }
+                else if (Pub_Class.ClsPub.isStrNull(ds1.Tables[0].Rows[0]["HFstProc"]) == "鏄�")
+                {
+                }
+                sReturn = sReturn + "鍙嶅鏍稿姛鑳斤紒";
+                oCN.Commit();
+                return true;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                oCN.RollBack();
+                return false; ;
+            }
+        }
+
+        //鏄惁琚叧鑱�
+        public bool Cj_StationEntrustOutBillisUse(Int64 lngBillKey, ref string sReturn)
+        {
+            try
+            {
+                //鏌ヨ涓昏〃
+                DataSet Ds;
+                Ds = oCN.RunProcReturn("Select HinterID from Sc_StationOutBillSub  Where HInterID=" + lngBillKey.ToString() + " and isnull(HRelationQty,0)<>0 ", "Sc_StationOutBillSub");
+                if (Ds.Tables[0].Rows.Count != 0)
+                {
+                    sReturn = "鍗曟嵁宸茶鍏宠仈,涓嶈兘鎿嶄綔锛�";
+                    return true;
+                }
+                sReturn = "";
+                return false;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                throw (e);
+            }
+        }
+        #endregion
+
+        //鎵归噺
+        #region 鎵归噺濮斿鎺ユ敹妯″潡杩斿洖鏄庣粏淇℃伅鍒楄〃
+        [Route("Cj_StationEntrustOutBill/get_BarCodeDetail")]
+        [HttpGet]
+        public object get_BarCodeDetail(string HMainInterID)
+        {
+            try
+            {
+                ds = oCN.RunProcReturn(
+                    "select a.HBillNo,a.HInterID,a.HQty,a.HProcExchBillNo,a.HICMOBillNo" +
+                    ",b.HNumber HMaterNumber,b.HName HMaterName,b.HModel HMaterModel,c.HName HSourceName,d.HName HGroupName" +
+                    ",e.HName HEmpName,a.HMaker,a.HMakeDate " +
+                    " from Sc_StationOutBillMain a " +
+                    " left join Gy_Material b on a.HMaterID = b.HItemID " +
+                    " left join Gy_Source c on a.HSourceID = c.HItemID " +
+                    " left join Gy_Group d on a.HGroupID = d.HItemID " +
+                    " left join Gy_Employee e on a.HEmpID = e.HItemID " +
+                    " where HMainInterID = " + HMainInterID + " order by a.HMakeDate desc", "Sc_StationOutBillMain");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犺繑鍥炶褰曪紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "杩斿洖璁板綍鎴愬姛锛�";
+                    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
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1