From 25849768b45e51a2f5ac0bd4df7bb98b24da9cd7 Mon Sep 17 00:00:00 2001
From: 杨乐 <yang.le.192@qq.com>
Date: 星期一, 07 二月 2022 17:18:22 +0800
Subject: [PATCH] 工序管理

---
 DAL/MES/ClsSc_MESMaterToSourceBill .cs |  108 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 103 insertions(+), 5 deletions(-)

diff --git a/DAL/MES/ClsSc_MESMaterToSourceBill .cs b/DAL/MES/ClsSc_MESMaterToSourceBill .cs
index 217041e..d13ee07 100644
--- a/DAL/MES/ClsSc_MESMaterToSourceBill .cs
+++ b/DAL/MES/ClsSc_MESMaterToSourceBill .cs
@@ -53,7 +53,12 @@
                 ",HProcExchEntryID=" + omodel.HProcExchEntryID.ToString() +
                 ",HProcExchBillNo='" + omodel.HProcExchBillNo + "'" +
                 ",HICMOInterID=" + omodel.HICMOInterID.ToString() +
+                ",HICMOEntryID=" + omodel.HICMOEntryID.ToString() +
                 ",HICMOBillNo='" + omodel.HICMOBillNo + "'" +
+                ",HMainSourceBillType=" + omodel.HMainSourceBillType.ToString() +
+                ",HMainSourceInterID=" + omodel.HMainSourceInterID.ToString() +
+                ",HMainSourceEntryID=" + omodel.HMainSourceEntryID.ToString() +
+                ",HMainSourceBillNo='" + omodel.HMainSourceBillNo.ToString() +"'"+
                 ",HSourceID=" + omodel.HSourceID.ToString() +
                 ",HProcID=" + omodel.HProcID.ToString() +
                 ",HMaterID=" + omodel.HMaterID.ToString() +
@@ -83,7 +88,7 @@
                       ",'" + oSub.HBarCode + "','" + oSub.HBarCode_Pack + "','" + oSub.HBillNo_bak + "'" +
                       ") ");
                 }
-                sReturn = "淇敼鍗曟嵁鎴愬姛锛�";
+                sReturn = omodel.HInterID.ToString();
                 oCn.Commit();
                 return true;
             }
@@ -107,13 +112,15 @@
                 oCn.RunProc("Insert Into Sc_MaterToSourceBillMain   " +
                 "(HBillType,HBillSubType,HInterID,HBillNo,HDate" +
                 ",HYear,HPeriod,HRemark,HMaker,HMakeDate" +
-                ",HProcExchInterID,HProcExchEntryID,HProcExchBillNo,HICMOInterID,HICMOBillNo" +
+                ",HProcExchInterID,HProcExchEntryID,HProcExchBillNo,HICMOInterID,HICMOEntryID,HICMOBillNo" +
+                ",HMainSourceBillType,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo" +
                 ",HSourceID,HProcID,HMaterID,HSourceBarCode,HEquipID,HWorkerID,HWorkerBarCode" +
                 ",HGroupID" +
                 ") " +
                 " values('" + this.BillType + "','" + this.HBillSubType + "'," + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "','" + omodel.HDate + "'" +
                 ", " + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HRemark + "','" + DBUtility.ClsPub.CurUserName + "',getdate()" +
-                "," + omodel.HProcExchInterID.ToString() + "," + omodel.HProcExchEntryID.ToString() + ",'" + omodel.HProcExchBillNo + "'," + omodel.HICMOInterID.ToString() + ",'" + omodel.HICMOBillNo + "'" +
+                "," + omodel.HProcExchInterID.ToString() + "," + omodel.HProcExchEntryID.ToString() + ",'" + omodel.HProcExchBillNo + "'," + omodel.HICMOInterID.ToString() + ","+ omodel.HICMOEntryID.ToString() + ",'" + omodel.HICMOBillNo + "'" +
+                "," + omodel.HMainSourceBillType.ToString() + "," + omodel.HMainSourceInterID.ToString() + "," + omodel.HMainSourceEntryID.ToString() + ",'" + omodel.HMainSourceBillNo + "'" +
                 "," + omodel.HSourceID.ToString() + "," + omodel.HProcID.ToString() + "," + omodel.HMaterID.ToString() + ",'" + omodel.HSourceBarCode + "'," + omodel.HEquipID.ToString() + "," + omodel.HWorkerID.ToString() + ",'" + omodel.HWorkerBarCode + "'" +
                 "," + omodel.HGroupID.ToString() +
                 ") ");
@@ -258,6 +265,45 @@
             }
         }
 
