wtt
2024-08-01 8939791cd1ace3d7e653e5edaa895e27938bec33
DBUtility/ÒµÎñµ¥¾Ý/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 = "";
@@ -99,10 +140,85 @@
                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);
            }
        }
        //反审核
        public bool AbandonCheck(Int64 lngBillKey, ref string sReturn)
        {
            string sql = "";
            if (isUse(lngBillKey, ref sReturn))
            {
                return false;
@@ -122,7 +238,36 @@
                {
                    oCn.RunProc(" Update " + MvarItemKey + " set HChecker='',HCheckDate=null,HBillStatus=1 Where HInterID=" + lngBillKey.ToString());
                }
                //反审核后 æ›´æ–°åŠæ—¶åº“存表 å‡å°‘库存
                sql = "select * from  " + MvarItemKey + " where HInterID=" + lngBillKey.ToString();
                ds = oCn.RunProcReturn(sql, MvarItemKey);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    string HBillType = ds.Tables[0].Rows[0]["HBillType"].ToString();
                    if (HBillType == "1201" || HBillType == "1202" || HBillType == "1203" || HBillType == "1247" || HBillType == "1244" || HBillType == "1251" || HBillType == "1210" || HBillType == "1204")
                    {
                        //反审核更新 åŠæ—¶åº“存表 å¢žåŠ åº“å­˜ 1201 1202 1203 1247 1244 1251 1210
                        //反审核更新 åŠæ—¶åº“存表 å‡å°‘库存 1204 1202 1203 1247 1244 1251 1210
                        ds = oCn.RunProcReturn("exec h_KF_UPDateICinventory  '" + lngBillKey.ToString() + "','" + HBillType + "','2'", "h_KF_UPDateICinventory");
                    }
                    //=========================审核反审核后负库存控制
                    DataSet ds2 = oCn.RunProcReturn("Exec h_p_KF_ICinventoryStockCtrl '" + lngBillKey.ToString() + "', '" + HBillType + "'", "h_p_KF_ICinventoryStockCtrl");
                    if (ds2 == null)
                    {
                        sReturn = "库存更新后控制判断失败!";
                        oCn.RollBack();
                        return false;
                    }
                    if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
                    {
                        sReturn = "库存更新失败!" + DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBackRemark"]);
                        oCn.RollBack();
                        return false;
                    }
                    //============================
                }
                sReturn = "";
                return true;
            }
@@ -132,7 +277,7 @@
                throw (e);
            }
        }
        //反审核(包含反审核后控制)
        //反审核(包含反审核后控制、写入日志)    2024-01-31
        public bool AbandonCheck(Int64 lngBillKey, string HBillNo, string procName, string sUser, ref string sReturn)
        {
            string sql = "";
@@ -176,8 +321,46 @@
                    oCn.RollBack();
                    return false;
                }
                //反审核后 æ›´æ–°åŠæ—¶åº“存表 å‡å°‘库存
                sql = "select * from  " + MvarItemKey + " where HInterID=" + lngBillKey.ToString();
                ds = oCn.RunProcReturn(sql, MvarItemKey);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    string HBillType = ds.Tables[0].Rows[0]["HBillType"].ToString();
                    if (HBillType == "1201" || HBillType == "1202" || HBillType == "1203" || HBillType == "1247" || HBillType == "1244" || HBillType == "1251" || HBillType == "1210" || HBillType == "1205" || HBillType == "1250" || HBillType == "1206" || HBillType == "1245" || HBillType == "1239")
                    {
                        //反审核更新 åŠæ—¶åº“存表 å¢žåŠ åº“å­˜ 1201 1202 1203 1247 1244 1251 1210
                        //反审核更新 åŠæ—¶åº“存表 å‡å°‘库存 1205 1250 1206 1245 1239
                        ds = oCn.RunProcReturn("exec h_KF_UPDateICinventory  '" + lngBillKey.ToString() + "','" + HBillType + "','2'", "h_KF_UPDateICinventory");
                    }else if (HBillType == "1207")
                    {
                        //更新及时库存表   å¢žåŠ è°ƒå…¥åº“å­˜,减少调出库存
                        ds = oCn.RunProcReturn("exec h_KF_UPDateICinventory_Move  '" + lngBillKey.ToString() + "','" + HBillType + "','2'", "h_KF_UPDateICinventory_Move");
                    }
                    //=========================审核反审核后负库存控制
                    DataSet ds2 = oCn.RunProcReturn("Exec h_p_KF_ICinventoryStockCtrl '" + lngBillKey.ToString() + "', '" + HBillType + "'", "h_p_KF_ICinventoryStockCtrl");
                    if (ds2 == null)
                    {
                        sReturn = "库存更新失败后控制判断失败!";
                        oCn.RollBack();
                        return false;
                    }
                    if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
                    {
                        sReturn = "库存更新失败!" + DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBackRemark"]);
                        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;
            }
