From c60226bc35f0fb82d95c17ab56120441c42a2b4a Mon Sep 17 00:00:00 2001
From: duhe <226547893@qq.com>
Date: 星期二, 21 五月 2024 14:38:44 +0800
Subject: [PATCH] 条码主档维护:作废、反作废

---
 DBUtility/业务单据/ClsXt_BaseBill.cs |  274 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 257 insertions(+), 17 deletions(-)

diff --git "a/DBUtility/\344\270\232\345\212\241\345\215\225\346\215\256/ClsXt_BaseBill.cs" "b/DBUtility/\344\270\232\345\212\241\345\215\225\346\215\256/ClsXt_BaseBill.cs"
index 50fc373..39bffd9 100644
--- "a/DBUtility/\344\270\232\345\212\241\345\215\225\346\215\256/ClsXt_BaseBill.cs"
+++ "b/DBUtility/\344\270\232\345\212\241\345\215\225\346\215\256/ClsXt_BaseBill.cs"
@@ -2,6 +2,7 @@
 using System.Collections.Generic;
 using System.Text;
 using System.Data;
+using System.Windows.Forms;
 
 namespace DBUtility
 {
@@ -23,6 +24,8 @@
         public SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
         public SQLHelper.ClsCNK3 oK3Cn = new SQLHelper.ClsCNK3();
         public SQLHelper.ClsCNK3 oCnK3 = new SQLHelper.ClsCNK3();
+        string ComputerName = SystemInformation.ComputerName;   //璁惧鍚嶇О
+        string IPAddress="";    //璁惧IP
 
         public ClsXt_BaseBill()
         {
@@ -71,6 +74,44 @@
                 throw (e);
             }
         }
