using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using System.Data;
|
|
namespace DAL
|
{
|
public class ClsPay_OtherMoney:DBUtility.ClsXt_BaseBill
|
{
|
public Model.ClsPay_OtherMoneyMain omodel = new Model.ClsPay_OtherMoneyMain();
|
public List<Model.ClsPay_OtherMoneySub> DetailColl = new List<Model.ClsPay_OtherMoneySub>();
|
|
public ClsPay_OtherMoney()
|
{
|
base.MvarItemKeySub = "Pay_OtherMoney";
|
base.MvarItemKeySub2 = "";
|
base.MvarItemKeySub3 = "";
|
base.MvarItemKeySub4 = "";
|
base.MvarItemKey = "Pay_OtherMoney";
|
base.MvarReportTitle = "补扣明细";
|
base.BillType = "99999";
|
base.HBillSubType = "99999";
|
|
}
|
|
#region 固定代码
|
|
~ClsPay_OtherMoney()
|
{
|
DetailColl = null;
|
}
|
|
#endregion 自定义方法
|
//修改单据
|
public override bool ModifyBill(Int64 lngBillKey, ref string sReturn)
|
{
|
try
|
{
|
//
|
oCn.BeginTran();
|
//更新主表
|
//删除关联
|
DeleteRelation(ref sReturn, lngBillKey);
|
//删除子表
|
DeleteBillSub(lngBillKey);
|
//插入子表
|
omodel.HInterID = lngBillKey;
|
foreach (Model.ClsPay_OtherMoneySub oSub in DetailColl)
|
{
|
oCn.RunProc("Insert into Pay_OtherMoney " +
|
" (HInterID,HItemID,HMoney,HType,HRemark" +
|
") values("
|
+ omodel.HInterID.ToString() + "," + oSub.HItemID.ToString() + "," + oSub.HMoney.ToString() + ",'" + oSub.HType + "','" + oSub.HRemark + "'" +
|
") ");
|
}
|
|
sReturn = "修改单据成功!";
|
oCn.Commit();
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
//新增单据
|
public override bool AddBill(ref string sReturn)
|
{
|
try
|
{
|
//得到mainid
|
omodel.HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo);
|
//若MAINDI重复则重新获取
|
oCn.BeginTran();
|
//主表
|
//插入子表
|
foreach (Model.ClsPay_OtherMoneySub oSub in DetailColl)
|
{
|
oCn.RunProc("Insert into Pay_OtherMoney " +
|
" (HInterID,HItemID,HMoney,HType,HRemark" +
|
") values("
|
+ omodel.HInterID.ToString() + "," + oSub.HItemID.ToString() + "," + oSub.HMoney.ToString() + ",'" + oSub.HType + "','" + oSub.HRemark + "'" +
|
") ");
|
}
|
sReturn = "新增单据成功!";
|
oCn.Commit();
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
//显示单据
|
public override bool ShowBill(Int64 lngBillKey, ref string sReturn)
|
{
|
try
|
{
|
//查询主表
|
|
//循环
|
DataSet DsSub ;
|
DsSub = oCn.RunProcReturn("Select * from Pay_OtherMoney Where HInterID=" + lngBillKey.ToString(), "Pay_OtherMoney");
|
if (DsSub == null || DsSub.Tables[0].Rows.Count == 0)
|
{
|
return false;
|
}
|
DetailColl.Clear();//清空
|
for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++)
|
{
|
Model.ClsPay_OtherMoneySub oSub = new Model.ClsPay_OtherMoneySub();
|
// 固定赋值===============================================
|
oSub.HInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HInterID"]);
|
//===================================================
|
oSub.HItemID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HItemID"]);
|
oSub.HMoney = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HMoney"]);
|
oSub.HType = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HType"]);
|
oSub.HRemark = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HRemark"]);
|
DetailColl.Add(oSub);
|
}
|
sReturn = "显示单据成功!";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
throw (e);
|
}
|
}
|
|
|
}
|
|
}
|