@@ -189,15 +372,113 @@
            }
        }
        //审批流-反审核(包含反审核后控制、写入日志)    2024-01-31
        public bool AbandonCheck(SQLHelper.ClsCN oCN,Int64 lngBillKey, string HBillNo, string procName, string sUser, ref string sReturn)
        {
            string sql = "";
            DataSet ds;
            if (isUse(lngBillKey, ref sReturn))
            {
                return false;
            }
            try
            {
                ds = oCN.RunProcReturn("select * from " + MvarItemKey + " where HInterID=" + lngBillKey.ToString(), MvarItemKey);
                if (ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "")
                {
                    oCN.RunProc(" Update " + MvarItemKey + " set HChecker='',HCheckDate=null,HBillStatus=4 Where HInterID=" + lngBillKey.ToString());
                }
                else if (ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "")
                {
                    oCN.RunProc(" Update " + MvarItemKey + " set HChecker='',HCheckDate=null,HBillStatus=3 Where HInterID=" + lngBillKey.ToString());
                }
                else
                {
                    oCN.RunProc(" Update " + MvarItemKey + " set HChecker='',HCheckDate=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 = "反审核过程中出错,请与网络管理人员联系";
                    return false;
                }
                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                {
                    sReturn = ds.Tables[0].Rows[0]["HRemark"].ToString();
                    return false;
                }
                //反审核后 æ›´æ–°åŠæ—¶åº“存表 å‡å°‘库存
                sql = "select * from  " + MvarItemKey + " where HInterID=" + lngBillKey.ToString();
                ds = oCN.RunProcReturn(sql, MvarItemKey);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    string HBillType = ds.Tables[0].Rows[0]["HBillType"].ToString();
                    if (HBillType == "1201" || HBillType == "1202" || HBillType == "1203" || HBillType == "1247" || HBillType == "1244" || HBillType == "1251" || HBillType == "1210" || HBillType == "1205" || HBillType == "1250" || HBillType == "1206" || HBillType == "1245" || HBillType == "1239")
                    {
                        //反审核更新 åŠæ—¶åº“存表 å¢žåŠ åº“å­˜ 1201 1202 1203 1247 1244 1251 1210
                        //反审核更新 åŠæ—¶åº“存表 å‡å°‘库存 1205 1250 1206 1245 1239
                        ds = oCN.RunProcReturn("exec h_KF_UPDateICinventory  '" + lngBillKey.ToString() + "','" + HBillType + "','2'", "h_KF_UPDateICinventory");
                    }
                }
                //写入日志
                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 = "反审核单据成功!";
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                throw (e);
            }
        }
        //审核
        public bool CheckBill(Int64 lngBillKey, ref string sReturn)
        {
            string sql = "";
            DataSet ds;
            try
            {
                string  HChecker = ClsPub.CurUserName ;
                string  HCheckDate =ClsPub.GetServerDate(-1);
                oCn.RunProc(" Update " + MvarItemKey + " set HChecker='" + HChecker + "',HCheckDate='" + HCheckDate + "',HBillStatus=2 Where HInterID=" + lngBillKey.ToString());
                //审核后 æ›´æ–°åŠæ—¶åº“存表 å¢žåŠ åº“å­˜
                sql = "select * from  " + MvarItemKey + " where HInterID=" + lngBillKey.ToString();
                ds = oCn.RunProcReturn(sql, MvarItemKey);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    string HBillType = ds.Tables[0].Rows[0]["HBillType"].ToString();
                    if (HBillType == "1201" || HBillType == "1202" || HBillType == "1203" || HBillType == "1247" || HBillType == "1244" || HBillType == "1251" || HBillType == "1210" || HBillType == "1204")
                    {
                        //审核更新 åŠæ—¶åº“存表 å¢žåŠ åº“å­˜ 1201 1202 1203 1247 1244 1251 1210
                        //审核更新 åŠæ—¶åº“存表 å‡å°‘库存 1204
                        ds = oCn.RunProcReturn("exec h_KF_UPDateICinventory  '" + lngBillKey.ToString() + "','" + HBillType + "','1'", "h_KF_UPDateICinventory");
                    }
                    //=========================审核反审核后负库存控制
                    DataSet ds2 = oCn.RunProcReturn("Exec h_p_KF_ICinventoryStockCtrl '" + lngBillKey.ToString() + "', '" + HBillType + "'", "h_p_KF_ICinventoryStockCtrl");
                    if (ds2 == null)
                    {
                        sReturn = "库存更新后控制判断失败!";
                        oCn.RollBack();
                        return false;
                    }
                    if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
                    {
                        sReturn = "库存更新失败!" + DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBackRemark"]);
                        oCn.RollBack();
                        return false;
                    }
                    //============================
                }
                sReturn = "";
                return true;
            }