+        //鍙嶄綔搴熷崟鎹�(鍖呭惈鍐欏叆鏃ュ織)    2024-01-31
+        public bool AbandonCancelltion(Int64 lngBillKey, string HBillNo, string sUser, ref string sReturn)
+        {
+            try
+            {
+                oCn.BeginTran();
+                DataSet ds = oCn.RunProcReturn("select * from " + MvarItemKey + " where HInterID=" + lngBillKey.ToString(), MvarItemKey);
+                if (ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "")
+                {
+                    oCn.RunProc(" Update " + MvarItemKey + " set HDeleteMan='',HDeleteDate=null,HBillStatus=3 Where HInterID=" + lngBillKey.ToString());
+                }
+                else if (ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
+                {
+                    oCn.RunProc(" Update " + MvarItemKey + " set HDeleteMan='',HDeleteDate=null,HBillStatus=2 Where HInterID=" + lngBillKey.ToString());
+                }
+                else
+                {
+                    oCn.RunProc(" Update " + MvarItemKey + " set HDeleteMan='',HDeleteDate=null,HBillStatus=1 Where HInterID=" + lngBillKey.ToString());
+                }
+
+                //鍐欏叆鏃ュ織
+                string WorkList = "鍙嶄綔搴熷崟鎹紝鍗曟嵁鍙凤細" + HBillNo;
+                string SystemName = "LMES-" + MvarReportTitle + "妯″潡";
+                oCn.RunProc("Insert into  System_Log(GeginDate,userid,WorkstationName,WorkList,SystemName,NetUserName,State) values " +
+                    "(getdate(),'" + sUser + "','" + ComputerName + "','" + WorkList + "','" + SystemName + "','" + IPAddress + "','鍙嶄綔搴�')"
+                    );
+
+                sReturn = "鍙嶄綔搴熷崟鎹垚鍔燂紒";
+                oCn.Commit();
+                return true;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                oCn.RollBack();
+                throw (e);
+            }
+        }
         //鍙嶅叧闂�
         public bool CancelClose(Int64 lngBillKey, ref string sReturn)
         {
@@ -79,15 +120,15 @@
                 DataSet ds = oCn.RunProcReturn("select * from " + MvarItemKey + " where HInterID=" + lngBillKey.ToString(), MvarItemKey);
                 if (ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "")
                 {
-                    oCn.RunProc(" Update " + MvarItemKey + " set HCloseMan='',HCloseDate=null,HBillStatus=4 Where HInterID=" + lngBillKey.ToString());
+                    oCn.RunProc(" Update " + MvarItemKey + " set HCloseMan='',HCloseDate=null,HBillStatus=4,HCloseType = 0 Where HInterID=" + lngBillKey.ToString());
                 }
                 else if (ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
                 {
-                    oCn.RunProc(" Update " + MvarItemKey + " set HCloseMan='',HCloseDate=null,HBillStatus=2 Where HInterID=" + lngBillKey.ToString());
+                    oCn.RunProc(" Update " + MvarItemKey + " set HCloseMan='',HCloseDate=null,HBillStatus=2,HCloseType = 0 Where HInterID=" + lngBillKey.ToString());
                 }
                 else
                 {
-                    oCn.RunProc(" Update " + MvarItemKey + " set HCloseMan='',HCloseDate=null,HBillStatus=1 Where HInterID=" + lngBillKey.ToString());
+                    oCn.RunProc(" Update " + MvarItemKey + " set HCloseMan='',HCloseDate=null,HBillStatus=1,HCloseType = 0 Where HInterID=" + lngBillKey.ToString());
                 }
 
                 sReturn = "";
@@ -96,6 +137,81 @@
             catch (Exception e)
             {
                 sReturn = e.Message;
+                throw (e);
+            }
+        }
+        //鍙嶅叧闂崟鎹�(鍖呭惈鍐欏叆鏃ュ織)    2024-01-31
+        public bool CancelClose(Int64 lngBillKey, string HBillNo, string sUser, ref string sReturn)
+        {
+            try
+            {
+                oCn.BeginTran();
+                DataSet ds = oCn.RunProcReturn("select * from " + MvarItemKey + " where HInterID=" + lngBillKey.ToString(), MvarItemKey);
+                if (ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "")
+                {
+                    oCn.RunProc(" Update " + MvarItemKey + " set HCloseMan='',HCloseDate=null,HBillStatus=4,HCloseType = 0 Where HInterID=" + lngBillKey.ToString());
+                }
+                else if (ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
+                {
+                    oCn.RunProc(" Update " + MvarItemKey + " set HCloseMan='',HCloseDate=null,HBillStatus=2,HCloseType = 0 Where HInterID=" + lngBillKey.ToString());
+                }
+                else
+                {
+                    oCn.RunProc(" Update " + MvarItemKey + " set HCloseMan='',HCloseDate=null,HBillStatus=1,HCloseType = 0 Where HInterID=" + lngBillKey.ToString());
+                }
+
+                //鍐欏叆鏃ュ織
+                string WorkList = "鍙嶅叧闂崟鎹紝鍗曟嵁鍙凤細" + HBillNo;
+                string SystemName = "LMES-" + MvarReportTitle + "妯″潡";
+                oCn.RunProc("Insert into  System_Log(GeginDate,userid,WorkstationName,WorkList,SystemName,NetUserName,State) values " +
+                    "(getdate(),'" + sUser + "','" + ComputerName + "','" + WorkList + "','" + SystemName + "','" + IPAddress + "','鍙嶅叧闂�')"
+                    );
+
+                sReturn = "鍙嶅叧闂崟鎹垚鍔燂紒";
+                oCn.Commit();
+                return true;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                oCn.RollBack();
+                throw (e);
+            }
+        }
+        //琛屽弽鍏抽棴鍗曟嵁(鍖呭惈鍐欏叆鏃ュ織)    2024-01-31
+        public bool CancelRow(Int64 lngBillKey,Int64 HEntryID, string HBillNo, string sUser, ref string sReturn)
+        {
+            try
+            {
+                //oCn.BeginTran();
+                string sql = "select * from " + MvarItemKeySub + " where HInterID=" + lngBillKey.ToString() + " and HEntryID = " + HEntryID;
+                DataSet ds = oCn.RunProcReturn(sql, MvarItemKeySub);
+                if(ds==null || ds.Tables[0].Rows.Count == 0)
+                {
+                    sReturn = "琛岃褰曚笉瀛樺湪锛�";
+                    return false;
+                }
+                else
+                {
+                    sql = " Update " + MvarItemKeySub + " set HCloseMan='',HEntryCloseDate='',HCloseType=0 Where HInterID=" + lngBillKey.ToString() + " and HEntryID = " + HEntryID;
+                    oCn.RunProc(sql);
+                }
+
+                //鍐欏叆鏃ュ織
+                string WorkList = "琛屽弽鍏抽棴锛屽崟鎹彿锛�" + HBillNo + "锛涘瓙琛ㄥ唴鐮侊細" + HEntryID;
+                string SystemName = "LMES-" + MvarReportTitle + "妯″潡";
+                oCn.RunProc("Insert into  System_Log(GeginDate,userid,WorkstationName,WorkList,SystemName,NetUserName,State) values " +
+                    "(getdate(),'" + sUser + "','" + ComputerName + "','" + WorkList + "','" + SystemName + "','" + IPAddress + "','琛屽弽鍏抽棴')"
+                    );
+
+                sReturn = "琛屽弽鍏抽棴鎴愬姛锛�";
+                //oCn.Commit();
+                return true;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                oCn.RollBack();
                 throw (e);
             }
         }
@@ -132,7 +248,7 @@
                 throw (e);
             }
         }
-        //鍙嶅鏍�(鍖呭惈鍙嶅鏍稿悗鎺у埗)
+        //鍙嶅鏍�(鍖呭惈鍙嶅鏍稿悗鎺у埗銆佸啓鍏ユ棩蹇�)    2024-01-31
         public bool AbandonCheck(Int64 lngBillKey, string HBillNo, string procName, string sUser, ref string sReturn)
         {
             string sql = "";
@@ -176,8 +292,14 @@
                     oCn.RollBack();
                     return false;
                 }
+                //鍐欏叆鏃ュ織
+                string WorkList = "鍙嶅鏍稿崟鎹紝鍗曟嵁鍙凤細" + HBillNo;
+                string SystemName = "LMES-" + MvarReportTitle + "妯″潡";
+                oCn.RunProc("Insert into  System_Log(GeginDate,userid,WorkstationName,WorkList,SystemName,NetUserName,State) values " +
+                    "(getdate(),'" + sUser + "','" + ComputerName + "','" + WorkList + "','" + SystemName + "','" + IPAddress + "','鍙嶅鏍�')"
+                    );
 
-                sReturn = "";
+                sReturn = "鍙嶅鏍稿崟鎹垚鍔燂紒";
                 oCn.Commit();
                 return true;
             }
