using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using System.Data;
|
using System.Windows.Forms;
|
|
namespace DBUtility
|
{
|
public class ClsXt_BaseBill
|
{
|
|
public string BillType; //单据类型
|
public string HBillSubType; //单据子类型
|
public string MvarItemKey; //表名
|
public string MvarItemKeySub; // 子表名
|
public string MvarItemKeySub2; // 子表名
|
public string MvarItemKeySub3; // 子表名
|
public string MvarItemKeySub4; // 子表名
|
public string MvarItemKeySubForWeb; //子表视图WEB
|
public string MvarItemKeySubForWeb2; //子表2视图WEB
|
public string MvarItemKeyForWeb; //主表视图WEB
|
|
public string MvarReportTitle; //标题
|
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()
|
{
|
BillType = "";
|
MvarItemKey = "";
|
MvarItemKeySub = "";
|
MvarItemKeySub2 = "";
|
MvarItemKeySub3 = "";
|
MvarItemKeySub4 = "";
|
MvarReportTitle = "";
|
MvarItemKeySubForWeb = "";
|
MvarItemKeySubForWeb2 = ""; //新增
|
MvarItemKeyForWeb = "";
|
}
|
|
#region 固定代码
|
|
~ClsXt_BaseBill()
|
{
|
|
}
|
//反作废
|
public bool AbandonCancelltion(Int64 lngBillKey, ref string sReturn)
|
{
|
try
|
{
|
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());
|
}
|
sReturn = "";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
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);
|
}
|
}
|
|
//反作废(包含作废后控制、写入日志) 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)
|
{
|
try
|
{
|
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());
|
}
|
|
sReturn = "";
|
return true;
|
}
|
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);
|
}
|
}
|
|
//反关闭单据(包含反关闭后控制 写入日志) 2025-03-18
|
public bool CancelClose(Int64 lngBillKey, string HBillNo, string procName, string sUser, ref string sReturn)
|
{
|
try
|
{
|
string sql = "";
|
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());
|
}
|
|
//反关闭后控制
|
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);
|
}
|
}
|
//行反关闭单据(包含写入日志) 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;
|
}
|
try
|
{
|
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 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 = "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;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
throw (e);
|
}
|
}
|
//反审核(包含反审核后控制、写入日志) 2024-01-31
|
public bool AbandonCheck(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();
|
|
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 = "反审核过程中出错,请与网络管理人员联系";
|
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;
|
}
|
//反审核后 更新及时库存表 减少库存
|
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 = "反审核单据成功!";
|
oCn.Commit();
|
return true;
|
}
|
catch (Exception e)
|
{
|
oCn.RollBack();
|
sReturn = e.Message;
|
throw (e);
|
}
|
}
|
|
//发起多级审批
|
public bool startCheckFlow(Int64 lngBillKey,ref string sReturn)
|
{
|
try
|
{
|
string HBillNo = ""; //单据号
|
string HCheckFlowID = ""; //审批流ID
|
string HCheckItemNowID = ""; //当前审核项目ID
|
string HCheckItemNextID = ""; //待审核项目ID
|
|
//判断是否已经发起审批
|
string sql0 = "select * from Xt_BillCheckFlowStatus where HBillInterID = " + lngBillKey + " and HBillTypeID = '" + this.BillType + "'";
|
DataSet ds0 = oCn.RunProcReturn(sql0, "Xt_BillCheckFlowStatus");
|
if (ds0 != null && ds0.Tables[0].Rows.Count > 0)
|
{
|
sReturn = "单据已发起审批,不可重复审批!";
|
return false;
|
}
|
|
//获取单据数据
|
string sql = "select * from " + this.MvarItemKey + " where HInterID = " + lngBillKey;
|
DataSet ds = oCn.RunProcReturn(sql, this.MvarItemKey);
|
if (ds == null || ds.Tables[0].Rows.Count == 0)
|
{
|
sReturn = "单据不存在!";
|
return false;
|
}
|
HBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString();
|
string HCheckFlowID_select = ds.Tables[0].Rows[0]["HCheckFlowID"].ToString();
|
//获取单据类型对应的默认审批流
|
string sql1 = "select b.HInterID,b.HCheckItemID from Xt_CheckFlowMain as a " +
|
"inner join Xt_CheckFlowSub as b on a.HInterID = b.HInterID " +
|
"where a.HBillTypeID = '" + this.BillType + "' " +
|
//"and a.HInterID = " + HCheckFlowID_select + " " +
|
"and a.HStandard = 1 " +
|
"order by b.HFlowNo asc";
|
DataSet ds1 = oCn.RunProcReturn(sql1, "Xt_CheckFlowMain");
|
if (ds1 == null || ds1.Tables[0].Rows.Count == 0)
|
{
|
sReturn = "默认审批流不存在!";
|
return false;
|
}
|
|
HCheckFlowID = ds1.Tables[0].Rows[0]["HInterID"].ToString();
|
HCheckItemNowID = ds1.Tables[0].Rows[0]["HCheckItemID"].ToString();
|
if (ds1.Tables[0].Rows.Count >= 2)
|
{
|
HCheckItemNextID = ds1.Tables[0].Rows[1]["HCheckItemID"].ToString();
|
}
|
else
|
{
|
HCheckItemNextID = "0";
|
}
|
|
oCn.BeginTran();
|
//增加 单据审批状态表 数据
|
for (int i = 0; i < ds1.Tables[0].Rows.Count; i++)
|
{
|
string sql2 = "insert into Xt_BillCheckFlowStatus" +
|
"(HBillTypeID,HBillInterID,HBillNo,HCheckFlowID,HCheckItemID,HChecker,HCheckDate,HCheckNote) " +
|
"values(" +
|
"'" + this.BillType + "'," +
|
"" + lngBillKey + "," +
|
"'" + HBillNo + "'," +
|
"" + ds1.Tables[0].Rows[i]["HInterID"].ToString() + "," +
|
"" + ds1.Tables[0].Rows[i]["HCheckItemID"].ToString() + "," +
|
"" + "''" + "," +
|
"" + "''" + "," +
|
"" + "''" + "" +
|
")";
|
|
oCn.RunProc(sql2);
|
}
|
|
//更新主表 审批流 数据
|
string sql3 = "update " + this.MvarItemKey + " set HCheckFlowID = " + HCheckFlowID + ",HCheckItemNowID=" + HCheckItemNowID + ",HCheckItemNextID=" + HCheckItemNextID + ",HBillStatus=" + 6 + " where HInterID = " + lngBillKey;
|
oCn.RunProc(sql3);
|
|
|
oCn.Commit();
|
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn += e.Message;
|
return false;
|
}
|
}
|
|
//驳回
|
public bool RejectCheckFlowProgress(Int64 lngBillKey, string HBillNo,string sUser, ref string sReturn)
|
{
|
|
if (isUse(lngBillKey, ref sReturn))
|
{
|
return false;
|
}
|
try
|
{
|
//开启事务
|
oCn.BeginTran();
|
|
//判断是否存在审核过的项目
|
//string sql0 = "select * from Xt_BillCheckFlowStatus where HBillInterID = " + lngBillKey + " and HBillTypeID = '" + this.BillType + "' and ISNULL(HChecker,'') <> ''";
|
//DataSet ds0 = oCn.RunProcReturn(sql0, "Xt_BillCheckFlowStatus");
|
//if (ds0 != null && ds0.Tables[0].Rows.Count == 0)
|
//{
|
// sReturn = "单据不存在已经审核的项目!";
|
// return false;
|
//}
|
|
//获取需要驳回的审核项目
|
string sql0 = "select c.* from Xt_CheckFlowMain as a " +
|
"inner join Xt_CheckFlowSub as b on a.HInterID = b.HInterID " +
|
"inner join Xt_BillCheckFlowStatus as c on a.HBillTypeID = c.HBillTypeID and b.HCheckItemID = c.HCheckItemID " +
|
"where c.HBillTypeID = '" + this.BillType + "' and c.HBillInterID = " + lngBillKey + " " +
|
"order by b.HFlowNo asc";
|
DataSet ds0 = oCn.RunProcReturn(sql0, "Xt_BillCheckFlowStatus");
|
if (ds0 == null || ds0.Tables[0].Rows.Count == 0)
|
{
|
sReturn = "驳回失败!原因:未发起审批!!";
|
return false;
|
}
|
//获取当前审核项目
|
string HCheckFlowID = ds0.Tables[0].Rows[0]["HCheckFlowID"].ToString(); //审批流内码
|
sql0 = "select * from " + MvarItemKey + " where HInterID = " + lngBillKey;
|
ds0 = oCn.RunProcReturn(sql0, MvarItemKey);
|
string HCheckItemNowID = ds0.Tables[0].Rows[0]["HCheckItemNowID"].ToString(); //当前审批项目内码
|
//查找是否有权限
|
string sql01 = "select * from Xt_CheckUserRight where HUserID = '" + sUser + "' and HCheckFlowInterID = " + HCheckFlowID + " and HCheckItemID = " + HCheckItemNowID + "";
|
DataSet ds01 = oCn.RunProcReturn(sql01, "Xt_CheckUserRight");
|
if (ds01.Tables[0].Rows.Count == 0)
|
{
|
sReturn = "无权限!";
|
return false;
|
}
|
//更新 驳回删除审核流状态表
|
string sql02 = "Delete Xt_BillCheckFlowStatus where HBillTypeID = '" + this.BillType + "' and HBillInterID=" + lngBillKey + " and HCheckFlowID=" + HCheckFlowID;
|
oCn.RunProc(sql02);
|
oCn.RunProc(" Update " + MvarItemKey + " set HChecker='',HCheckDate=null,HBillStatus=5,HCheckItemNowID = 0,HCheckItemNextID = 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)
|
{
|
oCn.RollBack();
|
sReturn = e.Message;
|
throw (e);
|
}
|
}
|
|
//审批流-反审核(包含反审核后控制、写入日志) 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"|| HBillType == "1256")
|
{
|
//反审核更新 及时库存表 增加库存 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;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
throw (e);
|
}
|
}
|
//审核
|
public bool CheckBill(Int64 lngBillKey,string sUser, ref string sReturn)
|
{
|
|
try
|
{
|
string HChecker = sUser;
|
string HCheckDate = ClsPub.GetServerDate(-1);
|
oCn.RunProc(" Update " + MvarItemKey + " set HChecker='" + HChecker + "',HCheckDate='" + HCheckDate + "' Where HInterID=" + lngBillKey.ToString());
|
sReturn = "";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
throw (e);
|
}
|
}
|
//审核(包含审核后控制、写入日志) 2024-01-31
|
public bool CheckBill(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.BeginTran();
|
|
//更新单据状态
|
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 = "审核过程中出错,请与网络管理人员联系";
|
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;
|
}
|
//审核后 更新及时库存表 增加库存
|
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 = "审核单据成功!";
|
oCn.Commit();
|
return true;
|
}
|
catch (Exception e)
|
{
|
oCn.RollBack();
|
sReturn = e.Message;
|
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" || HBillType == "1256")
|
{
|
//审核更新 及时库存表 增加库存 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)
|
{
|
|
try
|
{
|
string HCloseMan = ClsPub.CurUserName;
|
string HCloseDate = ClsPub.GetServerDate(-1);
|
oCn.RunProc(" Update " + MvarItemKey + " set HCloseMan='" + HCloseMan + "',HCloseDate='" + HCloseDate + "',HBillStatus=3,HCloseType = 1 Where HInterID=" + lngBillKey.ToString());
|
sReturn = "";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
throw (e);
|
}
|
}
|
//关闭单据(包含写入日志) 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 + "',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);
|
}
|
}
|
|
//关闭单据(包含关闭后控制 写入日志) 2025-03-18
|
public bool CloseBill(Int64 lngBillKey, string HBillNo, string procName, string sUser, ref string sReturn)
|
{
|
try
|
{
|
string sql = "";
|
DataSet ds;
|
oCn.BeginTran();
|
string HCloseMan = sUser;
|
string HCloseDate = ClsPub.GetServerDate(-1);
|
oCn.RunProc(" Update " + MvarItemKey + " set HCloseMan='" + HCloseMan + "',HCloseDate='" + HCloseDate + "',HBillStatus=3,HCloseType = 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)
|
{
|
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);
|
}
|
}
|
//作废
|
public bool Cancelltion(Int64 lngBillKey, ref string sReturn)
|
{
|
try
|
{
|
string HDeleteMan = ClsPub.CurUserName;
|
string HDeleteDate = ClsPub.GetServerDate(-1);
|
oCn.RunProc(" Update " + MvarItemKey + " set HDeleteMan='" + HDeleteMan + "',HDeleteDate='" + HDeleteDate + "',HBillStatus=4 Where HInterID=" + lngBillKey.ToString());
|
sReturn = "";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
throw (e);
|
}
|
}
|
|
//作废单据(包含写入日志) 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 + "',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);
|
}
|
}
|
//作废(包含作废后控制、写入日志) 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)
|
{
|
oCn.RunProc("Delete From " + MvarItemKeySub + " where HInterID=" + lngBillKey.ToString());
|
}
|
//保养计划删除子表2
|
public void DeleteBillSub2(Int64 lngBillKey)
|
{
|
if (MvarItemKeySub2 != "")
|
{
|
oCn.RunProc("Delete From " + MvarItemKeySub2 + " where HInterID=" + lngBillKey.ToString());
|
}
|
}
|
//删除子表
|
public void DeleteBillSub3(Int64 lngBillKey)
|
{
|
if (MvarItemKeySub3 != "")
|
{
|
oCn.RunProc("Delete From " + MvarItemKeySub3 + " where HInterID=" + lngBillKey.ToString());
|
}
|
}
|
//删除子表
|
public void DeleteBillSub4(Int64 lngBillKey)
|
{
|
if (MvarItemKeySub4 != "")
|
{
|
oCn.RunProc("Delete From " + MvarItemKeySub4 + " where HInterID=" + lngBillKey.ToString());
|
}
|
}
|
//删除主表
|
public void DeleteBillMain(Int64 lngBillKey)
|
{
|
oCn.RunProc("Delete From " + MvarItemKey + " where HInterID=" + lngBillKey.ToString());
|
}
|
//删除单据
|
public virtual bool DeleteBill(Int64 lngBillKey, ref string sReturn)
|
{
|
try
|
{
|
oCn.BeginTran();
|
//删除关联
|
DeleteRelation(ref sReturn, lngBillKey);
|
//删除明细表
|
DeleteBillSub(lngBillKey);
|
DeleteBillSub2(lngBillKey);
|
DeleteBillSub3(lngBillKey);
|
DeleteBillSub4(lngBillKey);
|
//删除主表
|
DeleteBillMain(lngBillKey);
|
sReturn = "删除单据成功!";
|
oCn.Commit();
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
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)
|
{
|
try
|
{
|
//查询主表
|
DataSet Ds ;
|
Ds = oCn.RunProcReturn("Select HinterID from " + MvarItemKeySub + " Where HInterID=" + lngBillKey.ToString() + " and isnull(HRelationQty,0)<>0 ", MvarItemKey);
|
if (Ds.Tables[0].Rows.Count != 0)
|
{
|
sReturn = "单据已被关联,不能操作!";
|
return true;
|
}
|
sReturn = "";
|
return false;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
throw (e);
|
}
|
}
|
//读取下张单据
|
public bool GetNextBill(ref string sReturn,string HBillNo)
|
{
|
try
|
{
|
//查询主表
|
Int64 lMainID = 0;
|
DataSet Ds ;
|
Ds = oCn.RunProcReturn("Select Top 1 HinterID from " + MvarItemKey + " Where HBillNo>'" + HBillNo + "' and HBillType='" + this.BillType + "' Order By HInterID ", MvarItemKey);
|
if (Ds.Tables[0].Rows.Count != 0)
|
{
|
lMainID = ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"].ToString());
|
if (lMainID != 0)
|
{
|
if (ShowBill(lMainID, ref sReturn))
|
{
|
sReturn = "查询下张单据成功";
|
return true;
|
}
|
}
|
}
|
sReturn = "查询下张单据失败";
|
return false;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
throw (e);
|
}
|
}
|
//读取上张单据
|
public bool GetPrevousBill(ref string sReturn, string HBillNo)
|
{
|
try
|
{
|
//查询主表
|
Int64 lMainID = 0;
|
DataSet Ds ;
|
Ds = oCn.RunProcReturn("Select Top 1 HinterID from " + MvarItemKey + " Where HBillNo<'" + HBillNo + "' and HBillType='" + BillType + "' Order By HInterID Desc", MvarItemKey);
|
if (Ds.Tables[0].Rows.Count != 0)
|
{
|
lMainID = ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"].ToString());
|
if (lMainID != 0)
|
{
|
if (ShowBill(lMainID, ref sReturn))
|
{
|
sReturn = "查询上张单据成功";
|
return true;
|
}
|
}
|
}
|
sReturn = "查询上张单据失败";
|
return false;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
throw (e);
|
}
|
}
|
//读取首张单据
|
public bool GetFirstBill(ref string sReturn)
|
{
|
try
|
{
|
//查询主表
|
Int64 lMainID = 0;
|
DataSet Ds ;
|
Ds = oCn.RunProcReturn("Select Top 1 HinterID from " + MvarItemKey + " Where HBillType='" + BillType + "' Order By HInterID ", MvarItemKey);
|
if (Ds.Tables[0].Rows.Count != 0)
|
{
|
lMainID = ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"].ToString());
|
if (lMainID != 0)
|
{
|
if (ShowBill(lMainID, ref sReturn))
|
{
|
sReturn = "查询首张单据成功";
|
return true;
|
}
|
}
|
}
|
sReturn = "查询首张单据失败";
|
return false;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
throw (e);
|
}
|
}
|
//读取末张单据
|
public bool GetLastBill(ref string sReturn)
|
{
|
try
|
{
|
//查询主表
|
Int64 lMainID = 0;
|
DataSet Ds ;
|
Ds = oCn.RunProcReturn("Select Top 1 HinterID from " + MvarItemKey + " Where HBillType='" + BillType + "' Order By HInterID Desc", MvarItemKey);
|
if (Ds.Tables[0].Rows.Count != 0)
|
{
|
lMainID = ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"].ToString());
|
if (lMainID != 0)
|
{
|
if (ShowBill(lMainID, ref sReturn))
|
{
|
sReturn = "查询末张单据成功";
|
return true;
|
}
|
}
|
}
|
sReturn = "查询末张单据失败";
|
return false;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
throw (e);
|
}
|
}
|
//MAINID是否重复
|
public virtual bool IsExistMainID(ref string sReturn, Int64 lngBillKey, ClsPub.Enum_BillStatus oBillStatus)
|
{
|
try
|
{
|
string sSql = "";
|
if (oBillStatus == ClsPub.Enum_BillStatus.BillStatus_AddNew)
|
{
|
sSql = "Select HInterID from " + MvarItemKey + " where HInterID =" + lngBillKey + "";
|
|
DataSet Ds;
|
Ds = oCn.RunProcReturn(sSql, " + MvarItemKey + ");
|
if (Ds.Tables[0].Rows.Count != 0)
|
{
|
sReturn = "ID重复";
|
return true;
|
}
|
}
|
sReturn = "ID未重复";
|
return false;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
throw (e);
|
}
|
}
|
//K3单据号是否重复
|
public bool IsExistBillNoK3(ref string sReturn, string sBillNo, ClsPub.Enum_BillStatus oBillStatus, Int64 lngBillKey)
|
{
|
try
|
{
|
string sSql = "";
|
if (oBillStatus == ClsPub.Enum_BillStatus.BillStatus_AddNew)
|
{
|
sSql = "Select FInterID from " + MvarItemKey + " where ftrantype='" + BillType + "'and FBillNO ='" + sBillNo + "'";
|
}
|
else
|
{
|
sSql = "Select FInterID from " + MvarItemKey + " where ftrantype='" + BillType + "'and FBillNO ='" + sBillNo + "' and FInterID<>" + lngBillKey.ToString();
|
}
|
DataSet Ds;
|
Ds = oCnK3.RunProcReturn(sSql, " + MvarItemKey + ");
|
if (Ds.Tables[0].Rows.Count != 0)
|
{
|
sReturn = "单号重复";
|
return true;
|
}
|
sReturn = "单号未重复";
|
return false;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
throw (e);
|
}
|
}
|
//单据号是否重复
|
public virtual bool IsExistBillNo(ref string sReturn, string sBillNo, ClsPub.Enum_BillStatus oBillStatus, Int64 lngBillKey)
|
{
|
string sSql = "";
|
try
|
{
|
|
if (oBillStatus == ClsPub.Enum_BillStatus.BillStatus_AddNew)
|
{
|
sSql = "Select HInterID from " + MvarItemKey + " where hbilltype='" + BillType + "'and HBillNO ='" + sBillNo + "'";
|
}
|
else
|
{
|
sSql = "Select HInterID from " + MvarItemKey + " where hbilltype='" + BillType + "'and HBillNO ='" + sBillNo + "' and HInterID<>" + lngBillKey.ToString();
|
}
|
DataSet Ds ;
|
Ds = oCn.RunProcReturn(sSql, " + MvarItemKey + ");
|
if (Ds.Tables[0].Rows.Count != 0)
|
{
|
sReturn = "单号重复";
|
return true;
|
}
|
sReturn = "单号未重复";
|
return false;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message+"sql:"+ sSql;
|
return false;
|
}
|
}
|
#endregion
|
//修改单据
|
public virtual bool ModifyBill(Int64 lngBillKey, ref string sReturn)
|
{
|
return true;
|
}
|
//新增单据
|
public virtual bool AddBill( ref string sReturn)
|
{
|
return true;
|
}
|
//显示单据
|
public virtual bool ShowBill(Int64 lngBillKey, ref string sReturn)
|
{
|
return true;
|
}
|
|
|
//删除关联
|
public virtual void DeleteRelation(ref string sReturn, Int64 lngBillKey)
|
{
|
sReturn = "";
|
return;
|
}
|
|
//新增关联
|
public virtual void AddNewRelation(ref string sReturn, Int64 lngBillKey)
|
{
|
sReturn = "";
|
return;
|
}
|
|
//读取下张单据K3
|
public bool GetNextBillK3(ref string sReturn, string HBillNo)
|
{
|
try
|
{
|
//查询主表
|
Int64 lMainID = 0;
|
DataSet Ds;
|
Ds = oCnK3.RunProcReturn("Select Top 1 FinterID from " + MvarItemKey + " Where FBillNo>'" + HBillNo + "' and FTranType='" + this.BillType + "' Order By FInterID ", MvarItemKey);
|
if (Ds.Tables[0].Rows.Count != 0)
|
{
|
lMainID = ClsPub.isLong(Ds.Tables[0].Rows[0]["FInterID"].ToString());
|
if (lMainID != 0)
|
{
|
if (ShowBill(lMainID, ref sReturn))
|
{
|
sReturn = "查询下张单据成功";
|
return true;
|
}
|
}
|
}
|
sReturn = "查询下张单据失败";
|
return false;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
throw (e);
|
}
|
}
|
|
//读取首张单据K3
|
public bool GetFirstBillK3(ref string sReturn)
|
{
|
try
|
{
|
//查询主表
|
Int64 lMainID = 0;
|
DataSet Ds;
|
Ds = oCnK3.RunProcReturn("Select Top 1 FinterID from " + MvarItemKey + " Where FTranType='" + BillType + "' Order By FInterID ", MvarItemKey);
|
if (Ds.Tables[0].Rows.Count != 0)
|
{
|
lMainID = ClsPub.isLong(Ds.Tables[0].Rows[0]["FInterID"].ToString());
|
if (lMainID != 0)
|
{
|
if (ShowBill(lMainID, ref sReturn))
|
{
|
sReturn = "查询首张单据成功";
|
return true;
|
}
|
}
|
}
|
sReturn = "查询首张单据失败";
|
return false;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
throw (e);
|
}
|
}
|
|
//读取末张单据K3
|
public bool GetLastBillK3(ref string sReturn)
|
{
|
try
|
{
|
//查询主表
|
Int64 lMainID = 0;
|
DataSet Ds;
|
Ds = oCnK3.RunProcReturn("Select Top 1 FinterID from " + MvarItemKey + " Where FTranType='" + BillType + "' Order By FInterID Desc", MvarItemKey);
|
if (Ds.Tables[0].Rows.Count != 0)
|
{
|
lMainID = ClsPub.isLong(Ds.Tables[0].Rows[0]["FInterID"].ToString());
|
if (lMainID != 0)
|
{
|
if (ShowBill(lMainID, ref sReturn))
|
{
|
sReturn = "查询末张单据成功";
|
return true;
|
}
|
}
|
}
|
sReturn = "查询末张单据失败";
|
return false;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
throw (e);
|
}
|
}
|
|
//读取上张单据K3
|
public bool GetPrevousBillK3(ref string sReturn, string HBillNo)
|
{
|
try
|
{
|
//查询主表
|
Int64 lMainID = 0;
|
DataSet Ds;
|
Ds = oCnK3.RunProcReturn("Select Top 1 FinterID from " + MvarItemKey + " Where FBillNo<'" + HBillNo + "' and FTranType='" + BillType + "' Order By FInterID Desc", MvarItemKey);
|
if (Ds.Tables[0].Rows.Count != 0)
|
{
|
lMainID = ClsPub.isLong(Ds.Tables[0].Rows[0]["FInterID"].ToString());
|
if (lMainID != 0)
|
{
|
if (ShowBill(lMainID, ref sReturn))
|
{
|
sReturn = "查询上张单据成功";
|
return true;
|
}
|
}
|
}
|
sReturn = "查询上张单据失败";
|
return false;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
throw (e);
|
}
|
}
|
|
//显示单据头
|
public DataSet ShowBillMain(Int64 lngBillKey,string sShowItem, ref string sReturn)
|
{
|
string s = "";
|
try
|
{
|
//查询主表
|
DataSet Ds;
|
s = "Select " + sShowItem + " from " + MvarItemKeyForWeb + " Where HInterID=" + lngBillKey.ToString();
|
Ds = oCn.RunProcReturn("Select " + sShowItem + " from " + MvarItemKeyForWeb + " Where HInterID=" + lngBillKey.ToString(), MvarItemKeyForWeb);
|
if (Ds==null || Ds.Tables[0].Rows.Count == 0)
|
{
|
sReturn = "单据头未找到!";
|
return null;
|
}
|
sReturn = "显示单据头成功!";
|
return Ds;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
return null;
|
}
|
}
|
|
//显示单据头2
|
public DataSet ShowBillMain(Int64 lngBillKey, Int64 HEntryID, string sShowItem, ref string sReturn)
|
{
|
string s = "";
|
try
|
{
|
//查询主表
|
DataSet Ds;
|
s = "Select " + sShowItem + " from " + MvarItemKeyForWeb + " Where HInterID=" + lngBillKey.ToString() + " and HEntryID=" + HEntryID;
|
Ds = oCn.RunProcReturn("Select " + sShowItem + " from " + MvarItemKeyForWeb + " Where HInterID=" + lngBillKey.ToString() + " and HEntryID=" + HEntryID, MvarItemKeyForWeb);
|
if (Ds == null || Ds.Tables[0].Rows.Count == 0)
|
{
|
sReturn = "单据头未找到!";
|
return null;
|
}
|
sReturn = "显示单据头成功!";
|
return Ds;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
return null;
|
}
|
}
|
|
//显示单体
|
public DataSet ShowBillSub(Int64 lngBillKey, string sShowItem, ref string sReturn)
|
{
|
string s = "";
|
try
|
{
|
//查询主表
|
DataSet Ds;
|
s = "Select " + sShowItem + " from " + MvarItemKeySubForWeb + " Where HInterID=" + lngBillKey.ToString() + " order by HEntryID ";
|
Ds = oCn.RunProcReturn("Select " + sShowItem + " from " + MvarItemKeySubForWeb + " Where HInterID=" + lngBillKey.ToString() + " order by HEntryID ", MvarItemKeySubForWeb);
|
if (Ds == null || Ds.Tables[0].Rows.Count == 0)
|
{
|
sReturn = "单据体未找到!";
|
return null;
|
}
|
sReturn = "显示单据体成功!";
|
return Ds;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message + s ;
|
return null;
|
}
|
}
|
|
//显示表体
|
public DataSet ShowBillSub(Int64 lngBillKey, Int64 HEntryID, string sShowItem, ref string sReturn)
|
{
|
string s = "";
|
try
|
{
|
//查询主表
|
DataSet Ds;
|
s = "Select " + sShowItem + " from " + MvarItemKeySubForWeb + " Where HInterID=" + lngBillKey.ToString() + " and HEntryID=" + HEntryID + " order by HEntryID ";
|
Ds = oCn.RunProcReturn("Select " + sShowItem + " from " + MvarItemKeySubForWeb + " Where HInterID=" + lngBillKey.ToString() + " and HEntryID=" + HEntryID + " order by HEntryID ", MvarItemKeySubForWeb);
|
if (Ds == null || Ds.Tables[0].Rows.Count == 0)
|
{
|
sReturn = "单据体未找到!";
|
return null;
|
}
|
sReturn = "显示单据体成功!";
|
return Ds;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message + s;
|
return null;
|
}
|
}
|
|
//显示表体2
|
public DataSet ShowBillSub2(Int64 lngBillKey, Int64 HEntryID, string sShowItem, ref string sReturn)
|
{
|
string s = "";
|
try
|
{
|
//查询主表
|
DataSet Ds;
|
s = "Select " + sShowItem + " from " + MvarItemKeySubForWeb2 + " Where HInterID=" + lngBillKey.ToString() + " and HEntryID=" + HEntryID + " order by HEntryID ";
|
Ds = oCn.RunProcReturn("Select " + sShowItem + " from " + MvarItemKeySubForWeb2 + " Where HInterID=" + lngBillKey.ToString() + " and HEntryID=" + HEntryID + " order by HEntryID ", MvarItemKeySubForWeb2);
|
if (Ds == null || Ds.Tables[0].Rows.Count == 0)
|
{
|
sReturn = "单据体未找到!";
|
return null;
|
}
|
sReturn = "显示单据体成功!";
|
return Ds;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message + s;
|
return null;
|
}
|
}
|
|
|
|
//更新打印次数
|
public void UpDatePrintQty(Int64 lngBillKey, ref string sReturn)
|
{
|
|
try
|
{
|
oCn.RunProc(" Update " + MvarItemKey + " set HPrintQty=HPrintQty + 1 Where HInterID=" + lngBillKey.ToString());
|
sReturn = "";
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
throw (e);
|
}
|
}
|
|
|
}
|
|
}
|