@@ -225,7 +506,7 @@
                throw (e);
            }
        }
        //审核(包含审核后控制)
        //审核(包含审核后控制、写入日志)    2024-01-31
        public bool CheckBill(Int64 lngBillKey, string HBillNo,string procName , string sUser, ref string sReturn)
        {
            string sql = "";
@@ -234,7 +515,7 @@
            {
                string HChecker = sUser;
                string HCheckDate = ClsPub.GetServerDate(-1);
                //开启事务
                oCn.BeginTran();
@@ -256,8 +537,47 @@
                    oCn.RollBack();
                    return false;
                }
                //审核后 æ›´æ–°åŠæ—¶åº“存表 å¢žåŠ åº“å­˜
                sql = "select * from  " + MvarItemKey + " where HInterID=" + lngBillKey.ToString();
                ds = oCn.RunProcReturn(sql, MvarItemKey);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    string HBillType = ds.Tables[0].Rows[0]["HBillType"].ToString();
                    if (HBillType == "1201" || HBillType == "1202" || HBillType == "1203" || HBillType == "1247" || HBillType == "1244" || HBillType == "1251" || HBillType == "1210" || HBillType == "1250" || HBillType == "1206" || HBillType == "1245" || HBillType == "1239")
                    {
                        //审核更新 åŠæ—¶åº“存表 å¢žåŠ åº“å­˜ 1201 1202 1203 1247 1244 1251 1210
                        //审核更新 åŠæ—¶åº“存表 å‡å°‘库存 1204 1250 1206 1245 1239
                        ds = oCn.RunProcReturn("exec h_KF_UPDateICinventory  '" + lngBillKey.ToString() + "','" + HBillType + "','1'", "h_KF_UPDateICinventory");
                    }//直接调拨单审核更新
                    else if (HBillType == "1207")
                    {
                        //更新及时库存表   å‡å°‘调入库存,增加调出库存
                        ds = oCn.RunProcReturn("exec h_KF_UPDateICinventory_Move  '" + lngBillKey.ToString() + "','" + HBillType + "','1'", "h_KF_UPDateICinventory_Move");
                    }
                    //=========================审核反审核后负库存控制
                    DataSet ds2 = oCn.RunProcReturn("Exec h_p_KF_ICinventoryStockCtrl '" + lngBillKey.ToString() + "', '" + HBillType +"'", "h_p_KF_ICinventoryStockCtrl");
                    if (ds2 == null)
                    {
                        sReturn = "库存更新后控制判断失败!";
                        oCn.RollBack();
                        return false;
                    }
                    if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
                    {
                        sReturn = "库存更新失败!" + DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBackRemark"]);
                        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;
            }
@@ -268,6 +588,63 @@
                throw (e);
            }
        }
        //审批流-审核(包含审核后控制、写入日志)    2024-01-31
        public bool CheckBill(SQLHelper.ClsCN oCN,Int64 lngBillKey, string HBillNo, string procName, string sUser, ref string sReturn)
        {
            string sql = "";
            DataSet ds;
            try
            {
                string HChecker = sUser;
                string HCheckDate = ClsPub.GetServerDate(-1);
                //更新单据状态
                oCN.RunProc(" Update " + MvarItemKey + " set HChecker='" + HChecker + "',HCheckDate='" + HCheckDate + "',HBillStatus=2 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 = "审核过程中出错,请与网络管理人员联系";
                    return false;
                }
                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                {
                    sReturn = ds.Tables[0].Rows[0]["HRemark"].ToString();
                    return false;
                }
                //审核后 æ›´æ–°åŠæ—¶åº“存表 å¢žåŠ åº“å­˜
                sql = "select * from  " + MvarItemKey + " where HInterID=" + lngBillKey.ToString();
                ds = oCN.RunProcReturn(sql, MvarItemKey);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    string HBillType = ds.Tables[0].Rows[0]["HBillType"].ToString();
                    if (HBillType == "1201" || HBillType == "1202" || HBillType == "1203" || HBillType == "1247" || HBillType == "1244" || HBillType == "1251" || HBillType == "1210" || HBillType == "1250" || HBillType == "1206" || HBillType == "1245" || HBillType == "1239")
                    {
                        //审核更新 åŠæ—¶åº“存表 å¢žåŠ åº“å­˜ 1201 1202 1203 1247 1244 1251 1210
                        //审核更新 åŠæ—¶åº“存表 å‡å°‘库存 1204 1250 1206 1245 1239
                        ds = oCN.RunProcReturn("exec h_KF_UPDateICinventory  '" + lngBillKey.ToString() + "','" + HBillType + "','1'", "h_KF_UPDateICinventory");
                    }
                }
                //写入日志
                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 = "审核单据成功!";
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                throw (e);
            }
        }
        //关闭
        public bool CloseBill(Int64 lngBillKey, ref string sReturn)
        {
@@ -276,7 +653,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 +663,138 @@
                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, string procName, 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 + "','行关闭')"
                    );
                //行关闭后控制=========================================
                string sql_afterClose = "exec " + procName + " " + lngBillKey + "," + HEntryID + ",'" + HBillNo + "','" + sUser + "'";
                DataSet ds_afterClose = oCn.RunProcReturn(sql_afterClose, procName);
                if (ds_afterClose == null || ds_afterClose.Tables[0].Rows.Count <= 0)
                {
                    sReturn = "行关闭失败,原因:行关闭后控制错误,请联系网络管理人员!";
                    oCn.RollBack();
                    return false;
                }
                else
                {
                    if (ds_afterClose.Tables[0].Rows[0]["HBack"].ToString() != "0")
                    {
                        sReturn = "关闭失败,原因:" + ds_afterClose.Tables[0].Rows[0]["HRemark"].ToString();
                        oCn.RollBack();
                        return false;
                    }
                }
                //=========================================
                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 +816,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,10 +904,11 @@
                throw (e);
            }
        }
        //删除单据
        public virtual bool DeleteBill(Int64 lngBillKey, string HBillNo, string procName, string user, ref string sReturn)
        //删除单据(包含删除后控制、写入日志)    2024-01-31
        public bool DeleteBill(Int64 lngBillKey, string HBillNo, string procName, string sUser, ref string sReturn)
        {
            string sql = "";
            DataSet ds;
            try
            {
                oCn.BeginTran();
@@ -416,24 +922,27 @@
                //删除主表
                DeleteBillMain(lngBillKey);
                //删除后控制==================================================================================
                string sql2 = "exec " + procName + " " + lngBillKey + ",'" + HBillNo + "','" + user + "'";
                DataSet ds = oCn.RunProcReturn(sql2, procName);
                //删除后控制
                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 = "删除失败!原因:删除后判断失败,请与网络管理人员联系";
                    sReturn = "删除过程中出错,请与网络管理人员联系";
                    oCn.RollBack();
                    return false;
                }
                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                {
                    sReturn = "删除失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString();
                    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();