@@ -225,7 +347,7 @@
                 throw (e);
             }
         }
-        //瀹℃牳(鍖呭惈瀹℃牳鍚庢帶鍒�)
+        //瀹℃牳(鍖呭惈瀹℃牳鍚庢帶鍒躲�佸啓鍏ユ棩蹇�)    2024-01-31
         public bool CheckBill(Int64 lngBillKey, string HBillNo,string procName , string sUser, ref string sReturn)
         {
             string sql = "";
@@ -256,8 +378,14 @@
                     oCn.RollBack();
                     return false;
                 }
+                //鍐欏叆鏃ュ織
+                string WorkList = "瀹℃牳鍗曟嵁锛屽崟鎹彿锛�" + HBillNo;
+                string SystemName = "LMES-" + MvarReportTitle + "妯″潡";
+                oCn.RunProc("Insert into  System_Log(GeginDate,userid,WorkstationName,WorkList,SystemName,NetUserName,State) values " +
+                    "(getdate(),'" + sUser + "','" + ComputerName + "','" + WorkList + "','"+SystemName+"','" + IPAddress + "','瀹℃牳')"
+                    );
 
-                sReturn = "";
+                sReturn = "瀹℃牳鍗曟嵁鎴愬姛锛�";
                 oCn.Commit();
                 return true;
             }
@@ -276,7 +404,7 @@
             {
                 string HCloseMan = ClsPub.CurUserName;
                 string HCloseDate = ClsPub.GetServerDate(-1); 
-                oCn.RunProc(" Update " + MvarItemKey + " set HCloseMan='" + HCloseMan + "',HCloseDate='" + HCloseDate + "',HBillStatus=3 Where HInterID=" + lngBillKey.ToString());
+                oCn.RunProc(" Update " + MvarItemKey + " set HCloseMan='" + HCloseMan + "',HCloseDate='" + HCloseDate + "',HBillStatus=3,HCloseType = 1 Where HInterID=" + lngBillKey.ToString());
                 sReturn = "";
                 return true;
             }
@@ -286,21 +414,71 @@
                 throw (e);
             }
         }
