using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using System.Data;
|
|
namespace DAL
|
{
|
public class ClsGy_SOPBill:DBUtility.ClsXt_BaseBill
|
{
|
public Model.ClsGy_SOPBillMain omodel = new Model.ClsGy_SOPBillMain();
|
public List<Model.ClsGy_SOPBillSub> DetailColl = new List<Model.ClsGy_SOPBillSub>();
|
|
public ClsGy_SOPBill()
|
{
|
base.MvarItemKeySub = "Gy_SOPBillSub";
|
base.MvarItemKeySub2 = "";
|
base.MvarItemKeySub3 = "";
|
base.MvarItemKeySub4 = "";
|
base.MvarItemKey="Gy_SOPBillMain";
|
base.MvarReportTitle="作业指导书";
|
base.BillType="3305";
|
}
|
|
#region 固定代码
|
|
~ClsGy_SOPBill()
|
{
|
DetailColl = null;
|
}
|
|
#endregion 自定义方法
|
//修改单据
|
public override bool ModifyBill(Int64 lngBillKey, ref string sReturn)
|
{
|
try
|
{
|
//
|
oCn.BeginTran();
|
//更新主表
|
oCn.RunProc("UpDate Gy_SOPBillMain set " +
|
" HName='" + omodel.HName + "'" +
|
",HBillNo='" + omodel.HBillNo + "'" +
|
",HMaterTypeID=" + omodel.HMaterTypeID.ToString() +
|
",HMaterID=" + omodel.HMaterID.ToString() +
|
",HMaterNumber='" + omodel.HMaterNumber + "'" +
|
",HUnitID=" + omodel.HUnitID.ToString() +
|
",HUnitNumber='" + omodel.HUnitNumber + "'" +
|
",HStandard=" + DBUtility.ClsPub.BoolToString(omodel.HStandard) +
|
",HDate='" + omodel.HDate + "'" +
|
",HYear=" + omodel.HYear.ToString() + "" +
|
",HPeriod=" + omodel.HPeriod.ToString() + "" +
|
",HUpDater='" + omodel.HUpDater + "'" +
|
",HUpDateDate='" + omodel.HUpDateDate + "'" +
|
",HRemark='" + omodel.HRemark + "'" +
|
|
|
" where HInterID=" + lngBillKey.ToString());
|
//删除关联
|
DeleteRelation(ref sReturn, lngBillKey);
|
//删除子表
|
DeleteBillSub(lngBillKey);
|
//插入子表
|
omodel.HInterID = lngBillKey;
|
foreach (Model.ClsGy_SOPBillSub oSub in DetailColl)
|
{
|
oCn.RunProc("Insert into Gy_SOPBillSub " +
|
"(HInterID,HEntryID,HProcID,HProcNO" +
|
",HWorkStationID,HCenterID,HRemark" +
|
") values("
|
+ omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + "," + oSub.HProcID.ToString() + "," + oSub.HProcNo.ToString() +
|
"," + oSub.HWorkStationID.ToString() + "," + oSub.HCenterID.ToString() + ",'" + oSub.HRemark.ToString() + "'" +
|
") ");
|
}
|
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 Gy_SOPBillMain " +
|
"(HBillType,HInterID,HBillNo,HDate" +
|
",HYear,HPeriod,HRemark,HMaker,Hmakedate,HMaterID,HName,HMaterTypeID" +
|
",HUnitID,HMaterNumber,HUnitNumber,HStandard" +
|
") " +
|
" values('" + this.BillType + "'," + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "','" + omodel.HDate + "'" +
|
"," + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HRemark + "','" + DBUtility.ClsPub.CurUserName + "',getdate()," + omodel.HMaterID.ToString() + ",'" + omodel.HName + "'," + omodel.HMaterTypeID.ToString() +
|
"," + omodel.HUnitID.ToString() + ",'" + omodel.HMaterNumber + "','" + omodel.HUnitNumber + "'," + DBUtility.ClsPub.BoolToString(omodel.HStandard) +
|
") ");
|
//插入子表
|
foreach (Model.ClsGy_SOPBillSub oSub in DetailColl)
|
{
|
oCn.RunProc("Insert into Gy_SOPBillSub " +
|
"(HInterID,HEntryID,HProcID,HProcNO" +
|
",HWorkStationID,HCenterID,HRemark" +
|
") values("
|
+ omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + "," + oSub.HProcID.ToString() + "," + oSub.HProcNo.ToString() +
|
"," + oSub.HWorkStationID.ToString() + "," + oSub.HCenterID.ToString() + ",'" + oSub.HRemark.ToString() + "'" +
|
") ");
|
}
|
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 Gy_SOPBillMain Where HInterID=" + lngBillKey.ToString(), "Gy_SOPBillMain");
|
if(Ds.Tables[0].Rows.Count==0)
|
{
|
sReturn = "单据未找到!";
|
return false;
|
}
|
//赋值
|
omodel.HInterID =DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"].ToString());
|
omodel.HBillNo = Ds.Tables[0].Rows[0]["HBillNo"].ToString().Trim();
|
omodel.HName = Ds.Tables[0].Rows[0]["HName"].ToString().Trim();
|
omodel.HDate = Convert.ToDateTime(Ds.Tables[0].Rows[0]["HDate"].ToString().Trim());
|
omodel.HYear = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HYear"].ToString());
|
omodel.HPeriod = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HPeriod"].ToString());
|
omodel.HRemark = Ds.Tables[0].Rows[0]["HRemark"].ToString().Trim();
|
|
omodel.HUseFlag = DBUtility.ClsPub.GridToBool(Ds.Tables[0].Rows[0]["HUseFlag"]);
|
omodel.HStandard = DBUtility.ClsPub.GridToBool(Ds.Tables[0].Rows[0]["HStandard"]);
|
omodel.HMaterNumber = Ds.Tables[0].Rows[0]["HMaterNumber"].ToString().Trim();
|
omodel.HUnitNumber = Ds.Tables[0].Rows[0]["HUnitNumber"].ToString().Trim();
|
omodel.HMaterTypeID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HMaterTypeID"].ToString());
|
omodel.HMaterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HMaterID"].ToString());
|
omodel.HUnitID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HUnitID"].ToString());
|
//
|
omodel.HMaker = Ds.Tables[0].Rows[0]["HMaker"].ToString().Trim();
|
omodel.HMakeDate = Ds.Tables[0].Rows[0]["HMakeDate"].ToString().Trim();
|
omodel.HBackDate = Ds.Tables[0].Rows[0]["HBackDate"].ToString().Trim();
|
omodel.HBacker = Ds.Tables[0].Rows[0]["HBacker"].ToString().Trim();
|
omodel.HUpDateDate = Ds.Tables[0].Rows[0]["HUpDateDate"].ToString().Trim();
|
omodel.HUpDater = Ds.Tables[0].Rows[0]["HUpDater"].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();
|
omodel.HUseDate = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["HUseDate"]);
|
omodel.HUseMan = Ds.Tables[0].Rows[0]["HUseMan"].ToString().Trim();
|
|
//循环
|
DataSet DsSub ;
|
DsSub = oCn.RunProcReturn("Select * from Gy_SOPBillSub Where HInterID=" + lngBillKey.ToString() + " Order by HEntryID ", "Gy_SOPBillSub");
|
DetailColl.Clear();//清空
|
for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++)
|
{
|
Model.ClsGy_SOPBillSub oSub = new Model.ClsGy_SOPBillSub();
|
oSub.HInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HInterID"]);
|
oSub.HEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HEntryID"]);
|
//
|
oSub.HProcID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HProcID"]);
|
oSub.HCenterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HCenterID"]);
|
oSub.HProcNo = DBUtility.ClsPub.isInt(DsSub.Tables[0].Rows[i]["HProcNo"]);
|
oSub.HWorkStationID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HWorkStationID"]);
|
oSub.HRemark = DsSub.Tables[0].Rows[i]["HRemark"].ToString().Trim();
|
DetailColl.Add(oSub);
|
}
|
sReturn = "显示单据成功!";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
throw (e);
|
}
|
}
|
|
//启用工艺路线
|
public bool Sub_RoutingCheckAndUsed(Int64 HInterID)
|
{
|
try
|
{
|
string HChecker = DBUtility.ClsPub.CurUserName;
|
oCn.RunProc("EXEC h_p_Gy_RoutingCheckAndUsed " + HInterID.ToString() + ",'" + HChecker + "'");
|
return true;
|
}
|
catch (Exception e)
|
{
|
throw (e);
|
}
|
}
|
|
//反启用工艺路线
|
public bool Sub_RoutingUsed_Back(Int64 HInterID)
|
{
|
try
|
{
|
oCn.RunProc("EXEC h_p_Gy_RoutingUsed_Back " + HInterID.ToString());
|
return true;
|
}
|
catch (Exception e)
|
{
|
throw (e);
|
}
|
}
|
|
//产品是否已存在工艺路线
|
public bool IsExistRouting(Int64 HMaterID)
|
{
|
DataSet Ds = new DataSet();
|
Ds = oCn.RunProcReturn("select * from Gy_SOPBillMain where hmaterid=" + HMaterID, "Gy_SOPBillMain");
|
if (Ds.Tables[0].Rows.Count > 0)
|
{
|
return true;
|
}
|
else
|
{
|
return false;
|
}
|
}
|
|
//根据产品内码 删除工艺
|
public bool DeleteByMaterID(Int64 HMaterID)
|
{
|
try
|
{
|
oCn.RunProc("Delete from Gy_SOPBillMain where HMaterID=" + HMaterID.ToString());
|
return true;
|
}
|
catch (Exception e)
|
{
|
return false;
|
}
|
}
|
}
|
|
}
|