using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using System.Data;
|
|
namespace DAL
|
{
|
public class ClsSc_ICMrpResultBill_K3 : DBUtility.ClsXt_BaseBill
|
{
|
public Model.ClsSc_ICMrpResultBillMain_K3 omodel = new Model.ClsSc_ICMrpResultBillMain_K3();
|
//public List<Model.ClsSc_ICMrpResultBill_K3Sub> DetailColl = new List<Model.ClsSc_ICMrpResultBill_K3Sub>();
|
|
public ClsSc_ICMrpResultBill_K3()
|
{
|
base.MvarItemKeySub = "";
|
base.MvarItemKeySub2 = "";
|
base.MvarItemKeySub3 = "";
|
base.MvarItemKeySub4 = "";
|
base.MvarItemKey = "ICMrpResult";
|
base.MvarReportTitle = "计划订单";
|
base.BillType = "500";
|
}
|
|
#region 固定代码
|
|
~ClsSc_ICMrpResultBill_K3()
|
{
|
//DetailColl = 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 FInterID from ICMrpResult where FTranType='" + BillType + "' and FBillNo ='" + sBillNo + "'";
|
}
|
else
|
{
|
sSql = "Select FInterID from ICMrpResult where FTranType='" + BillType + "' and FBillNo ='" + sBillNo + "' and FInterID<>" + lngBillKey.ToString();
|
}
|
DataSet Ds;
|
Ds = oK3Cn.RunProcReturn(sSql, "ICMrpResult");
|
if (Ds.Tables[0].Rows.Count != 0)
|
{
|
sReturn = "单号重复";
|
return true;
|
}
|
sReturn = "单号未重复";
|
return false;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
return false;
|
}
|
}
|
|
//删除主表
|
public void DeleteBillMain(Int64 lngBillKey)
|
{
|
oK3Cn.RunProc("Delete From ICMrpResult where FInterID=" + 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);
|
//
|
//更新主表
|
oK3Cn.RunProc("Insert Into ICMrpResult " +
|
"(FInterID,FBillNo,FBrNo,FTranType,FCancellation" +
|
",Fstatus,FMrpClosed,FItemID,FUseUnitID,FAuxNoBatchQty" +
|
",FNeedDate,FAuxNeedQty,FPlanBeginDate,FAuxPlanQty,FItemType" +
|
",FPlanEndDate,FSourceID,FWorktypeID,FAuxPutInQty,FAuxHaveOrderQty" +
|
",FOrgSaleInterID,FOrgPPOInterID,FOrgEntyrID,FCheckDate,FSrcSaleInterID" +
|
",FSrcPPOInterID,FSrcPPBomInterID,FSrcPlanOrderInterID,FSrcICMOInterID" +
|
",FSrcReICMOInterID,FBom,FMRPDate,FRunID,FType" +
|
",FSupplyID,FUnitID,FCloseType,FMrpLockFlag,FPurchaserID" +
|
",FPlanMode,FMtoNo,FBillerId,FBillDate,FPlanCategory,FBomCategory" +
|
",FPlanOrderNo,FPlanOrderInterID" +
|
") " +
|
" values(" + lngBillKey.ToString() + ",'" + omodel.HBillNo + "','0'," + BillType + ",0" +
|
",0,0," + omodel.HMaterID.ToString() + "," + omodel.HUnitID.ToString() + "," + omodel.HAuxPlanQty.ToString() +
|
",'" + omodel.HNeedDate.ToShortDateString() + "'," + omodel.HAuxPlanQty.ToString() + ",'" + omodel.HPlanBeginDate.ToShortDateString() + "'," + omodel.HAuxPlanQty.ToString() + ",11011" +
|
",'" + omodel.HPlanEndDate.ToShortDateString() + "'," + omodel.HDeptID.ToString() + ",55," + omodel.HAuxPlanQty.ToString() + ",0" +
|
"," + omodel.HSeOrderInterID.ToString() + ",0," + omodel.HSeOrderEntryID.ToString() + ",null,0" +
|
",0,0,0,0" +
|
",0,0,'" + DBUtility.ClsPub.GetServerDate(-1) + "'," + omodel.HRunID.ToString() + ",1" +
|
",0," + omodel.HUnitID.ToString() + ",-1,0,268" +
|
",14036,'',16394,'" + omodel.HDate.ToShortDateString() + "','1','36820'" +
|
",'" + omodel.HBillNo + "'," + omodel.HInterID.ToString() + //"," + omodel.HEmpID.ToString() +
|
") ");
|
//删除关联
|
//DeleteRelation(ref sReturn, lngBillKey);
|
////删除子表
|
//DeleteBillSub(lngBillKey);
|
////插入子表
|
//omodel.HInterID = lngBillKey;
|
//foreach (Model.ClsSc_ICMrpResultBill_K3Sub oSub in DetailColl)
|
//{
|
// oK3Cn.RunProc("Insert into Sc_ICMrpResultBillSub " +
|
// " (HInterID,HEntryID,HCloseMan,HCloseType," +
|
// "HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
|
// ") values("
|
// + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + ",'" + oSub.HCloseMan + "'," + Convert.ToString(oSub.HCloseType ? 1 : 0) + ",'" + oSub.HRemark + "'" +
|
// "," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() +
|
// ") ");
|
//}
|
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 'ICMrpResult', @InterID output, 1, 16394 select ltrim(@InterID)", "GetICMaxNum");
|
omodel.HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
|
Ds = oK3Cn.RunProcReturn("select ISNULL((SELECT MAX(FInterID) FROM ICMRPInfo WHERE FType=0 And FNumber<>'APS0001'),0)", "ICMRPInfo");
|
omodel.HRunID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
|
|
//若MAINDI重复则重新获取
|
oK3Cn.BeginTran();
|
//主表
|
oK3Cn.RunProc("Insert Into ICMrpResult " +
|
"(FInterID,FBillNo,FBrNo,FTranType,FCancellation" +
|
",Fstatus,FMrpClosed,FItemID,FUseUnitID,FAuxNoBatchQty" +
|
",FNeedDate,FAuxNeedQty,FPlanBeginDate,FAuxPlanQty,FItemType" +
|
",FPlanEndDate,FSourceID,FWorktypeID,FAuxPutInQty,FAuxHaveOrderQty" +
|
",FOrgSaleInterID,FOrgPPOInterID,FOrgEntyrID,FCheckDate,FSrcSaleInterID" +
|
",FSrcPPOInterID,FSrcPPBomInterID,FSrcPlanOrderInterID,FSrcICMOInterID" +
|
",FSrcReICMOInterID,FBom,FMRPDate,FRunID,FType" +
|
",FSupplyID,FUnitID,FCloseType,FMrpLockFlag,FPurchaserID" +
|
",FPlanMode,FMtoNo,FBillerId,FBillDate,FPlanCategory,FBomCategory" +
|
",FPlanOrderNo,FPlanOrderInterID" +
|
") " +
|
" values(" + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "','0'," + BillType + ",0" +
|
",0,0," + omodel.HMaterID.ToString() + "," + omodel.HUnitID.ToString() + "," + omodel.HAuxPlanQty.ToString() +
|
",'" + omodel.HNeedDate.ToShortDateString() + "'," + omodel.HAuxPlanQty.ToString() + ",'" + omodel.HPlanBeginDate.ToShortDateString() + "'," + omodel.HAuxPlanQty.ToString() + ",11011" +
|
",'" + omodel.HPlanEndDate.ToShortDateString() + "'," + omodel.HDeptID.ToString() + ",55," + omodel.HAuxPlanQty.ToString() + ",0" +
|
"," + omodel.HSeOrderInterID.ToString() + ",0," + omodel.HSeOrderEntryID.ToString() + ",null,0" +
|
",0,0,0,0" +
|
",0,0,'" + DBUtility.ClsPub.GetServerDate(-1) + "'," + omodel.HRunID.ToString() + ",1" +
|
",0," + omodel.HUnitID.ToString() + ",-1,0,268" +
|
",14036,'',16394,'" + omodel.HDate.ToShortDateString() + "','1','36820'" +
|
",'" + omodel.HBillNo + "'," + omodel.HInterID.ToString() + //"," + omodel.HEmpID.ToString() +
|
") ");
|
////插入子表
|
//foreach (Model.ClsSc_ICMrpResultBill_K3Sub oSub in DetailColl)
|
//{
|
// oK3Cn.RunProc("Insert into Sc_ICMrpResultBillSub " +
|
// " (HInterID,HEntryID,HCloseMan,HCloseType," +
|
// "HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
|
// ") values("
|
// + omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + ",'" + oSub.HCloseMan + "'," + Convert.ToString(oSub.HCloseType ? 1 : 0) + ",'" + oSub.HRemark + "'" +
|
// "," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() +
|
// ") ");
|
//}
|
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 ICMrpResult Where FInterID=" + lngBillKey.ToString(), "ICMrpResult");
|
if (Ds.Tables[0].Rows.Count == 0)
|
{
|
sReturn = "单据未找到!";
|
return false;
|
}
|
//赋值
|
omodel.HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FInterID"]);
|
omodel.HBillNo = Ds.Tables[0].Rows[0]["FBillNo"].ToString().Trim();
|
omodel.HDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["FBillDate"]);
|
omodel.HNeedDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["FNeedDate"]);
|
//omodel.HYear = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HYear"]);
|
//omodel.HPeriod = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HPeriod"]);
|
//=================
|
//omodel.HRemark = Ds.Tables[0].Rows[0]["Fnote"].ToString().Trim();
|
//omodel.HEmpNumber = Ds.Tables[0].Rows[0]["HEmpNumber"].ToString().Trim();
|
//omodel.HCusNumber = Ds.Tables[0].Rows[0]["HCusNumber"].ToString().Trim();
|
//omodel.HDeptNumber = Ds.Tables[0].Rows[0]["HDeptNumber"].ToString().Trim();
|
//omodel.HCenterNumber = Ds.Tables[0].Rows[0]["HCenterNumber"].ToString().Trim();
|
//omodel.HMaterNumber = Ds.Tables[0].Rows[0]["HMaterNumber"].ToString().Trim();
|
//omodel.HUnitNumber = Ds.Tables[0].Rows[0]["HUnitNumber"].ToString().Trim();
|
//omodel.HBomNumber = Ds.Tables[0].Rows[0]["HBomNumber"].ToString().Trim();
|
//
|
omodel.HSeOrderBillNo = "";
|
omodel.HSeOrderInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FOrgSaleInterID"]);
|
omodel.HSeOrderEntryID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FOrgEntyrID"]);
|
//omodel.HEmpID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FPlanner"]);
|
//omodel.HCusID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FSupplyID"]);
|
omodel.HDeptID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FSourceID"]);
|
omodel.HMaterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FItemID"]);
|
omodel.HUnitID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FUnitID"]);
|
//
|
omodel.HRunID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FRunID"]);
|
omodel.HAuxPlanQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["FAuxPlanQty"]);
|
//
|
omodel.HPlanBeginDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["FPlanBeginDate"]);
|
omodel.HPlanEndDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["FPlanEndDate"]);
|
//
|
omodel.HMaker = Ds.Tables[0].Rows[0]["FBillerId"].ToString().Trim();
|
omodel.HMakeDate = Ds.Tables[0].Rows[0]["FBillDate"].ToString().Trim();
|
//omodel.HUpDateDate = Ds.Tables[0].Rows[0]["HUpDateDate"].ToString().Trim();
|
//omodel.HUpDater = Ds.Tables[0].Rows[0]["HUpDater"].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.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 Sc_ICMrpResultBillSub Where HInterID=" + lngBillKey.ToString() + " order by HEntryID ", "Sc_ICMrpResultBillSub");
|
//DetailColl.Clear();//清空
|
//for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++)
|
//{
|
// Model.ClsSc_ICMrpResultBill_K3Sub oSub = new Model.ClsSc_ICMrpResultBill_K3Sub();
|
// oSub.HInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HInterID"].ToString());
|
// oSub.HEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HEntryID"].ToString());
|
|
// //
|
// oSub.HSourceInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceInterID"].ToString());
|
// oSub.HSourceEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceEntryID"].ToString());
|
// 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"].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);
|
}
|
}
|
|
|
}
|
|
}
|