using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using System.Data;
|
|
namespace DAL
|
{
|
public class ClsXt_DefineBillMainSet : DBUtility.ClsXt_BaseBill
|
{
|
public Model.ClsXt_DefineBillMainSetMain omodel = new Model.ClsXt_DefineBillMainSetMain();
|
public List<Model.ClsXt_DefineBillMainSetSub> DetailColl = new List<Model.ClsXt_DefineBillMainSetSub>();
|
|
public ClsXt_DefineBillMainSet()
|
{
|
base.MvarItemKeyForWeb = "";
|
base.MvarItemKeySubForWeb = "Xt_DefineBillMainSet";
|
base.MvarItemKeySub = "Xt_DefineBillMainSetSub";
|
base.MvarItemKeySub2 = "";
|
base.MvarItemKeySub3 = "";
|
base.MvarItemKeySub4 = "";
|
base.MvarItemKey= "Xt_DefineBillMainSetMain";
|
base.MvarReportTitle="表头自定义单据";
|
base.BillType="";
|
base.HBillSubType = "";
|
|
}
|
|
#region 固定代码
|
|
~ClsXt_DefineBillMainSet()
|
{
|
DetailColl = null;
|
}
|
|
#endregion 自定义方法
|
|
#region 修改单据
|
public override bool ModifyBill(Int64 lngBillKey, ref string sReturn)
|
{
|
try
|
{
|
oCn.BeginTran();
|
omodel.HInterID = lngBillKey;
|
//更新主表
|
string mainSql = "update Xt_DefineBillMainSetMain set " +
|
"HInterID = '" + omodel.HInterID + "'" +
|
",HModName = '" + omodel.HModName + "'" +
|
",HUser = '" + omodel.HUser + "'" +
|
",HTableName = '" + omodel.HTableName + "'" +
|
",HDataViewName = '" + omodel.HDataViewName + "'" +
|
",HDataProcName = '" + omodel.HDataProcName + "'" +
|
",HUpdater = '" + omodel.HUpDater + "'" +
|
",HUpdateDate = " + "getdate()" + "" +
|
",HRowElementCount = '" + omodel.HRowElementCount + "'" +
|
" where HInterID=" + lngBillKey.ToString();
|
oCn.RunProc(mainSql);
|
|
//删除子表
|
DeleteBillSub(lngBillKey);
|
|
//插入子表
|
int HEntryID = 1;
|
foreach (Model.ClsXt_DefineBillMainSetSub oSub in DetailColl)
|
{
|
string subSql = "Insert into Xt_DefineBillMainSetSub " +
|
" (HInterID,HEntryID,HArrangeOrder,HArrangeOrderSub,HIsHide,HIsDisabled,HIsMust,HParentElementID,HElementID" +
|
",HElementLabel,HElementType,HFieldMaxLength,HDefaultValue,HFieldName,HFieldDataType,HRelateUrl,HSubWindowBackData" +
|
",HSubWindowBackDataMethodName,HSelectContent" +
|
") values(" +
|
"'" + omodel.HInterID + "'" +
|
",'" + (HEntryID++) + "'" +
|
",'" + oSub.HArrangeOrder + "'" +
|
",'" + oSub.HArrangeOrderSub + "'" +
|
",'" + (oSub.HIsHide ? 1 : 0) + "'" +
|
",'" + (oSub.HIsDisabled ? 1 : 0) + "'" +
|
",'" + (oSub.HIsMust ? 1 : 0) + "'" +
|
",'" + oSub.HParentElementID + "'" +
|
",'" + oSub.HElementID + "'" +
|
",'" + oSub.HElementLabel + "'" +
|
",'" + oSub.HElementType + "'" +
|
",'" + oSub.HFieldMaxLength + "'" +
|
",'" + oSub.HDefaultValue + "'" +
|
",'" + oSub.HFieldName + "'" +
|
",'" + oSub.HFieldDataType + "'" +
|
",'" + oSub.HRelateUrl + "'" +
|
",'" + oSub.HSubWindowBackData + "'" +
|
",'" + oSub.HSubWindowBackDataMethodName + "'" +
|
",'" + oSub.HSelectContent + "'" +
|
") ";
|
oCn.RunProc(subSql);
|
}
|
|
sReturn = "修改单据成功!";
|
oCn.Commit();
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
#endregion
|
|
#region 新增单据
|
public override bool AddBill(ref string sReturn)
|
{
|
try
|
{
|
|
|
string sql_0 = "select top(1)* from Xt_DefineBillMainSetMain order by HInterID desc";
|
DataSet dataSet = oCn.RunProcReturn(sql_0, "Xt_DefineBillMainSetMain");
|
if(dataSet!=null && dataSet.Tables[0].Rows.Count > 0)
|
{
|
omodel.HInterID = DBUtility.ClsPub.isLong(dataSet.Tables[0].Rows[0]["HInterID"]) + 1;
|
}
|
else
|
{
|
omodel.HInterID = 1;
|
}
|
|
oCn.BeginTran();
|
//主表
|
string mainSql = "Insert Into Xt_DefineBillMainSetMain" +
|
"(HInterID,HModName,HUser,HTableName,HDataViewName,HDataProcName,HMaker,HMakeDate,HRowElementCount) " +
|
" values(" +
|
"'" + omodel.HInterID + "'" +
|
",'" + omodel.HModName + "'" +
|
",'" + omodel.HUser + "'" +
|
",'" + omodel.HTableName + "'" +
|
",'" + omodel.HDataViewName + "'" +
|
",'" + omodel.HDataProcName + "'" +
|
",'" + omodel.HMaker + "'" +
|
"," + "getdate()" + "" +
|
",'" + omodel.HRowElementCount + "'" +
|
")";
|
oCn.RunProc(mainSql);
|
|
//插入子表
|
int HEntryID = 1;
|
foreach (Model.ClsXt_DefineBillMainSetSub oSub in DetailColl)
|
{
|
string subSql = "Insert into Xt_DefineBillMainSetSub " +
|
" (HInterID,HEntryID,HArrangeOrder,HArrangeOrderSub,HIsHide,HIsDisabled,HIsMust,HParentElementID,HElementID" +
|
",HElementLabel,HElementType,HFieldMaxLength,HDefaultValue,HFieldName,HFieldDataType,HRelateUrl,HSubWindowBackData" +
|
",HSubWindowBackDataMethodName,HSelectContent" +
|
") values(" +
|
"'" + omodel.HInterID + "'" +
|
",'" + (HEntryID++) + "'" +
|
",'" + oSub.HArrangeOrder + "'" +
|
",'" + oSub.HArrangeOrderSub + "'" +
|
",'" + (oSub.HIsHide?1:0) + "'" +
|
",'" + (oSub.HIsDisabled?1:0) + "'" +
|
",'" + (oSub.HIsMust?1:0) + "'" +
|
",'" + oSub.HParentElementID + "'" +
|
",'" + oSub.HElementID + "'" +
|
",'" + oSub.HElementLabel + "'" +
|
",'" + oSub.HElementType + "'" +
|
",'" + oSub.HFieldMaxLength + "'" +
|
",'" + oSub.HDefaultValue + "'" +
|
",'" + oSub.HFieldName + "'" +
|
",'" + oSub.HFieldDataType + "'" +
|
",'" + oSub.HRelateUrl + "'" +
|
",'" + oSub.HSubWindowBackData + "'" +
|
",'" + oSub.HSubWindowBackDataMethodName + "'" +
|
",'" + oSub.HSelectContent + "'" +
|
") ";
|
oCn.RunProc(subSql);
|
}
|
|
sReturn = "新增单据成功!";
|
oCn.Commit();
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
#endregion
|
|
#region 显示单据
|
public override bool ShowBill(Int64 lngBillKey, ref string sReturn)
|
{
|
try
|
{
|
//查询主表
|
DataSet Ds ;
|
Ds = oCn.RunProcReturn("Select * from Xt_DefineBillMainSetMain Where HInterID=" + lngBillKey.ToString(), "Xt_DefineBillMainSetMain");
|
if(Ds.Tables[0].Rows.Count==0)
|
{
|
sReturn = "单据未找到!";
|
return false;
|
}
|
//固定赋值===========================================
|
omodel.HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"]);
|
omodel.HModName = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HModName"]);
|
omodel.HUser = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HUser"]);
|
omodel.HTableName = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HTableName"]);
|
omodel.HDataViewName = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HDataViewName"]);
|
omodel.HDataProcName = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HDataProcName"]);
|
omodel.HMaker = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HMaker"]);
|
omodel.HMakeDate = Ds.Tables[0].Rows[0]["HMakeDate"].ToString().Trim();
|
omodel.HUpDater = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HUpDater"]);
|
omodel.HUpDateDate = Ds.Tables[0].Rows[0]["HUpDateDate"].ToString().Trim();
|
omodel.HRowElementCount = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HRowElementCount"]);
|
|
//循环
|
DataSet DsSub ;
|
DsSub = oCn.RunProcReturn("Select * from Xt_DefineBillMainSetSub Where HInterID=" + lngBillKey.ToString() + " order by HEntryID ", "Xt_DefineBillMainSetSub");
|
DetailColl.Clear();//清空
|
for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++)
|
{
|
Model.ClsXt_DefineBillMainSetSub oSub = new Model.ClsXt_DefineBillMainSetSub();
|
// 固定赋值===============================================
|
oSub.HInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HInterID"]);
|
oSub.HEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HEntryID"]);
|
oSub.HArrangeOrder = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HArrangeOrder"]);
|
oSub.HArrangeOrderSub = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HArrangeOrderSub"]);
|
oSub.HIsHide = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HIsHide"])==1?true:false;
|
oSub.HIsDisabled = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HIsDisabled"]) == 1 ? true : false;
|
oSub.HIsMust = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HIsMust"]) == 1 ? true : false;
|
oSub.HParentElementID = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HParentElementID"]);
|
oSub.HElementID = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HElementID"]);
|
oSub.HElementLabel = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HElementLabel"]);
|
oSub.HElementType = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HElementType"]);
|
oSub.HFieldMaxLength = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HFieldMaxLength"]);
|
oSub.HDefaultValue = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HDefaultValue"]);
|
oSub.HFieldName = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HFieldName"]);
|
oSub.HFieldDataType = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HFieldDataType"]);
|
oSub.HRelateUrl = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HRelateUrl"]);
|
oSub.HSubWindowBackData = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HSubWindowBackData"]);
|
oSub.HSubWindowBackDataMethodName = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HSubWindowBackDataMethodName"]);
|
oSub.HSelectContent = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HSelectContent"]);
|
DetailColl.Add(oSub);
|
}
|
sReturn = "显示单据成功!";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
throw (e);
|
}
|
}
|
#endregion
|
|
}
|
|
}
|