| using System; | 
| using System.Collections.Generic; | 
| using System.Text; | 
| using System.Data;  | 
|   | 
| namespace DAL | 
| { | 
|     /// <summary> | 
|     /// 生产排程 保存 生产人员  1对多 | 
|     /// </summary> | 
|     public  class ClsSc_ICMOSortBill_Group | 
|     { | 
|   | 
|         public string MvarItemKey; | 
|         public string MvarReportTitle; | 
|   | 
|         public Model.ClsSc_ICMOSortBill_GroupMain omodel = new Model.ClsSc_ICMOSortBill_GroupMain(); | 
|         public List<Model.ClsSc_ICMOSortBill_GroupSub> DetailColl = new List<Model.ClsSc_ICMOSortBill_GroupSub>(); | 
|         SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); | 
|         public bool FillTag = false; | 
|         public ClsSc_ICMOSortBill_Group() | 
|         { | 
|             MvarItemKey = "3708"; | 
|             MvarReportTitle = "生产计划排程"; | 
|         } | 
|   | 
|         #region 固定代码 | 
|          | 
|         ~ClsSc_ICMOSortBill_Group() | 
|         { | 
|             DetailColl = null; | 
|         } | 
|         //删除子表 | 
|         public void DeleteBillSub(Int64 lngBillKey) | 
|         { | 
|             //oCn.RunProc("Delete From Sc_ICMOSortBillSub where HInterID=" + lngBillKey.ToString()); | 
|         } | 
|         //删除主表 | 
|         public void DeleteBillMain(Int64 lngBillKey) | 
|         { | 
|             //oCn.RunProc("Delete From Sc_ICMOSortBillMain where HInterID=" + lngBillKey.ToString()); | 
|         } | 
|         //删除单据 | 
|         public bool DeleteBill(Int64 lngBillKey, ref string sReturn) | 
|         { | 
|             //try | 
|             //{ | 
|             //    oCn.BeginTran(); | 
|             //    //删除关联  | 
|             //    //删除明细表 | 
|             //    //DeleteBillSub(lngBillKey); | 
|             //    //删除主表 | 
|             //    DeleteBillMain(lngBillKey); | 
|             //    sReturn = "删除单据成功!"; | 
|             //    oCn.Commit(); | 
|             return true; | 
|             //} | 
|             //catch (Exception e) | 
|             //{ | 
|             //    sReturn = e.Message; | 
|             //    oCn.RollBack(); | 
|             //    return false; | 
|             //} | 
|         } | 
|         | 
|      | 
|         #endregion | 
|          | 
|         //新增单据 | 
|         public bool AddBill(ref string sReturn) | 
|         { | 
|             try | 
|             { | 
|                 //若MAINDI重复则重新获取 | 
|                 oCn.BeginTran(); | 
|                 oCn.RunProc("delete from Sc_ICMOSortBill_Group where HICMOInterID=" + omodel.HICMOInterID.ToString() + " and HSplitNO='" + omodel.HSplitNO + "' and HSourceID=" + omodel.HSourceID.ToString() + " and HGroupID=" + omodel.HGroupID.ToString()); | 
|                 //主表 | 
|                 // | 
|                 //插入子表 | 
|                 foreach (Model.ClsSc_ICMOSortBill_GroupSub oSub in DetailColl) | 
|                 { | 
|                     oCn.RunProc("Insert into Sc_ICMOSortBill_Group " + | 
|                        " (HICMOInterID,HICMOBillNo,HSplitNO,HMaterID" + | 
|                        ",HSourceID,HGroupID,HEmpID" + | 
|                        ") " + | 
|                        " values (" | 
|                        + omodel.HICMOInterID.ToString() + ",'" + omodel.HICMOBillNo.ToString() + "','" + omodel.HSplitNO.ToString() + "'," + omodel.HMaterID.ToString() + | 
|                        "," + omodel.HSourceID.ToString() + "," + omodel.HGroupID.ToString() + "," + oSub.HEmpID.ToString() + | 
|                        ") "); | 
|                 } | 
|                  | 
|                 sReturn = "新增单据成功!"; | 
|                 oCn.Commit(); | 
|                 // | 
|                 return true; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 sReturn = e.Message; | 
|                 oCn.RollBack(); | 
|                 return false; | 
|             } | 
|         } | 
|         //显示单据 | 
|         public bool ShowBill(Int64 HICMOInterID, string HSplitNO, Int64 HSourceID, Int64 HGroupID, ref string sReturn) | 
|         { | 
|             try | 
|             { | 
|                 //查询主表 | 
|                 DataSet Ds; | 
|                 DataSet DsSub; | 
|                 Ds = oCn.RunProcReturn("Select * from Sc_ICMOSortBill_Group where HICMOInterID=" + HICMOInterID.ToString() + " and HSplitNO='" + HSplitNO + "' and HSourceID=" + HSourceID.ToString() + " and HGroupID=" + HGroupID.ToString(), "Sc_ICMOSortBill_Group"); | 
|                 if (Ds.Tables[0].Rows.Count == 0) | 
|                 { | 
|                     sReturn = "单据未找到!"; | 
|                     return false; | 
|                 } | 
|                 //赋值 | 
|                 omodel.HMaterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HMaterID"]); | 
|                 omodel.HGroupID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HGroupID"]); | 
|                 omodel.HSourceID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSourceID"]); | 
|                 omodel.HSplitNO = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HSplitNO"].ToString()); | 
|                 // | 
|                 omodel.HICMOInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HICMOInterID"]); | 
|                 omodel.HICMOBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HICMOBillNo"].ToString()); | 
|                 // | 
|                 DsSub = oCn.RunProcReturn("Select * from Sc_ICMOSortBill_Group where HICMOInterID=" + omodel.HICMOInterID.ToString() + " and HSplitNO='" + omodel.HSplitNO + "' and HSourceID=" + omodel.HSourceID.ToString() + " and HGroupID=" + omodel.HGroupID.ToString(), "Sc_ICMOSortBill_Group"); | 
|                 DetailColl.Clear();//清空 | 
|                 for (int j = 0; j < DsSub.Tables[0].Rows.Count; j++) | 
|                 { | 
|                     Model.ClsSc_ICMOSortBill_GroupSub oSub = new Model.ClsSc_ICMOSortBill_GroupSub(); | 
|                     oSub.HEmpID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[j]["HEmpID"]); | 
|                     DetailColl.Add(oSub); | 
|                 } | 
|                 // | 
|                  | 
|                 sReturn = "显示单据成功!"; | 
|                 return true; | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 sReturn = e.Message; | 
|                 return false; | 
|             } | 
|         } | 
|   | 
|   | 
|   | 
|   | 
|   | 
|   | 
|     } | 
|   | 
| } |