wtt
2024-05-24 347f0efe1387a80639101d986791ecf67c421cc4
DAL/²É¹º¹ÜÀí/ClsCg_ContractBill.cs
@@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.Text;
using System.Data;
using DBUtility;
using System.Windows.Forms;
namespace DAL
{
@@ -328,8 +330,94 @@
                throw (e);
            }
        }
        #region è¡Œå…³é—­æ–¹æ³•重载
        //行关闭
        public bool CloseRow(Int64 lngBillKey, Int64 HEntryID, Int64 HEntryID2 , string HBillNo, string sUser, ref string sReturn)
        {
            string ComputerName = SystemInformation.ComputerName;   //设备名称
            string IPAddress = "";    //设备IP
            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 = " Update " + MvarItemKeySub2 + " set HCloseMan='" + HCloseMan + "',HEntryCloseDate='" + HEntryCloseDate + "',HCloseType=1 Where HInterID=" + lngBillKey.ToString() + " and HEntryID = " + HEntryID2;
                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+ ";付款计划子表内码:"+HEntryID2;
                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 CancelRow(Int64 lngBillKey, Int64 HEntryID, Int64 HEntryID2, string HBillNo, string sUser, ref string sReturn)
        {
            try
            {
                //oCn.BeginTran();
                string ComputerName = SystemInformation.ComputerName;   //设备名称
                string IPAddress = "";    //设备IP
                string sql = "select * from " + MvarItemKeySub + " where HInterID=" + lngBillKey.ToString() + " and HEntryID = " + HEntryID;
                DataSet ds = oCn.RunProcReturn(sql, MvarItemKeySub);
                string sql2 = "select * from " + MvarItemKeySub2 + " where HInterID=" + lngBillKey.ToString() + " and HEntryID = " + HEntryID2;
                DataSet ds2 = oCn.RunProcReturn(sql, MvarItemKeySub);
                if ((ds == null || ds.Tables[0].Rows.Count == 0) && (ds2 == null || ds2.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);
                    sql = " Update " + MvarItemKeySub2 + " set HCloseMan='',HEntryCloseDate='',HCloseType=0 Where HInterID=" + lngBillKey.ToString() + " and HEntryID = " + HEntryID2;
                    oCn.RunProc(sql);
                }
                //写入日志
                string WorkList = "行反关闭,单据号:" + HBillNo + ";物料明细子表内码:" + HEntryID + ";付款计划子表内码:" + HEntryID2;
                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);
            }
        }
        #endregion
    }
}