using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using System.Data;
|
|
namespace DAL
|
{
|
public class ClsPay_ApplyBill_K3 : DBUtility.ClsXt_BaseBill
|
{
|
public Model.ClsPay_ApplyBillMain_K3 omodel = new Model.ClsPay_ApplyBillMain_K3();
|
public List<Model.ClsPay_ApplyBillSub_K3> DetailColl = new List<Model.ClsPay_ApplyBillSub_K3>();
|
|
public ClsPay_ApplyBill_K3()
|
{
|
base.MvarItemKeySub = "t_rp_PayApplyBillEntry";
|
base.MvarItemKeySub2 = "";
|
base.MvarItemKeySub3 = "";
|
base.MvarItemKeySub4 = "";
|
base.MvarItemKey = "t_rp_PayApplyBill";
|
base.MvarReportTitle = "付款申请单";
|
base.BillType = "1000040";
|
}
|
|
#region 固定代码
|
|
~ClsPay_ApplyBill_K3()
|
{
|
DetailColl = null;
|
base.oCn.CnDispose();
|
base.oCn = null;
|
}
|
|
#endregion 自定义方法
|
|
//单据号是否重复
|
public bool IsExistBillNo(ref string sReturn, string sBillNo, DBUtility.ClsPub.Enum_BillStatus oBillStatus, Int64 lngBillKey)
|
{
|
try
|
{
|
string sSql = "";
|
if (oBillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew)
|
{
|
sSql = "Select FBillID from t_rp_PayApplyBill where FItemClassID='" + BillType + "' and FNumber ='" + sBillNo + "'";
|
}
|
else
|
{
|
sSql = "Select FBillID from t_rp_PayApplyBill where FItemClassID='" + BillType + "' and FNumber ='" + sBillNo + "' and FBillID<>" + lngBillKey.ToString();
|
}
|
DataSet Ds;
|
Ds = oK3Cn.RunProcReturn(sSql, "t_rp_PayApplyBill");
|
if (Ds.Tables[0].Rows.Count != 0)
|
{
|
sReturn = "单号重复";
|
return true;
|
}
|
sReturn = "单号未重复";
|
return false;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
return false;
|
}
|
}
|
|
//删除子表
|
public void DeleteBillSub(Int64 lngBillKey)
|
{
|
oK3Cn.RunProc("Delete From t_rp_PayApplyBillEntry where FBillID=" + lngBillKey.ToString());
|
}
|
//删除主表
|
public void DeleteBillMain(Int64 lngBillKey)
|
{
|
oK3Cn.RunProc("Delete From t_rp_PayApplyBill where FBillID=" + lngBillKey.ToString());
|
}
|
//删除单据
|
public bool DeleteBill(Int64 lngBillKey, ref string sReturn)
|
{
|
DataSet Ds = new DataSet();
|
try
|
{
|
oK3Cn.BeginTran();
|
//删除关联
|
//DeleteRelation(ref sReturn, lngBillKey);
|
//删除明细表
|
DeleteBillSub(lngBillKey);
|
//删除主表
|
DeleteBillMain(lngBillKey);
|
//删除关联
|
|
sReturn = "删除单据成功!";
|
oK3Cn.Commit();
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oK3Cn.RollBack();
|
return false;
|
}
|
}
|
|
//修改单据
|
public override bool ModifyBill(Int64 lngBillKey, ref string sReturn)
|
{
|
try
|
{
|
oK3Cn.BeginTran();
|
//删除主表
|
DeleteBillMain(lngBillKey);
|
//删除子表
|
DeleteBillSub(lngBillKey);
|
//
|
//更新主表
|
//oK3Cn.RunProc("Insert Into t_rp_PayApplyBill " +
|
//"(FBillID,FNumber,FBrNo,FItemClassID,FCancellation,FStatus" +
|
//",FDiscountType,Fdate,FCustID,FCustAddress,FSaleStyle,FFetchStyle,FCurrencyID" +
|
//",FFetchAdd,FCheckDate,FMangerID,FDeptID,FEmpID,FBillerID,FSettleID" +
|
//",FExchangeRateType,FExchangeRate,FMultiCheckDate1,FMultiCheckDate2" +
|
//",FMultiCheckDate3,FMultiCheckDate4,FMultiCheckDate5,FMultiCheckDate6" +
|
//",FPOOrdBillNo,FRelateBrID,FTransitAheadTime,FImport,FSelTranType" +
|
//",FBrID,FSettleDate,FExplanation,FAreaPS,FManageType,FSysStatus" +
|
//",FValidaterName,FConsignee,FVersionNo,FChangeDate,FChangeUser" +
|
//",FChangeCauses,FChangeMark,FPrintCount,FPlanCategory,FUUID" +
|
//") " +
|
//" values(" + lngBillKey.ToString() + ",'" + omodel.HBillNo + "','0'," + this.BillType + ",0,0" +
|
//",0,'" + omodel.HDate.ToShortDateString() + "'," + omodel.HCusID.ToString() + ",0,101,''," + omodel.HCurID.ToString() +
|
//",'" + omodel.HAddress + "',null," + omodel.HMangerID.ToString() + "," + omodel.HDeptID.ToString() + "," + omodel.HEmpID.ToString() + ",16394," + omodel.HSSID.ToString() +
|
//",1," + omodel.HExRate.ToString() + ",null,null" +
|
//",null,null,null,null" +
|
//",'',0,'0',0,0" +
|
//",0,'" + DBUtility.ClsPub.GetServerDate(-1) + "','" + omodel.HExplanation + "',20302,0,2" +
|
//",'',0,'000',Null,0" +
|
//",'','',0,'1',NEWID()" +
|
//") ");
|
//插入子表
|
foreach (Model.ClsPay_ApplyBillSub_K3 oSub in DetailColl)
|
{
|
//oK3Cn.RunProc("Insert into t_rp_PayApplyBillEntry " +
|
// " (FBillID,FEntryID,FBrNo,FMapNumber,FMapName,FItemID" +
|
// ",FAuxPropID,FQty,FUnitID,Fauxqty,FSecCoefficient,FSecQty" +
|
// ",Fauxprice,FAuxTaxPrice,Famount,FCess" +
|
// ",FTaxRate,FUniDiscount,FTaxAmount,FAuxPriceDiscount,FTaxAmt" +
|
// ",FAllAmount,FTranLeadTime" +
|
// ",FInForecast,FDate,Fnote,FPlanMode,FMTONo,FBOMCategory,FBomInterID" +
|
// ",FOrderBOMStatus,FCostObjectID,FAdviceConsignDate,FATPDeduct,FLockFlag" +
|
// ",FSourceBillNo,FSourceTranType,FSourceInterId,FSourceEntryID" +
|
// ",FContractBillNo,FContractInterID,FContractEntryID,FAuxQtyInvoice" +
|
// ",FSecInvoiceQty,FQtyInvoice,FSecCommitInstall,FCommitInstall" +
|
// ",FAuxCommitInstall,FAllStdAmount,FMrpLockFlag,FHaveMrp,FReceiveAmountFor_Commit" +
|
// ",FOrderBillNo,FOrderEntryID,FOrderBOMInterID" +
|
// ") values("
|
// + lngBillKey.ToString() + "," + oSub.HEntryID.ToString() + ",'0','',''," + oSub.HMaterID.ToString() +
|
// ",0," + oSub.HQty.ToString() + "," + oSub.HUnitID.ToString() + "," + oSub.HQty.ToString() + ",0,0" +
|
// "," + oSub.HPrice.ToString() + "," + oSub.HTaxPrice.ToString() + "," + oSub.HMoney.ToString() + "," + oSub.HTaxRate.ToString() +
|
// "," + oSub.HTaxRate.ToString() + ",0," + oSub.HTaxMoney.ToString() + "," + oSub.HTaxPrice.ToString() + "," + oSub.HTaxMoney.ToString() +
|
// "," + oSub.HlineTotal.ToString() + ",''" +
|
// ",0,'" + oSub.HDate.ToShortDateString() + "','" + oSub.HRemark + "',14036,'',36820,0" +
|
// ",0,'0','" + oSub.HDate.ToShortDateString() + "',0,0" +
|
// ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() +
|
// ",'',0,0,0" +
|
// ",0,0,0,0" +
|
// ",0," + oSub.HlineTotal.ToString() + ",0,0,0" +
|
// ",'','',0" +
|
// ") ");
|
}
|
sReturn = "修改单据成功!";
|
oK3Cn.Commit();
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oK3Cn.RollBack();
|
throw (e);
|
}
|
}
|
//新增单据
|
public override bool AddBill(ref string sReturn)
|
{
|
try
|
{
|
DataSet Ds;
|
//得到mainid
|
Ds = oK3Cn.RunProcReturn("declare @InterID int set @InterID=0 exec GetICMaxNum 't_rp_PayApplyBill', @InterID output, 1, 16394 select ltrim(@InterID)", "GetICMaxNum");
|
omodel.HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
|
//若MAINDI重复则重新获取
|
oK3Cn.BeginTran();
|
//主表
|
oK3Cn.RunProc("Insert Into t_rp_PayApplyBill " +
|
"(FBillID,FPayBillID_CN,FNumber,FDate,FItemClassID " +
|
",FClassTypeID,FCurrencyID,FCustomer,FExchangeRate,FAmountFor " +
|
",FExchangeRateType,FApproveAmountFor,FExplanation,FChecker " +
|
",FDepartment,FEmployee,FPreparer,FAmount,FApproveAmount " +
|
",FPayType,FSubSystemID,FRPBank,FBankAcct,FCheckDate " +
|
",FClassTypeID_CN,FConfirm_CN,FRP_CN,FBankAcctName) " +
|
") " +
|
" values(" + omodel.HInterID.ToString() + ",0,'" + omodel.HBillNo + "',getdate(),8" +
|
"," + this.BillType + "," + omodel.HCurID.ToString() + "," + omodel.HSupID.ToString() + "," + omodel.HExRate.ToString() + "," + omodel.HMoney.ToString() +
|
",1," + omodel.HMoney.ToString() + ",'" + omodel.HExplanation + "',null" +
|
"," + omodel.HDeptID.ToString() + "," + omodel.HEmpID.ToString() + ",16394," + omodel.HMoney.ToString() + "," + omodel.HMoney.ToString() +
|
",'1','0','','',NULL" +
|
",'1006001','1','1','1'" +
|
") ");
|
//插入子表
|
foreach (Model.ClsPay_ApplyBillSub_K3 oSub in DetailColl)
|
{
|
oK3Cn.RunProc("Insert into t_rp_PayApplyBillEntry " +
|
"(Findex,FBillID,FClassID_SRC,FBillNo_SRC,FContractNo "+
|
",FOrderNo,FApplyQuantity,FApplyAmountFor,FID_SRC,FEntryID_SRC "+
|
",FApplyAmount,FApproveAmountFor,FRemainAmountFor,FApproveAmount "+
|
",FRemainAmount,FOrderEntryID,FContractEntryID,FItemID,FUnitID "+
|
",FQuantity,ftaxpricefor,FAmountFor,FOrderType,FOrderInterID,FFeeObjID) " +
|
") values("
|
+ oSub.HEntryID.ToString() + "," + omodel.HInterID.ToString() + ",0,'',''" +
|
",'',0," + omodel.HMoney.ToString() + ",0,0" +
|
"," + omodel.HMoney.ToString() + "," + omodel.HMoney.ToString() + ",0," + omodel.HMoney.ToString() +
|
",0,0,0,0,0" +
|
",0,0,0,0,0,0" +
|
") ");
|
}
|
sReturn = "新增单据成功!";
|
oK3Cn.Commit();
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oK3Cn.RollBack();
|
throw (e);
|
}
|
}
|
//显示单据
|
public override bool ShowBill(Int64 lngBillKey, ref string sReturn)
|
{
|
try
|
{
|
//查询主表
|
DataSet Ds;
|
Ds = oK3Cn.RunProcReturn("Select * from t_rp_PayApplyBill Where FBillID=" + lngBillKey.ToString(), "t_rp_PayApplyBill");
|
if (Ds.Tables[0].Rows.Count == 0)
|
{
|
sReturn = "单据未找到!";
|
return false;
|
}
|
//赋值
|
//omodel.HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FBillID"]);
|
//omodel.HBillNo = Ds.Tables[0].Rows[0]["FNumber"].ToString().Trim();
|
//omodel.HDate = Convert.ToDateTime(Ds.Tables[0].Rows[0]["Fdate"].ToString().Trim());
|
//omodel.HExplanation = Ds.Tables[0].Rows[0]["FExplanation"].ToString().Trim();
|
////
|
//omodel.HCusID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FCustID"]);
|
//omodel.HCurID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FCurrencyID"]);
|
//omodel.HDeptID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FDeptID"]);
|
//omodel.HEmpID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FEmpID"]);
|
//omodel.HMangerID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FMangerID"]);
|
//omodel.HSSID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FSettleID"]);
|
////
|
//omodel.HExRate = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["FExchangeRate"]);
|
//omodel.HAddress = Ds.Tables[0].Rows[0]["FFetchAdd"].ToString().Trim();
|
////
|
//omodel.HMaker = Ds.Tables[0].Rows[0]["FBillerID"].ToString().Trim();
|
//omodel.HMakeDate = Ds.Tables[0].Rows[0]["Fdate"].ToString().Trim();
|
//omodel.HUpDater = Ds.Tables[0].Rows[0]["FOperatorID"].ToString().Trim();
|
//omodel.HUpDateDate = Ds.Tables[0].Rows[0]["FEntertime"].ToString().Trim();
|
//omodel.HBackDate = Ds.Tables[0].Rows[0]["HBackDate"].ToString().Trim();
|
//omodel.HBacker = Ds.Tables[0].Rows[0]["HBacker"].ToString().Trim();
|
//omodel.HChecker = Ds.Tables[0].Rows[0]["FCheckerID"].ToString().Trim();
|
//omodel.HCheckDate = Ds.Tables[0].Rows[0]["FCheckDate"].ToString().Trim();
|
//omodel.HCloseDate = Ds.Tables[0].Rows[0]["HCloseDate"].ToString().Trim();
|
//omodel.HCloseMan = Ds.Tables[0].Rows[0]["HCloseMan"].ToString().Trim();
|
//omodel.HDeleteDate = Ds.Tables[0].Rows[0]["HDeleteDate"].ToString().Trim();
|
//omodel.HDeleteMan = Ds.Tables[0].Rows[0]["HDeleteMan"].ToString().Trim();
|
//循环
|
DataSet DsSub;
|
DsSub = oK3Cn.RunProcReturn("Select * from t_rp_PayApplyBillEntry Where FBillID=" + lngBillKey.ToString() + " order by HEntryID ", "t_rp_PayApplyBillEntry");
|
DetailColl.Clear();//清空
|
for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++)
|
{
|
Model.ClsPay_ApplyBillSub_K3 oSub = new Model.ClsPay_ApplyBillSub_K3();
|
//oSub.HInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["FBillID"].ToString());
|
//oSub.HEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["FEntryID"].ToString());
|
//oSub.HMaterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["FItemID"].ToString());
|
//oSub.HUnitID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["FUnitID"].ToString());
|
|
//oSub.HQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["Fauxqty"].ToString());
|
//oSub.HPrice = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["Fauxprice"].ToString());
|
//oSub.HTaxPrice = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["FAuxTaxPrice"].ToString());
|
//oSub.HMoney = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["Famount"].ToString());
|
//oSub.HTaxRate = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["FCess"].ToString());
|
//oSub.HTaxMoney = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["FTaxAmount"].ToString());
|
//oSub.HlineTotal = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["FAllAmount"].ToString());
|
|
////oSub.HCloseMan = DsSub.Tables[0].Rows[i]["HCloseMan"].ToString().Trim();
|
////oSub.HCloseType = (bool)DsSub.Tables[0].Rows[i]["HCloseType"];
|
//oSub.HDate = Convert.ToDateTime(DsSub.Tables[0].Rows[i]["FDate"].ToString().Trim());
|
//oSub.HRemark = DsSub.Tables[0].Rows[i]["Fnote"].ToString().Trim();
|
////
|
//oSub.HSourceInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["FSourceInterID"].ToString());
|
//oSub.HSourceEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["FSourceEntryID"].ToString());
|
//oSub.HSourceBillType = DsSub.Tables[0].Rows[i]["FSourceTranType"].ToString().Trim();
|
//oSub.HSourceBillNo = DsSub.Tables[0].Rows[i]["FSourceBillNo"].ToString().Trim();
|
//oSub.HRelationQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HRelationQty"].ToString());
|
//oSub.HRelationMoney = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HRelationMoney"].ToString());
|
DetailColl.Add(oSub);
|
}
|
sReturn = "显示单据成功!";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
throw (e);
|
}
|
}
|
|
|
|
|
|
}
|
|
}
|