using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using System.Data;
|
|
namespace DAL
|
{
|
/// <summary>
|
/// 创建人:wangjj
|
/// 时间:2018-01-05 15:11:37
|
/// 说明:模具采购合同的DAL
|
///
|
/// </summary>
|
public class ClsSc_MouldPOContractBill:DBUtility.ClsXt_BaseBill
|
{
|
|
public Model.ClsSc_MouldPOContractBillMain omodel = new Model.ClsSc_MouldPOContractBillMain();
|
public List<Model.ClsSc_MouldPOContractBillSub> DetailColl = new List<Model.ClsSc_MouldPOContractBillSub>();
|
// public List<Model.ClsSc_MouldPOContractBillSub2> DetailEmpColl = new List<Model.ClsSc_MouldPOContractBillSub2>();
|
|
public ClsSc_MouldPOContractBill()
|
{
|
base.MvarItemKeySub = "Sc_MouldPOContractBillSub";
|
//base.MvarItemKeySub2 = "Sc_MouldPOContractBillSub2";
|
base.MvarItemKeySub3 = "";
|
base.MvarItemKeySub4 = "";
|
base.MvarItemKey="Sc_MouldPOContractBillMain";
|
base.MvarReportTitle="模具采购合同";
|
base.BillType = "3836";
|
base.HBillSubType = "3836";
|
}
|
|
#region 析构函数,销毁对象
|
|
~ClsSc_MouldPOContractBill()
|
{
|
DetailColl = null;
|
}
|
|
#endregion 自定义方法
|
//修改单据
|
public override bool ModifyBill(Int64 lngBillKey, ref string sReturn)
|
{
|
try
|
{
|
//
|
oCn.BeginTran();
|
//更新主表
|
string ssql = "UpDate Sc_MouldPOContractBillMain set " +
|
" HBillNo='" + omodel.HBillNo + "'" + //固定赋值===============
|
",HDate='" + omodel.HDate + "'" +
|
",HYear='" + omodel.HYear + "'" +
|
",HPeriod='" + omodel.HPeriod + "'" +
|
",HRemark='" + omodel.HRemark + "'" +
|
",HUpDater='" + DBUtility.ClsPub.CurUserName + "'" +
|
",HUpDateDate=getdate()" +
|
//========================================
|
",HContractName='" + omodel.HContractName + "'" +
|
",HDeptID='" + omodel.HDeptID + "'" +
|
",HEmpID='" + omodel.HEmpID + "'" +
|
",HSupID='" + omodel.HSupID + "'" +
|
",HCurID='" + omodel.HCurID + "'" +
|
",HPlanEndDate='" + omodel.HPlanEndDate + "'" +
|
",HAnalyse='" + omodel.HAnalyse + "'" +
|
",HKeyAolve='" + omodel.HKeyAolve + "'" +
|
",HPlanResult='" + omodel.HPlanResult + "'" +
|
",HAdvice='" + omodel.HAdvice + "'" +
|
",HMouldNo='" + omodel.HMouldNo + "'" +
|
",HName='" + omodel.HName + "'" +
|
",HModel='" + omodel.HModel + "'" +
|
",HModel2='" + omodel.HModel2 + "'" +
|
",HQty='" + omodel.HQty + "'" +
|
",HPrice='" + omodel.HPrice + "'" +
|
",HDesignLife='" + omodel.HDesignLife + "'" +
|
",HExplanation='" + omodel.HExplanation + "'" +
|
",HInnerBillNo='" + omodel.HInnerBillNo + "'" +
|
" where HInterID='" + lngBillKey.ToString() + "'";
|
oCn.RunProc(ssql);
|
|
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);
|
|
string ssql = "Insert Into Sc_MouldPOContractBillMain " +
|
"(HYear,HPeriod,HBillType,HBillSubType,HInterID,HDate,HBillNo,HBillStatus," +
|
"HCheckItemNowID,HCheckItemNextID,HCheckFlowID,HRemark,HBackRemark," +
|
"HMaker,HMakeDate,HMainSourceBillType,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HPrintQty," +
|
//自定义
|
"HContractName,HDeptID,HEmpID,HSupID,HCurID ,HPlanEndDate,HAnalyse,HKeyAolve," +
|
"HPlanResult,HAdvice,HMouldNo,HName,HModel,HModel2,HQty,HPrice,HMoney,HDesignLife,HExplanation,HInnerBillNo" +
|
") " +
|
" values('" + omodel.HYear + "','" + omodel.HPeriod + "','" + this.BillType + "','" + this.HBillSubType +
|
"','" + omodel.HInterID + "','" + omodel.HDate + "','" + omodel.HBillNo + "','" + omodel.HBillStatus +
|
"','" + omodel.HCheckItemNowID + "','" + omodel.HCheckItemNextID + "','" + omodel.HCheckFlowID +
|
"','" + omodel.HRemark + "','" + omodel.HBackRemark + "','" + omodel.HMaker + "','" + omodel.HMakeDate + "','" + omodel.HMainSourceBillType + "','" + omodel.HMainSourceInterID +
|
"','" + omodel.HMainSourceEntryID + "','" + omodel.HMainSourceBillNo + "','" + omodel.HPrintQty +
|
//自定义
|
"','" + omodel.HContractName + "','" + omodel.HDeptID +
|
"','" + omodel.HEmpID + "','" + omodel.HSupID + "','" + omodel.HCurID + "','" + omodel.HPlanEndDate + "','" + omodel.HAnalyse +
|
"','" + omodel.HKeyAolve + "','" + omodel.HPlanResult + "','" + omodel.HAdvice + "','" + omodel.HMouldNo +
|
"','" + omodel.HName + "','" + omodel.HModel + "','" + omodel.HModel2 + "','" + omodel.HQty +
|
"','" + omodel.HPrice + "','" + omodel.HMoney + "','" + omodel.HDesignLife + "','" + omodel.HExplanation + "','" + omodel.HInnerBillNo +
|
"') ";
|
//若MAINDI重复则重新获取
|
oCn.BeginTran();
|
//主表
|
oCn.RunProc(ssql);
|
|
//
|
//插入子表
|
//foreach (Model.ClsSc_MouldPOContractBillSub oSub in DetailColl)
|
//{
|
// oCn.RunProc("Insert into Sc_MouldPOContractBillSub " +
|
// " (HInterID,HEntryID,HRemark" +
|
// ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
|
// ") 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() +
|
// ") ");
|
//}
|
//
|
//插入子表2
|
//foreach (Model.ClsSc_MouldPOContractBillSub2 oSubSec in DetailEmpColl)
|
//{
|
// oCn.RunProc("Insert into Sc_MouldPOContractBillSub2 " +
|
// " (HInterID,HEntryID,HRemark" +
|
// ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
|
// ")" +
|
// " values("
|
// + omodel.HInterID.ToString() + "," + oSubSec.HEntryID.ToString() + ",'" + oSubSec.HRemark + "'" +
|
// "," + oSubSec.HSourceInterID.ToString() + "," + oSubSec.HSourceEntryID.ToString() + ",'" + oSubSec.HSourceBillNo + "','" + oSubSec.HSourceBillType + "'," + oSubSec.HRelationQty.ToString() + "," + oSubSec.HRelationMoney.ToString() +
|
// ") ");
|
//}
|
//
|
//foreach (Model.ClsSc_MouldPOContractBillSub oSub in DetailColl)
|
//{
|
// Ds = oCn.RunProcReturn("exec h_p_Sc_MouldPOContractBill_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 Sc_MouldPOContractBillMain Where HInterID=" + lngBillKey.ToString(), "Sc_MouldPOContractBillMain");
|
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.HContractName = Ds.Tables[0].Rows[0]["HContractName"].ToString().Trim();
|
omodel.HDeptID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HDeptID"]);
|
omodel.HEmpID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HEmpID"]);
|
omodel.HSupID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSupID"]);
|
omodel.HCurID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HCurID"]);
|
omodel.HPlanEndDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HPlanEndDate"]);
|
omodel.HAnalyse = Ds.Tables[0].Rows[0]["HAnalyse"].ToString().Trim();
|
omodel.HKeyAolve = Ds.Tables[0].Rows[0]["HKeyAolve"].ToString().Trim();
|
omodel.HPlanResult = Ds.Tables[0].Rows[0]["HPlanResult"].ToString().Trim();
|
omodel.HAdvice = Ds.Tables[0].Rows[0]["HAdvice"].ToString().Trim();
|
omodel.HMouldNo = Ds.Tables[0].Rows[0]["HMouldNo"].ToString().Trim();
|
omodel.HName = Ds.Tables[0].Rows[0]["HName"].ToString().Trim();
|
omodel.HModel = Ds.Tables[0].Rows[0]["HModel"].ToString().Trim();
|
omodel.HModel2 = Ds.Tables[0].Rows[0]["HModel"].ToString().Trim();
|
omodel.HQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HQty"]);
|
omodel.HPrice = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HPrice"]);
|
omodel.HMoney = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HMoney"]);
|
omodel.HDesignLife = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HDesignLife"]);
|
omodel.HExplanation = Ds.Tables[0].Rows[0]["HExplanation"].ToString().Trim();
|
omodel.HInnerBillNo = Ds.Tables[0].Rows[0]["HInnerBillNo"].ToString().Trim();
|
|
//
|
|
//循环
|
//DataSet DsSub ;
|
//DsSub = oCn.RunProcReturn("Select * from Sc_MouldPOContractBillSub Where HInterID=" + lngBillKey.ToString() + " order by HEntryID ", "Sc_MouldPOContractBillSub");
|
//DetailColl.Clear();//清空
|
//for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++)
|
//{
|
// Model.ClsSc_MouldPOContractBillSub oSub = new Model.ClsSc_MouldPOContractBillSub();
|
// // 固定赋值===============================================
|
// 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();
|
// //===================================================
|
//DetailColl.Add(oSub);
|
//}
|
//循环子表2
|
//DataSet DsSubSec = new DataSet();
|
//DsSubSec = oCn.RunProcReturn("Select * from Sc_MouldPOContractBillSub2 Where HInterID=" + lngBillKey.ToString() + " order by HEntryID ", "Sc_MouldPOContractBillMain");
|
//DetailEmpColl.Clear();//清空
|
//for (int i = 0; i < DsSubSec.Tables[0].Rows.Count; i++)
|
//{
|
// Model.ClsSc_MouldPOContractBillSub2 oSubSec = new Model.ClsSc_MouldPOContractBillSub2();
|
// // 固定赋值===============================================
|
// 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();
|
// //===================================================
|
// //
|
//DetailEmpColl.Add(oSubSec);
|
//}
|
sReturn = "显示单据成功!";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
throw (e);
|
}
|
}
|
|
public bool GetByID(int HMaterID)
|
{
|
DataSet DS;
|
try
|
{
|
DS = oCn.RunProcReturn("Select * from " + MvarItemKey + " Where HInterID='" + HMaterID + "'", MvarItemKey, ref DBUtility.ClsPub.sExeReturnInfo);
|
if (DS.Tables[0].Rows.Count == 0)
|
return false;
|
else
|
{
|
return GetInfo(DS);
|
}
|
}
|
catch (Exception e)
|
{
|
throw (e);
|
}
|
}
|
|
//返回项目信息
|
public bool GetInfo(DataSet Ds)
|
{
|
try
|
{
|
omodel = new Model.ClsSc_MouldPOContractBillMain();
|
//omodel.HMaterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HMaterID"]);
|
//omodel.HInitModel = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HInitModel"]);
|
//omodel.HSupNumber = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HSupNumber"]);
|
//omodel.HMaterNumber = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HMaterNumber"]);
|
// omodel.HBarCode = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBarCode"]);
|
return true;
|
|
}
|
catch (Exception e)
|
{
|
throw (e);
|
}
|
}
|
|
|
}
|
|
}
|