+        //鍒犻櫎鍗曟嵁
+        public override bool DeleteBill(Int64 lngBillKey, ref string sReturn)
+        {
+            try
+            {
+                oCn.BeginTran();
+                //鍒ゆ柇鏄惁鍏佽鍒犻櫎
+                DataSet ds = oCn.RunProcReturn("exec h_p_Sc_MaterToSourceBill_DelCtrl @HInterId=" + lngBillKey + "", "h_p_Sc_MaterToSourceBill_DelCtrl");
+                if (ds == null || ds.Tables[0].Rows.Count <= 0)
+                {
+                    sReturn = "鏃犻獙璇佹暟鎹紒";
+                    return false;
+                }
+                if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) == "2")
+                {
+                    sReturn = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                    return false;
+                }
+
+                //鍒犻櫎鍏宠仈鍏崇郴
+                oCn.RunProc("exec h_p_Sc_MaterToSourceBill_DelRelation @HInterId=" + lngBillKey + "");
+
+                //鍒犻櫎鏄庣粏琛�
+                oCn.RunProc("Delete From " + MvarItemKeySub + "  where HInterID=" + lngBillKey.ToString());
+                //鍒犻櫎涓昏〃
+                oCn.RunProc("Delete From " + MvarItemKey + "  where HInterID=" + lngBillKey.ToString());
+
+                sReturn = "鍒犻櫎鍗曟嵁鎴愬姛锛�";
+                oCn.Commit();
+                return true;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                oCn.RollBack();
+                throw (e);
+            }
+        }
+
         //瀹℃牳
         public bool CheckBill(Int64 lngBillKey, ref string sReturn)
         {
@@ -266,13 +312,28 @@
             {
                 string HChecker = DBUtility.ClsPub.CurUserName;
                 string HCheckDate = DBUtility.ClsPub.GetServerDate(-1);
-                oCn.RunProc(" Update " + MvarItemKey + " set HChecker='" + HChecker + "',HCheckDate='" + HCheckDate + "' Where HInterID=" + lngBillKey.ToString());
+                oCn.BeginTran();
+                oCn.RunProc(" Update " + MvarItemKey + " set HBillStatus='2', HChecker='" + HChecker + "',HCheckDate='" + HCheckDate + "' Where HInterID=" + lngBillKey.ToString());
                 //鐢熸垚璋冩嫧鍗�
                 //寰楀埌璋冩嫧鍗� mainid 鍗曟嵁鍙�
                 //long NewInterID = DBUtility.ClsPub.CreateBillID("1207", ref DBUtility.ClsPub.sExeReturnInfo);
                 //string NewBillNo = DBUtility.ClsPub.CreateBillCode("1207", ref DBUtility.ClsPub.sExeReturnInfo, true);//寰楀埌鏂板崟鍙�
                 //oCn.RunProc("exec h_p_Kf_MoveStockBill_Add " + lngBillKey.ToString() + "," + NewInterID.ToString() + ",'" + NewBillNo + "','" + HChecker + "'");
                 //
+                //鍐嶆楠岃瘉 淇濆瓨鏄惁 鍚堢悊
+                DataSet ds = oCn.RunProcReturn("exec h_p_Sc_MaterToSourceBill_AddRelation @HInterId=" + omodel.HInterID + "", "h_p_Sc_MaterToSourceBill_AddRelation");
+                if (ds == null || ds.Tables[0].Rows.Count <= 0)
+                {
+                    sReturn = "鏃犻獙璇佹暟鎹紒";
+                    oCn.RollBack();
+                }
+                if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) == "2")
+                {
+                    sReturn = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                    oCn.RollBack();
+                }
+
+                oCn.Commit();
                 sReturn = "";
                 return true;
             }
@@ -283,9 +344,46 @@
             }
         }
 
+        //鍙嶅鏍�
+        public bool AbandonCheck(Int64 lngBillKey, ref string sReturn)
+        {
 
+            try
+            {
+                string HChecker = DBUtility.ClsPub.CurUserName;
+                string HCheckDate = DBUtility.ClsPub.GetServerDate(-1);
+                oCn.BeginTran();
+                oCn.RunProc(" Update " + MvarItemKey + " set HBillStatus='1', HChecker='',HCheckDate=null Where HInterID=" + lngBillKey.ToString());
+                //鐢熸垚璋冩嫧鍗�
+                //寰楀埌璋冩嫧鍗� mainid 鍗曟嵁鍙�
+                //long NewInterID = DBUtility.ClsPub.CreateBillID("1207", ref DBUtility.ClsPub.sExeReturnInfo);
+                //string NewBillNo = DBUtility.ClsPub.CreateBillCode("1207", ref DBUtility.ClsPub.sExeReturnInfo, true);//寰楀埌鏂板崟鍙�
+                //oCn.RunProc("exec h_p_Kf_MoveStockBill_Add " + lngBillKey.ToString() + "," + NewInterID.ToString() + ",'" + NewBillNo + "','" + HChecker + "'");
+                //
+                //鍐嶆楠岃瘉 淇濆瓨鏄惁 鍚堢悊
+                DataSet ds = oCn.RunProcReturn("exec h_p_Sc_MaterToSourceBill_DelRelation @HInterId=" + omodel.HInterID + "", "h_p_Sc_MaterToSourceBill_DelRelation");
+                if (ds == null || ds.Tables[0].Rows.Count <= 0)
+                {
+                    sReturn = "鏃犻獙璇佹暟鎹紒";
+                    oCn.RollBack();
 
+                }
+                if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) == "2")
+                {
+                    sReturn = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                    oCn.RollBack();
 
-        
+                }
+
+                oCn.Commit();
+                sReturn = "";
+                return true;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                throw (e);
+            }
+        }
     }
 }

--
Gitblit v1.9.1