-        //鍏抽棴
-        public bool CloseBill(Int64 lngBillKey, string sUser, ref string sReturn)
+        //鍏抽棴鍗曟嵁(鍖呭惈鍐欏叆鏃ュ織)    2024-01-31
+        public bool CloseBill(Int64 lngBillKey, string HBillNo, string sUser, ref string sReturn)
         {
-
             try
             {
+                oCn.BeginTran();
                 string HCloseMan = sUser;
                 string HCloseDate = ClsPub.GetServerDate(-1);
-                oCn.RunProc(" Update " + MvarItemKey + " set HCloseMan='" + HCloseMan + "',HCloseDate='" + HCloseDate + "' Where HInterID=" + lngBillKey.ToString());
-                sReturn = "";
+                oCn.RunProc(" Update " + MvarItemKey + " set HCloseMan='" + HCloseMan + "',HCloseDate='" + HCloseDate + "',HBillStatus=3,HCloseType = 1 Where HInterID=" + lngBillKey.ToString());
+                
+                //鍐欏叆鏃ュ織
+                string WorkList = "鍏抽棴鍗曟嵁锛屽崟鎹彿锛�" + HBillNo;
+                string SystemName = "LMES-" + MvarReportTitle + "妯″潡";
+                oCn.RunProc("Insert into  System_Log(GeginDate,userid,WorkstationName,WorkList,SystemName,NetUserName,State) values " +
+                    "(getdate(),'" + sUser + "','" + ComputerName + "','" + WorkList + "','" + SystemName + "','" + IPAddress + "','鍏抽棴')"
+                    );
+
+                sReturn = "鍏抽棴鍗曟嵁鎴愬姛锛�";
+                oCn.Commit();
                 return true;
             }
             catch (Exception e)
             {
                 sReturn = e.Message;
+                oCn.RollBack();
+                throw (e);
+            }
+        }
+        //琛屽叧闂崟鎹�(鍖呭惈鍐欏叆鏃ュ織)    2024-01-31
+        public bool CloseRow(Int64 lngBillKey,Int64 HEntryID, string HBillNo, string sUser, ref string sReturn)
+        {
+            DataSet ds;
+            try
+            {
+                oCn.BeginTran();
+                string HCloseMan = sUser;
+                string HEntryCloseDate = ClsPub.GetServerDate(-1);
+                //鍙樻洿琛屽叧闂姸鎬�
+                string sql = " Update " + MvarItemKeySub + " set HCloseMan='" + HCloseMan + "',HEntryCloseDate='" + HEntryCloseDate + "',HCloseType=1 Where HInterID=" + lngBillKey.ToString() + " and HEntryID = " + HEntryID;
+                oCn.RunProc(sql);
+
+                //妫�鏌ュ崟鎹瓙琛ㄦ墍鏈夎鏄惁閮藉叧闂紝鑻ラ兘鍏抽棴鍒欒嚜鍔ㄥ叧闂崟鎹�
+                //sql = "select * from " + MvarItemKeySub + " where HInterID=" + lngBillKey + " and HCloseMan=''";
+                //ds = oCn.RunProcReturn(sql, MvarItemKeySub);
+                //if(ds!=null && ds.Tables[0].Rows.Count == 0)
+                //{
+                //    sql = " Update " + MvarItemKey + " set HCloseMan='" + HCloseMan + "',HCloseDate=getdate(),HBillStatus=3,HCloseType = 0 Where HInterID=" + lngBillKey.ToString();
+                //    oCn.RunProc(sql);
+                //}
+
+                //鍐欏叆鏃ュ織
+                string WorkList = "琛屽叧闂紝鍗曟嵁鍙凤細" + HBillNo + "锛涘瓙琛ㄥ唴鐮侊細" + HEntryID;
+                string SystemName = "LMES-" + MvarReportTitle + "妯″潡";
+                oCn.RunProc("Insert into  System_Log(GeginDate,userid,WorkstationName,WorkList,SystemName,NetUserName,State) values " +
+                    "(getdate(),'" + sUser + "','" + ComputerName + "','" + WorkList + "','" + SystemName + "','" + IPAddress + "','琛屽叧闂�')"
+                    );
+
+                sReturn = "琛屽叧闂垚鍔燂紒";
+                oCn.Commit();
+                return true;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                oCn.RollBack();
                 throw (e);
             }
         }
@@ -322,20 +500,31 @@
             }
         }
 
