zrg
2025-03-12 967c01b8974e90b452f3737b21e142e13ee21cf3
增加作废、反作废通用方法
1个文件已修改
112 ■■■■■ 已修改文件
DBUtility/业务单据/ClsXt_BaseBill.cs 112 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DBUtility/ÒµÎñµ¥¾Ý/ClsXt_BaseBill.cs
@@ -112,6 +112,67 @@
                throw (e);
            }
        }
        //反作废(包含作废后控制、写入日志)    2025-03-10
        public bool AbandonCancelltion(Int64 lngBillKey, string HBillNo, string procName, string sUser, ref string sReturn)
        {
            string sql = "";
            if (isUse(lngBillKey, ref sReturn))
            {
                return false;
            }
            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());
                }
                //作废后控制
                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)
            {
                oCn.RollBack();
                sReturn = e.Message;
                throw (e);
            }
        }
        //反关闭
        public bool CancelClose(Int64 lngBillKey, ref string sReturn)
        {
@@ -1004,6 +1065,57 @@
                throw (e);
            }
        }
        //作废(包含作废后控制、写入日志)    2025-03-10
        public bool Cancelltion(Int64 lngBillKey, string HBillNo, string procName, string sUser, ref string sReturn)
        {
            string sql = "";
            DataSet ds;
            if (isUse(lngBillKey, ref sReturn))
            {
                return false;
            }
            try
            {
                //开启事务
                oCn.BeginTran();
                string HDeleteMan = sUser;
                string HDeleteDate = ClsPub.GetServerDate(-1);
                oCn.RunProc(" Update " + MvarItemKey + " set HDeleteMan='" + HDeleteMan + "',HDeleteDate='" + HDeleteDate + "',HBillStatus=4 Where HInterID=" + lngBillKey.ToString());
                //作废后控制
                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)
            {
                oCn.RollBack();
                sReturn = e.Message;
                throw (e);
            }
        }
        //保养计划删除子表1
        public void DeleteBillSub(Int64 lngBillKey)
        {