using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using System.Data;
|
|
namespace DAL
|
{
|
public class ClsGy_LineCenterSub:DBUtility.ClsXt_BaseBill
|
{
|
public Model.ClsSc_ProcProdMoveBillMain omodel = new Model.ClsSc_ProcProdMoveBillMain();
|
public List<Model.ClsGy_LineCenterSub> DetailColl = new List<Model.ClsGy_LineCenterSub>();
|
|
public ClsGy_LineCenterSub()
|
{
|
base.MvarItemKeySub = "Gy_LineCenterSub";
|
base.MvarItemKeySub2 = "";
|
base.MvarItemKeySub3 = "";
|
base.MvarItemKeySub4 = "";
|
base.MvarItemKey="Sc_ProcProdMoveBillMain";
|
base.MvarReportTitle="产线中心关联表";
|
base.BillType="0";
|
}
|
|
#region 固定代码
|
|
~ClsGy_LineCenterSub()
|
{
|
DetailColl = null;
|
}
|
|
#endregion 自定义方法
|
//修改单据
|
public override bool ModifyBill(Int64 lngBillKey, ref string sReturn)
|
{
|
try
|
{
|
//
|
oCn.BeginTran();
|
//
|
//DeleteRelation(ref sReturn, lngBillKey);
|
//删除子表
|
//DeleteBillSub(lngBillKey);
|
oCn.RunProc("delete from Gy_LineCenterSub where Hitemid=" + lngBillKey.ToString());
|
//插入子表
|
//omodel.HInterID = lngBillKey;
|
foreach (Model.ClsGy_LineCenterSub oSub in DetailColl)
|
{
|
oCn.RunProc("Insert into Gy_LineCenterSub " +
|
" (HLineCenterID,HSourceID,HSno,HUnionFlag,HFstSource,HKeySource" +
|
") values(" + oSub.HLineCenterID.ToString() + "," + oSub.HSourceID.ToString() + "," + oSub.HSNo.ToString() + "," + Convert.ToString(oSub.HUnionFlag ? 1 : 0) + ",'" + oSub.HFstSource + "','" + oSub.HKeySource + "'" +
|
") ");
|
}
|
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();
|
//插入子表
|
foreach (Model.ClsGy_LineCenterSub oSub in DetailColl)
|
{
|
oCn.RunProc("Insert into Gy_LineCenterSub " +
|
" (HLineCenterID,HSourceID,HSno,HUnionFlag,HFstSource,HKeySource) values(" + oSub.HLineCenterID.ToString() + "," + oSub.HSourceID.ToString() + "," + oSub.HSNo.ToString() + "," + Convert.ToString(oSub.HUnionFlag ? 1 : 0) + ",'" + oSub.HFstSource + "','" + oSub.HKeySource + "'" +
|
") ");
|
}
|
|
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 DsSub ;
|
omodel.HInterID = lngBillKey;
|
DsSub = oCn.RunProcReturn("Select * from Gy_LineCenterSub Where HItemID=" + lngBillKey.ToString(), "Gy_LineCenterSub");
|
DetailColl.Clear();//清空
|
for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++)
|
{
|
Model.ClsGy_LineCenterSub oSub = new Model.ClsGy_LineCenterSub();
|
|
|
oSub.HLineCenterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HLineCenterID"]);
|
oSub.HSourceID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceID"]);
|
oSub.HKeySource = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HKeySource"]);
|
oSub.HSNo = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSNo"]);
|
|
oSub.HFstSource = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HFstSource"]);
|
oSub.HUnionFlag = DBUtility.ClsPub.isBool(DsSub.Tables[0].Rows[i]["HUnionFlag"]);
|
//
|
DetailColl.Add(oSub);
|
}
|
sReturn = "显示成功!";
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
throw (e);
|
}
|
}
|
//delete
|
public override bool DeleteBill(long lngBillKey, ref string sReturn)
|
{
|
try
|
{
|
//
|
oCn.BeginTran();
|
//
|
//DeleteRelation(ref sReturn, lngBillKey);
|
//删除子表
|
//DeleteBillSub(lngBillKey);
|
oCn.RunProc("delete from Gy_LineCenterSub where Hitemid=" + lngBillKey.ToString());
|
sReturn = "删除成功!";
|
oCn.Commit();
|
return true;
|
}
|
catch (Exception e)
|
{
|
sReturn = e.Message;
|
oCn.RollBack();
|
throw (e);
|
}
|
}
|
//delete
|
|
/// <summary>
|
/// 根据转出工序,得到接收工序
|
/// </summary>
|
/// <returns></returns>
|
public bool GetNextProcessPlan(long HMainID,long HSubID, ref string sReturn)
|
{
|
//DataSet DsSub;
|
//DsSub = oCn.RunProcReturn("Select top 1 * from h_v_Sc_ProcessPlanList where hmainid=" + HMainID.ToString() + " and hsubid>" + HSubID.ToString() + " order by hsubid ", "h_v_Sc_ProcessPlanList");
|
//if (DsSub.Tables[0].Rows.Count == 0)
|
//{
|
// sReturn = "单据未找到!";
|
// return false;
|
//}
|
//omodel.HInProcID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[0]["hprocid"]);
|
//DetailColl.Clear();//清空
|
//for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++)
|
//{
|
// Model.ClsGy_LineCenterSub oSub = new Model.ClsGy_LineCenterSub();
|
// //
|
// oSub.HFstSource = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["HFstSource"]);
|
// oSub.HLineCenterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HLineCenterID"]);
|
// oSub.HSourceID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSourceID"]);
|
// oSub.HSNo = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HSNo"]);
|
// oSub.HUnionFlag = DBUtility.ClsPub.isBool(DsSub.Tables[0].Rows[i]["HUnionFlag"]);
|
// //
|
// DetailColl.Add(oSub);
|
//}
|
return true;
|
}
|
|
|
}
|
|
}
|