-        //浣滃簾
-        public bool Cancelltion(Int64 lngBillKey,string sUser, ref string sReturn)
+        //浣滃簾鍗曟嵁(鍖呭惈鍐欏叆鏃ュ織)    2024-01-31
+        public bool Cancelltion(Int64 lngBillKey, string HBillNo, string sUser, ref string sReturn)
         {
             try
             {
+                oCn.BeginTran();
                 string HDeleteMan = sUser;
                 string HDeleteDate = ClsPub.GetServerDate(-1);
-                oCn.RunProc(" Update " + MvarItemKey + " set HDeleteMan='" + HDeleteMan + "',HDeleteDate='" + HDeleteDate + "' Where HInterID=" + lngBillKey.ToString());
-                sReturn = "";
+                oCn.RunProc(" Update " + MvarItemKey + " set HDeleteMan='" + HDeleteMan + "',HDeleteDate='" + HDeleteDate + "',HBillStatus=4 Where HInterID=" + lngBillKey.ToString());
+                
+                //鍐欏叆鏃ュ織
+                string WorkList = "浣滃簾鍗曟嵁锛屽崟鎹彿锛�" + HBillNo;
+                string SystemName = "LMES-" + MvarReportTitle + "妯″潡";
+                oCn.RunProc("Insert into  System_Log(GeginDate,userid,WorkstationName,WorkList,SystemName,NetUserName,State) values " +
+                    "(getdate(),'" + sUser + "','" + ComputerName + "','" + WorkList + "','" + SystemName + "','" + IPAddress + "','浣滃簾')"
+                    );
+
+                sReturn = "浣滃簾鍗曟嵁鎴愬姛锛�";
+                oCn.Commit();
                 return true;
             }
             catch (Exception e)
             {
                 sReturn = e.Message;
+                oCn.RollBack();
                 throw (e);
             }
         }
@@ -399,6 +588,57 @@
                 throw (e);
             }
         }
+        //鍒犻櫎鍗曟嵁(鍖呭惈鍒犻櫎鍚庢帶鍒躲�佸啓鍏ユ棩蹇�)    2024-01-31
+        public bool DeleteBill(Int64 lngBillKey, string HBillNo, string procName, string sUser, ref string sReturn)
+        {
+            string sql = "";
+            DataSet ds;
+            try
+            {
+                oCn.BeginTran();
+                //鍒犻櫎鍏宠仈
+                DeleteRelation(ref sReturn, lngBillKey);
+                //鍒犻櫎鏄庣粏琛�
+                DeleteBillSub(lngBillKey);
+                DeleteBillSub2(lngBillKey);
+                DeleteBillSub3(lngBillKey);
+                DeleteBillSub4(lngBillKey);
+                //鍒犻櫎涓昏〃
+                DeleteBillMain(lngBillKey);
+
+                //鍒犻櫎鍚庢帶鍒�
+                sql = "exec " + procName + " " + lngBillKey + ",'" + HBillNo + "','" + sUser + "'";
+                ds = oCn.RunProcReturn(sql, procName);
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    sReturn = "鍒犻櫎杩囩▼涓嚭閿欙紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                    oCn.RollBack();
+                    return false;
+                }
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    sReturn = ds.Tables[0].Rows[0]["HRemark"].ToString();
+                    oCn.RollBack();
+                    return false;
+                }
+                //鍐欏叆鏃ュ織
+                string WorkList = "鍒犻櫎鍗曟嵁锛屽崟鎹彿锛�" + HBillNo;
+                string SystemName = "LMES-" + MvarReportTitle + "妯″潡";
+                oCn.RunProc("Insert into  System_Log(GeginDate,userid,WorkstationName,WorkList,SystemName,NetUserName,State) values " +
+                    "(getdate(),'" + sUser + "','" + ComputerName + "','" + WorkList + "','" + SystemName + "','" + IPAddress + "','鍒犻櫎')"
+                    );
+
+                sReturn = "鍒犻櫎鍗曟嵁鎴愬姛锛�";
+                oCn.Commit();
+                return true;
+            }
+            catch (Exception e)
+            {
+                sReturn = e.Message;
+                oCn.RollBack();
+                throw (e);
+            }
+        }
         //鏄惁琚叧鑱�
         public bool isUse(Int64 lngBillKey, ref string sReturn)
         {

--
Gitblit v1.9.1