using System; using System.Collections.Generic; using System.Text; using System.Data; namespace DAL { public class ClsGy_WorkCenterSourceBill:DBUtility.ClsXt_BaseBill { public Model.ClsSc_ProcProdMoveBillMain omodel = new Model.ClsSc_ProcProdMoveBillMain(); public List DetailColl = new List(); public ClsGy_WorkCenterSourceBill() { base.MvarItemKeySub = "Gy_WorkCenterSub"; base.MvarItemKeySub2 = ""; base.MvarItemKeySub3 = ""; base.MvarItemKeySub4 = ""; base.MvarItemKey="Sc_ProcProdMoveBillMain"; base.MvarReportTitle="工作中心下属资源"; base.BillType="0"; } #region 固定代码 ~ClsGy_WorkCenterSourceBill() { 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_WorkCenterSub where Hitemid=" + lngBillKey.ToString()); //插入子表 //omodel.HInterID = lngBillKey; foreach (Model.ClsGy_WorkCenterSourceBillSub oSub in DetailColl) { oCn.RunProc("Insert into Gy_WorkCenterSub " + " (HCenterID,HSourceID,HSno,HUnionFlag" + ") values(" + oSub.HCenterID.ToString() + "," + oSub.HSourceID.ToString() + "," + oSub.HSNo.ToString() + "," + Convert.ToString(oSub.HUnionFlag ? 1 : 0) + ") "); } 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_WorkCenterSourceBillSub oSub in DetailColl) { oCn.RunProc("Insert into Gy_WorkCenterSub " + " (HCenterID,HSourceID,HSno,HUnionFlag" + ") values(" + oSub.HCenterID.ToString() + "," + oSub.HSourceID.ToString() + "," + oSub.HSNo.ToString() +"," + Convert.ToString(oSub.HUnionFlag ? 1 : 0) + ") "); } 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_WorkCenterSub Where HItemID=" + lngBillKey.ToString(), "Gy_WorkCenterSub"); DetailColl.Clear();//清空 for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++) { Model.ClsGy_WorkCenterSourceBillSub oSub = new Model.ClsGy_WorkCenterSourceBillSub(); oSub.HCenterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HCenterID"]); 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); } 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_WorkCenterSub where Hitemid=" + lngBillKey.ToString()); sReturn = "删除成功!"; oCn.Commit(); return true; } catch (Exception e) { sReturn = e.Message; oCn.RollBack(); throw (e); } } //delete /// /// 根据转出工序,得到接收工序 /// /// 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_WorkCenterSourceBillSub oSub = new Model.ClsGy_WorkCenterSourceBillSub(); // // // oSub.HInProcPlanBillNo = DBUtility.ClsPub.isStrNull(DsSub.Tables[0].Rows[i]["工序计划单号"]); // oSub.HInProcPlanInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["hmainid"]); // oSub.HInProcPlanEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["hsubid"]); // oSub.HInCenterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["HCenterID"]); // oSub.HInSourceID = 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; } } }