using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using System.Data;
|
|
namespace DAL
|
{
|
public class ClsSup_AskPriceBill:DBUtility.ClsXt_BaseBill
|
{
|
public Model.ClsSup_AskPriceBillMain omodel = new Model.ClsSup_AskPriceBillMain();
|
public List<Model.ClsSup_AskPriceBillSub> DetailColl = new List<Model.ClsSup_AskPriceBillSub>();
|
public List<Model.ClsSup_AskPriceBillSub_Sup> DetailEmpColl = new List<Model.ClsSup_AskPriceBillSub_Sup>();
|
|
public ClsSup_AskPriceBill()
|
{
|
base.MvarItemKeyForWeb = "h_v_Sup_AskPriceBillMain_ForWeb";
|
base.MvarItemKeySubForWeb = "h_v_Sup_AskPriceBillSub_ForWeb";
|
base.MvarItemKeySub = "Sup_AskPriceBillSub";
|
base.MvarItemKeySub2 = "Sup_AskPriceBillSub_Sup";
|
base.MvarItemKeySub3 = "";
|
base.MvarItemKeySub4 = "";
|
base.MvarItemKey="Sup_AskPriceBillMain";
|
base.MvarReportTitle="供应商询价单";
|
base.BillType= "1120";
|
base.HBillSubType = "1120";
|
|
}
|
|
#region 固定代码
|
|
~ClsSup_AskPriceBill()
|
{
|
DetailColl = null;
|
}
|
|
#endregion 自定义方法
|
//修改单据
|
public override bool ModifyBill(Int64 lngBillKey, ref string sReturn)
|
{
|
try
|
{
|
//
|
oCn.BeginTran();
|
//更新主表
|
oCn.RunProc("UpDate Sup_AskPriceBillMain set " +
|
" HBillNo='" + omodel.HBillNo + "'" + //固定赋值===============
|
",HDate='" + omodel.HDate + "'" +
|
",HYear='" + omodel.HYear.ToString() + "'" +
|
",HPeriod='" + omodel.HPeriod.ToString() + "'" +
|
",HRemark='" + omodel.HRemark + "'" +
|
",HUpDater='" + DBUtility.ClsPub.CurUserName + "'" +
|
",HUpDateDate=getdate()" +
|
//========================================
|
",HProcType='" + omodel.HProcType + "'" +
|
",HEmpID=" + omodel.HEmpID.ToString() +
|
",HDeptID=" + omodel.HDeptID.ToString() +
|
",HBeginDate='" + omodel.HBeginDate + "'" +
|
",HEndDate='" + omodel.HEndDate + "'" +
|
",HPayConditionID=" + omodel.HPayConditionID.ToString() +
|
",HCurID=" + omodel.HCurID.ToString() +
|
",HExplanation='" + omodel.HExplanation + "'" +
|
",HInnerBillNo='" + omodel.HInnerBillNo + "'" +
|
|
" where HInterID=" + lngBillKey.ToString());
|
//删除关联
|
DeleteRelation(ref sReturn, lngBillKey);
|
//删除子表
|
DeleteBillSub(lngBillKey);
|
DeleteBillSub2(lngBillKey);
|
//插入子表
|
omodel.HInterID = lngBillKey;
|
foreach (Model.ClsSup_AskPriceBillSub oSub in DetailColl)
|
{
|
oCn.RunProc("Insert into Sup_AskPriceBillSub " +
|
" (HInterID,HEntryID,HRemark" +
|
",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
|
",HMaterID,HUnitID,HQty" +
|
",HDate,HBagType,HCarryType,HAddress" +
|
") values("
|
+ omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + ",'" + oSub.HRemark + "'" +
|
"," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() +
|
"," + oSub.HMaterID.ToString() + "," + oSub.HUnitID.ToString() + "," + oSub.HQty.ToString() +
|
",'" + oSub.HDate + "','" + oSub.HBagType + "','" + oSub.HCarryType + "','" + oSub.HAddress + "'" +
|
") ");
|
}
|
//
|
//插入子表2
|
foreach (Model.ClsSup_AskPriceBillSub_Sup oSubSec in DetailEmpColl)
|
{
|
oCn.RunProc("Insert into Sup_AskPriceBillSub_Sup " +
|
" (HInterID,HEntryID,HSupID" +
|
",HMaterID,HFlag,HRemark,HCloseMan,HCloseType,HRelationQty" +
|
")" +
|
" values("
|
+ omodel.HInterID.ToString() + "," + oSubSec.HEntryID.ToString() + "," + oSubSec.HSupID.ToString() +
|
"," + oSubSec.HMaterID.ToString() + ", " + DBUtility.ClsPub.BoolToString(oSubSec.HFlag) + ",'" + oSubSec.HRemark + "'" +
|
",'" + oSubSec.HCloseMan + "', " + DBUtility.ClsPub.BoolToString(oSubSec.HCloseType) + "," + oSubSec.HRelationQty.ToString() +
|
") ");
|
}
|
//foreach (Model.ClsSup_AskPriceBillSub oSub in DetailColl)
|
//{
|
// Ds = oCn.RunProcReturn("exec h_p_Sup_AskPriceBill_Qty " + oSub.HICMOInterID, "");
|
// if (Ds.Tables[0].Rows.Count == 0)
|
// return;
|
// if (DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBool"]) == "Y")
|
// {
|
// sReturn = "汇报数量超过计划数量!不允许保存";
|
// return false;
|
// }
|
//}
|
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();
|
//主表
|
oCn.RunProc("Insert Into Sup_AskPriceBillMain " +
|
"(HBillType,HBillSubType,HInterID,HBillNo,HDate" +
|
",HYear,HPeriod,HRemark,HMaker,HMakeDate" +
|
",HProcType,HEmpID,HDeptID,HBeginDate" +
|
",HEndDate,HPayConditionID,HCurID" +
|
",HExplanation,HInnerBillNo" +
|
") " +
|
" values('" + this.BillType + "','" + this.HBillSubType + "'," +omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "','" + omodel.HDate + "'" +
|
", " + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HRemark + "','" + omodel.HMaker + "','" + omodel.HMakeDate +
|
"','" + omodel.HProcType + "'," + omodel.HEmpID.ToString() + "," + omodel.HDeptID.ToString() + ",'" + omodel.HBeginDate + "'" +
|
",'" + omodel.HEndDate + "'," + omodel.HPayConditionID.ToString() + "," + omodel.HCurID.ToString() +
|
",'" + omodel.HExplanation + "','" + omodel.HInnerBillNo + "'" +
|
") ");
|
//
|
//插入子表
|
foreach (Model.ClsSup_AskPriceBillSub oSub in DetailColl)
|
{
|
oCn.RunProc("Insert into Sup_AskPriceBillSub " +
|
" (HInterID,HEntryID,HRemark" +
|
",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
|
",HMaterID,HUnitID,HQty" +
|
",HDate,HBagType,HCarryType,HAddress" +
|
") values("
|
+ omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + ",'" + oSub.HRemark + "'" +
|
"," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() +
|
"," + oSub.HMaterID.ToString() + "," + oSub.HUnitID.ToString() + "," + oSub.HQty.ToString() +
|
",'" + oSub.HDate + "','" + oSub.HBagType + "','" + oSub.HCarryType + "','" + oSub.HAddress + "'" +
|
") ");
|
}
|
//
|
//插入子表2
|
foreach (Model.ClsSup_AskPriceBillSub_Sup oSubSec in DetailEmpColl)
|
{
|
oCn.RunProc("Insert into Sup_AskPriceBillSub_Sup " +
|
" (HInterID,HEntryID,HSupID" +
|
",HMaterID,HFlag,HRemark,HCloseMan,HCloseType,HRelationQty" +
|
")" +
|
" values("
|
+ omodel.HInterID.ToString() + "," + oSubSec.HEntryID.ToString() + "," + oSubSec.HSupID.ToString() +
|
"," + oSubSec.HMaterID.ToString() + ", " + DBUtility.ClsPub.BoolToString(oSubSec.HFlag) + ",'" + oSubSec.HRemark + "'" +
|
",'" + oSubSec.HCloseMan + "', " + DBUtility.ClsPub.BoolToString(oSubSec.HCloseType) + "," + oSubSec.HRelationQty.ToString() +
|
") ");
|
}
|
//
|
//foreach (Model.ClsSup_AskPriceBillSub oSub in DetailColl)
|
//{
|
// Ds = oCn.RunProcReturn("exec h_p_Sup_AskPriceBill_Qty " + oSub.HICMOInterID, "");
|
// if (Ds.Tables[0].Rows.Count == 0)
|
// return;
|
// if (DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBool"]) == "Y")
|
// {
|
// sReturn = "汇报数量超过计划数量!不允许保存";
|
// return false;
|
// }
|
//}
|
//
|
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 Ds ;
|
Ds = oCn.RunProcReturn("Select * from Sup_AskPriceBillMain Where HInterID=" + lngBillKey.ToString(), "Sup_AskPriceBillMain");
|
if(Ds.Tables[0].Rows.Count==0)
|
{
|
sReturn = "单据未找到!";
|
return false;
|
}
|
//固定赋值===========================================
|
omodel.HYear = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HYear"]);
|
omodel.HPeriod = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HPeriod"]);
|
omodel.HBillType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBillType"]);
|
omodel.HBillSubType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBillSubType"]);
|
omodel.HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"]);
|
omodel.HDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HDate"]);
|
omodel.HBillNo = Ds.Tables[0].Rows[0]["HBillNo"].ToString().Trim();
|
omodel.HBillStatus = DBUtility.ClsPub.isInt(Ds.Tables[0].Rows[0]["HBillStatus"]);
|
omodel.HCheckItemNowID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCheckItemNowID"]);
|
omodel.HCheckItemNextID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCheckItemNextID"]);
|
omodel.HCheckFlowID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCheckFlowID"]);
|
omodel.HRemark = Ds.Tables[0].Rows[0]["HRemark"].ToString().Trim();
|
omodel.HBackDate = Ds.Tables[0].Rows[0]["HBackDate"].ToString().Trim();
|
omodel.HBacker = Ds.Tables[0].Rows[0]["HBacker"].ToString().Trim();
|
omodel.HCheckDate = Ds.Tables[0].Rows[0]["HCheckDate"].ToString().Trim();
|
omodel.HChecker = Ds.Tables[0].Rows[0]["HChecker"].ToString().Trim();
|
omodel.HMaker = Ds.Tables[0].Rows[0]["HMaker"].ToString().Trim();
|
omodel.HMakeDate = Ds.Tables[0].Rows[0]["HMakeDate"].ToString().Trim();
|
omodel.HUpDateDate = Ds.Tables[0].Rows[0]["HUpDateDate"].ToString().Trim();
|
omodel.HUpDater = Ds.Tables[0].Rows[0]["HUpDater"].ToString().Trim();
|
omodel.HCloseDate = Ds.Tables[0].Rows[0]["HCloseDate"].ToString().Trim();
|
omodel.HCloseMan = Ds.Tables[0].Rows[0]["HCloseMan"].ToString().Trim();
|
omodel.HCloseType = DBUtility.ClsPub.isBool(Ds.Tables[0].Rows[0]["HCloseType"]);
|
omodel.HDeleteDate = Ds.Tables[0].Rows[0]["HDeleteDate"].ToString().Trim();
|
omodel.HDeleteMan = Ds.Tables[0].Rows[0]["HDeleteMan"].ToString().Trim();
|
//========================================================
|
|
|
omodel.HProcType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HProcType"]);
|
omodel.HEmpID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HEmpID"]);
|
omodel.HDeptID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HDeptID"]);
|
omodel.HBeginDate = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBeginDate"]);
|
omodel.HEndDate = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HEndDate"]);
|
omodel.HPayConditionID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HPayConditionID"]);
|
omodel.HCurID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCurID"]);
|
omodel.HExplanation = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HExplanation"]);
|
omodel.HInnerBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HInnerBillNo"]);
|
//
|
|
//循环
|
DataSet DsSub ;
|
DsSub = oCn.RunProcReturn("Select * from Sup_AskPriceBillSub Where HInterID=" + lngBillKey.ToString() + " order by HEntryID ", "Sup_AskPriceBillSub");
|
DetailColl.Clear();//清空
|
for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++)
|
{
|
Model.ClsSup_AskPriceBillSub oSub = new Model.ClsSup_AskPriceBillSub();
|
// 固定赋值===============================================
|
oSub.HInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HInterID"]);
|
oSub.HEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HEntryID"]);
|
oSub.HSourceInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceInterID"]);
|
oSub.HSourceEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceEntryID"]);
|
oSub.HSourceBillType = DsSub.Tables[0].Rows[i]["HSourceBillType"].ToString().Trim();
|
oSub.HSourceBillNo = DsSub.Tables[0].Rows[i]["HSourceBillNo"].ToString().Trim();
|
oSub.HRelationQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HRelationQty"]);
|
oSub.HRelationMoney = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HRelationMoney"]);
|
oSub.HCloseMan = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HCloseMan"]);
|
oSub.HCloseType = DBUtility.ClsPub.isBool(DsSub.Tables[0].Rows[i]["HCloseType"]);
|
oSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[i]["HEntryCloseDate"]);
|
oSub.HRemark = DsSub.Tables[0].Rows[i]["HRemark"].ToString().Trim();
|
//===================================================
|
oSub.HMaterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HMaterID"]);
|
oSub.HUnitID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HUnitID"]);
|
oSub.HQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["HQty"]);
|
oSub.HDate = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[0]["HDate"]);
|
oSub.HBagType = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[0]["HBagType"]);
|
oSub.HCarryType = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[0]["HCarryType"]);
|
oSub.HAddress = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[0]["HAddress"]);
|
|
DetailColl.Add(oSub);
|
}
|
//循环子表2
|
DataSet DsSubSec = new DataSet();
|
DsSubSec = oCn.RunProcReturn("Select * from Sup_AskPriceBillSub_Sup Where HInterID=" + lngBillKey.ToString() + " order by HEntryID ", "Sup_AskPriceBillMain");
|
DetailEmpColl.Clear();//清空
|
for (int i = 0; i < DsSubSec.Tables[0].Rows.Count; i++)
|
{
|
Model.ClsSup_AskPriceBillSub_Sup oSubSec = new Model.ClsSup_AskPriceBillSub_Sup();
|
// 固定赋值===============================================
|
oSubSec.HInterID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HInterID"]);
|
oSubSec.HEntryID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HEntryID"]);
|
oSubSec.HSourceInterID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HSourceInterID"]);
|
oSubSec.HSourceEntryID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HSourceEntryID"]);
|
oSubSec.HSourceBillType = DsSubSec.Tables[0].Rows[i]["HSourceBillType"].ToString().Trim();
|
oSubSec.HSourceBillNo = DsSubSec.Tables[0].Rows[i]["HSourceBillNo"].ToString().Trim();
|
oSubSec.HRelationQty = DBUtility.ClsPub.isDoule(DsSubSec.Tables[0].Rows[i]["HRelationQty"]);
|
oSubSec.HRelationMoney = DBUtility.ClsPub.isDoule(DsSubSec.Tables[0].Rows[i]["HRelationMoney"]);
|
oSubSec.HCloseMan = DBUtility.ClsPub.isStrNull(DsSubSec.Tables[0].Rows[i]["HCloseMan"]);
|
oSubSec.HCloseType = DBUtility.ClsPub.isBool(DsSubSec.Tables[0].Rows[i]["HCloseType"]);
|
oSubSec.HEntryCloseDate = DBUtility.ClsPub.isDate(DsSubSec.Tables[0].Rows[i]["HEntryCloseDate"]);
|
oSubSec.HRemark = DsSubSec.Tables[0].Rows[i]["HRemark"].ToString().Trim();
|
//===================================================
|
oSubSec.HSupID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HSupID"]);
|
oSubSec.HMaterID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HMaterID"]);
|
oSubSec.HFlag = DBUtility.ClsPub.isBool(DsSubSec.Tables[0].Rows[i]["HFlag"]);
|
|
|
//
|
DetailEmpColl.Add(oSubSec);
|
}
|
sReturn = "显示单据成功!";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
throw (e);
|
}
|
}
|
|
|
}
|
|
}
|