1
yangle
昨天 6d0bfe2160e06a4502dc3052c43fab9813341db3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
using System;
using System.Collections.Generic;
using System.Text;
using System.Data; 
 
namespace DAL
{
    public  class ClsSc_ProcPlanSortBill
    {
 
        public string MvarItemKey;
        public string MvarReportTitle;
        public long HRelationInterID;
        public List<Cls_ICTLDetail> oDetailColl = new List<Cls_ICTLDetail>();
        public List<Model.ClsSc_ProcPlanSortBillMain> MainColl = new List<Model.ClsSc_ProcPlanSortBillMain>();
        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
        public bool FillTag=false;
        public ClsSc_ProcPlanSortBill()
        {
            MvarItemKey = "3713";
            MvarReportTitle = "工序计划排程";
        }
 
        #region 固定代码
        
        ~ClsSc_ProcPlanSortBill()
        {
            //DetailColl = null;
            MainColl = null;
        }
        //删除子表
        public void DeleteBillSub(Int64 lngBillKey)
        {
            oCn.RunProc("Delete From Sc_ProcPlanSortBillSub where HInterID=" + lngBillKey.ToString());
        }
        //删除主表
        public void DeleteBillMain(Int64 lngBillKey)
        {
            oCn.RunProc("Delete From Sc_ProcPlanSortBillMain 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(Int64 sDeptID,ref string sReturn)
        {
            try
            {
                long lInterID = 0;
                string sBillNo = "";
                //得到mainid
                HRelationInterID = DBUtility.ClsPub.CreateBillID(MvarItemKey, ref DBUtility.ClsPub.sExeReturnInfo);
                //若MAINDI重复则重新获取
                oCn.BeginTran();
                //按部门删除
                oCn.RunProc("update Sc_ProcPlanSortBillMain set HDeleteMan='System',HDeleteDate=getdate()  where HDeleteMan='' and  HDeptID=" + sDeptID.ToString());
                //
                //主表
                foreach (Model.ClsSc_ProcPlanSortBillMain oMain in MainColl)
                {
                    //lInterID = DBUtility.ClsPub.CreateBillID(MvarItemKey, ref DBUtility.ClsPub.sExeReturnInfo);
                    oCn.RunProc("Insert Into Sc_ProcPlanSortBillMain   " +
                    "(HYear,HPeriod,HInterID,HBillNo,HBillType,HDate" +
                    ",HDeptID,HMaterID,HSourceID,HUnitID,HSplitNo,HYX" +
                    ",HPlanBeginDate,HPlanEndDate,HPlanQty,HSplitPlanQty,HSplitRelationQty,HRelationQty" +
                    ",HKTQ,HWorkQty,HReadyTimes,HRemark,HMaker,HMakeDate,HSourceInterID" +
                    ",HSourceEntryID,HSourceBillNo,HSourceBillType,HICMOInterID,HICMOBillNo,HSeOrderBillNo" +
                    ",HProcPlanInterID,HProcPlanEntryID,HProcPlanBillNo,HProcID" +
                    ",HSeOrderInterID,HSeOrderEntryID,HRelationInterID,HWorkerID,HGroupID" +
                    ") " +
                    " values (" + oMain.HYear.ToString() + "," + oMain.HPeriod.ToString() + "," + oMain.HInterID.ToString() + ",'" + oMain.HBillNo.Trim() + "','" + MvarItemKey + "','" + oMain.HDate.ToShortDateString() + "'" +
                    ", " + oMain.HDeptID.ToString() + "," + oMain.HMaterID.ToString() + "," + oMain.HSourceID.ToString() + "," + oMain.HUnitID.ToString() + ",'" + oMain.HSplitNo.Trim() + "'," + oMain.HYX.ToString() +
                    ",'" + oMain.HPlanBeginDate.ToShortDateString() + "','" + oMain.HPlanEndDate.ToShortDateString() + "'," + oMain.HPlanQty.ToString() + "," + oMain.HSplitPlanQty.ToString() + "," + oMain.HSplitRelationQty.ToString() + "," + oMain.HRelationQty.ToString() +
                    ",'" + DBUtility.ClsPub.BoolToString(oMain.HKTQ) + "'," + oMain.HWorkQty.ToString() + "," + oMain.HReadyTimes.ToString() + ",'" + oMain.HRemark + "','" + DBUtility.ClsPub.CurUserName + "',getdate()," + oMain.HSourceInterID.ToString() +
                    ", " + oMain.HSourceEntryID.ToString() + ",'" + oMain.HSourceBillNo + "','" + oMain.HSourceBillType + "'," + oMain.HICMOInterID.ToString() + ",'" + oMain.HICMOBillNo.Trim() + "','" + oMain.HSeOrderBillNo.Trim() + "'" +
                    ", " + oMain.HProcPlanInterID.ToString() + "," + oMain.HProcPlanEntryID.ToString() + ",'" + oMain.HProcPlanBillNo + "'," + oMain.HProcID.ToString() +
                    ", " + oMain.HSeOrderInterID.ToString() + "," + oMain.HSeOrderEntryID.ToString() + "," + HRelationInterID.ToString() + "," + oMain.HWorkerID.ToString() + "," + oMain.HGroupID.ToString() +
                    ") ");
 
                    //插入子表
                    foreach (Model.ClsSc_ProcPlanSortBillSub oSub in oMain.DetailColl)
                    {
                        oCn.RunProc("Insert into Sc_ProcPlanSortBillSub " +
                           " (HInterID,HEntryID,HMasterDate,HDate" +
                           ",HQty,HStatusTag,HiForeColor,HiBackColor" +
                           ",HBeginTime,HEndTime,HUseTime" +
                           ",HRemark,HCloseMan,HCloseType" +
                           ") " +
                           " values ("
                           + oMain.HInterID.ToString()  + "," + oSub.HEntryID.ToString() + ",'" + oSub.HMasterDate.ToShortDateString() + "','" + oSub.HDate.ToShortDateString() + "'" +
                           "," + DBUtility.ClsPub.isSingle(oSub.HQty) + "," + oSub.HStatusTag.ToString() + ",'" + oSub.HiForeColor.ToString() + "','" + oSub.HiBackColor.ToString() +
                           "','" + DBUtility.ClsPub.isDate(oSub.HBeginTime) + "','" + DBUtility.ClsPub.isDate(oSub.HBeginTime) + "'," + oSub.HUseTime.ToString() +
                           ",'" + oSub.HRemark + "','" + oSub.HCloseMan + "'," + DBUtility.ClsPub.BoolToString(oSub.HCloseType) +
                           ") ");
                    }
                    
                }
                
                sReturn = "新增单据成功!";
                oCn.Commit();
                ////存入生产状态表
                oCn.RunProc("exec h_p_Sc_ICMOBillStatus_Add " + sDeptID.ToString());
                //
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                oCn.RollBack();
                return false;
            }
        }
        //显示单据
        public bool ShowBill(Int64 lngBillKey, ref string sReturn)
        {
            try
            {
                //查询主表
                DataSet Ds;
                DataSet DsSub;
                Ds = oCn.RunProcReturn("Select * from Sc_ProcPlanSortBillMain Where HRelationInterID=" + lngBillKey.ToString(), "Sc_ProcPlanSortBillMain");
                if(Ds.Tables[0].Rows.Count==0)
                {
                    sReturn = "单据未找到!";
                    return false;
                }
                //赋值
                MainColl.Clear();
                for (int i = 0; i < Ds.Tables[0].Rows.Count; i++)
                {
                    Model.ClsSc_ProcPlanSortBillMain oMain = new Model.ClsSc_ProcPlanSortBillMain();
                    oMain.HRelationInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HRelationInterID"]); 
                    oMain.HYear = DBUtility.ClsPub.isInt(Ds.Tables[0].Rows[i]["HYear"]);
                    oMain.HPeriod = DBUtility.ClsPub.isInt(Ds.Tables[0].Rows[i]["HPeriod"] );
                    oMain.HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HInterID"] );
                    oMain.HBillNo = Ds.Tables[0].Rows[i]["HBillNo"].ToString();
                    oMain.HDate = Convert.ToDateTime(Ds.Tables[0].Rows[i]["HDate"].ToString().Trim());
                    oMain.HDeptID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HDeptID"].ToString());
                    oMain.HProcID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HProcID"]);
                    oMain.HMaterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HMaterID"].ToString());
                    oMain.HGroupID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HGroupID"].ToString());
                    oMain.HWorkerID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HWorkerID"].ToString());
                    oMain.HUnitID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HUnitID"].ToString());
                    oMain.HSourceID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HSourceID"]);
                    oMain.HSplitNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HSplitNo"].ToString());
                    oMain.HYX = DBUtility.ClsPub.isInt(Ds.Tables[0].Rows[i]["HYX"]); 
                    oMain.HPlanBeginDate = Convert.ToDateTime(Ds.Tables[0].Rows[i]["HPlanBeginDate"]);
                    oMain.HPlanEndDate = Convert.ToDateTime(Ds.Tables[0].Rows[i]["HPlanEndDate"]);
                    oMain.HPlanQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HPlanQty"]);
                    oMain.HSplitPlanQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HSplitPlanQty"]);
                    oMain.HSplitRelationQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HSplitRelationQty"]);
                    oMain.HRelationQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HRelationQty"]);
                    oMain.HKTQ = DBUtility.ClsPub.isBool(Ds.Tables[0].Rows[i]["HKTQ"]);
                    oMain.HReadyTimes = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HReadyTimes"]);
                    oMain.HRemark = Ds.Tables[0].Rows[i]["HRemark"].ToString().Trim();
                    //
                    oMain.HMaker = Ds.Tables[0].Rows[i]["HMaker"].ToString().Trim();
                    oMain.HMakeDate = Ds.Tables[0].Rows[i]["HMakeDate"].ToString().Trim();
                    oMain.HUpDateDate = Ds.Tables[0].Rows[i]["HUpDateDate"].ToString().Trim();
                    oMain.HUpDater = Ds.Tables[0].Rows[i]["HUpDater"].ToString().Trim();
                    oMain.HCheckDate = Ds.Tables[0].Rows[i]["HCheckDate"].ToString().Trim();
                    oMain.HChecker = Ds.Tables[0].Rows[i]["HChecker"].ToString().Trim();
                    oMain.HCloseDate = Ds.Tables[0].Rows[i]["HCloseDate"].ToString().Trim();
                    oMain.HCloseMan = Ds.Tables[0].Rows[i]["HCloseMan"].ToString().Trim();
                    oMain.HDeleteDate = Ds.Tables[0].Rows[i]["HDeleteDate"].ToString().Trim();
                    oMain.HDeleteMan = Ds.Tables[0].Rows[i]["HDeleteMan"].ToString().Trim();
                    //
                    oMain.HSourceInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HSourceInterID"].ToString());
                    oMain.HSourceEntryID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HSourceEntryID"].ToString());
                    oMain.HSourceBillType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HSourceBillType"].ToString());
                    oMain.HSourceBillNo = Ds.Tables[0].Rows[i]["HSourceBillNo"].ToString().Trim();
                    oMain.HProcPlanInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HProcPlanInterID"].ToString());
                    oMain.HProcPlanEntryID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HProcPlanEntryID"].ToString());
                    oMain.HProcPlanBillNo = Ds.Tables[0].Rows[i]["HProcPlanBillNo"].ToString().Trim();
                    oMain.HICMOInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HICMOInterID"]);
                    oMain.HICMOBillNo = Ds.Tables[0].Rows[i]["HICMOBillNo"].ToString().Trim();
                    oMain.HSeOrderInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HSeOrderInterID"]);
                    oMain.HSeOrderEntryID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HSeOrderEntryID"]);
                    oMain.HSeOrderBillNo = Ds.Tables[0].Rows[i]["HSeOrderBillNo"].ToString().Trim();
                    //
                    DsSub = oCn.RunProcReturn("Select * from Sc_ProcPlanSortBillSub Where HInterID=" + oMain.HInterID.ToString() + " order by HEntryID ", "Sc_ProcPlanSortBillSub");
                    oMain.DetailColl.Clear();//清空
                    for (int j = 0; j < DsSub.Tables[0].Rows.Count; j++)
                    {
                        Model.ClsSc_ProcPlanSortBillSub oSub = new Model.ClsSc_ProcPlanSortBillSub();
                        oSub.HInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[j]["HInterID"]);
                        oSub.HEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[j]["HEntryID"]);
                        oSub.HMasterDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[j]["HMasterDate"]);
                        oSub.HDate = DBUtility.ClsPub.isDate(DsSub.Tables[0].Rows[j]["HDate"]);
                        oSub.HQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[j]["HQty"]);
                        oSub.HStatusTag = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[j]["HStatusTag"]);
                        oSub.HiForeColor = DsSub.Tables[0].Rows[j]["HiForeColor"].ToString();
                        oSub.HiBackColor = DsSub.Tables[0].Rows[j]["HiBackColor"].ToString();
                        oSub.HRemark = DsSub.Tables[0].Rows[j]["HRemark"].ToString().Trim();
                        oSub.HCloseMan = DsSub.Tables[0].Rows[j]["HCloseMan"].ToString().Trim();
                        oSub.HCloseType = (bool)DsSub.Tables[0].Rows[j]["HCloseType"];
                        oMain.DetailColl.Add(oSub);
                    }
                    //
                    MainColl.Add(oMain);
                }
                //循环
                
                sReturn = "显示单据成功!";
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                return false;
            }
        }
        //得到该部门HRelationInterID
        public Int64 GetRelationInterIDByDept(Int64 sDeptID)
        {
            DataSet DS ;
            try
            {
                DS = oCn.RunProcReturn("Select isnull(max(HRelationInterID),0) HRelationInterID  from Sc_ProcPlanSortBillMain Where HDeptID=" + sDeptID + "  and Hdeleteman='' ", "Sc_ProcPlanSortBillMain");
                if (DS.Tables[0].Rows.Count == 0)
                    return 0;
                else
                {
 
                    return DBUtility.ClsPub.isLong(DS.Tables[0].Rows[0]["HRelationInterID"]);
                }
            }
            catch (Exception e)
            {
                return 0;
            }
        }
 
        //设置本行 资源 产能,拆分汇报数量
        public Single GetSourceWorkQty(Int64 sMaterID,Int64 sProcID,Int64 sSourceID)
        {
            DataSet DS ;
            try
            {
                DS = oCn.RunProcReturn("exec h_p_Sc_SetSourceWorkQty "+sMaterID.ToString()+","+sProcID.ToString()+","+sSourceID.ToString(), "xt_xtgnb");
                if (DS.Tables[0].Rows.Count == 0)
                    return 0;
                else
                {
                    return DBUtility.ClsPub.isSingle(DS.Tables[0].Rows[0]["HWorkQty"]);
                }
            }
            catch (Exception e)
            {
                return 0;
            }
        }
 
        //设置本行 资源  ,拆分汇报数量
        public bool GetSourceRelationQty(Int64 ICMOInterID, Int64 sSourceID, ref Single RelationQty, ref Single SplitRelationQty)
        {
            DataSet DS ;
            try
            {
                DS = oCn.RunProcReturn("exec h_p_Sc_SetSourceRelationQty " + ICMOInterID.ToString() + "," + sSourceID.ToString(), "xt_xtgnb");
                if (DS.Tables[0].Rows.Count == 0)
                {
                    RelationQty = 0;
                    SplitRelationQty = 0;
                    return false;
                }
                else
                {
                    RelationQty = DBUtility.ClsPub.isSingle(DS.Tables[0].Rows[0]["RelationQty"]);
                    SplitRelationQty = DBUtility.ClsPub.isSingle(DS.Tables[0].Rows[0]["SplitRelationQty"]);
                    return true;
                }
            }
            catch (Exception e)
            {
                RelationQty = 0;
                SplitRelationQty = 0;
                return false;
            }
        }
 
        //得到最新排程时间
        public DateTime GetNewSetup(Int64 HDeptID)
        {
            try
            {
                DataSet DS = oCn.RunProcReturn("select top 1 HMakeDate from Sc_ProcPlanSortBillMain Where HDeptID=" + HDeptID.ToString() + " and HDeleteMan='' order by HDate desc", "Sc_ProcPlanSortBillMain");
                if (DS == null || DS.Tables[0].Rows.Count == 0)
                {
                    return DateTime.Today;
                }
                else
                {
                    return DBUtility.ClsPub.isDate(DS.Tables[0].Rows[0]["HMakeDate"]);
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
 
        //填充投料单
        public void FillData(Int64 HDeptID)
        { 
            string sSQL="";
            FillTag = false;
            oDetailColl.Clear();
            sSQL = "exec h_v_Sc_GetICMOSortPPBOMQty " + HDeptID.ToString();
            try
            {
                DataSet Ds = oCn.RunProcReturn(sSQL, "gy_Material");
                if (Ds == null || Ds.Tables[0].Rows.Count == 0)
                {
                    return;
                }
                for (int i = 0; i < Ds.Tables[0].Rows.Count; i++)
                {
                    Cls_ICTLDetail oTL = new Cls_ICTLDetail();
                    oTL.BLS = DBUtility.ClsPub.isSingle(Ds.Tables[0].Rows[i]["BLS"]);
                    oTL.DWYL = DBUtility.ClsPub.isSingle(Ds.Tables[0].Rows[i]["DWYL"]);
                    oTL.FAuxQty = DBUtility.ClsPub.isSingle(Ds.Tables[0].Rows[i]["FAuxQty"]);
                    oTL.FqtyPick = DBUtility.ClsPub.isSingle(Ds.Tables[0].Rows[i]["FqtyPick"]);
                    oTL.GGXH = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["GGXH"]);
                    oTL.JHTLS = DBUtility.ClsPub.isSingle(Ds.Tables[0].Rows[i]["JHTLS"]);
                    oTL.JLDW = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["JLDW"]);
                    oTL.LLS = DBUtility.ClsPub.isSingle(Ds.Tables[0].Rows[i]["LLS"]);
                    oTL.MainGGXH = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["MainGGXH"]);
                    oTL.MainWLDM = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["MainWLDM"]);
                    oTL.MainWLMC = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["MainWLMC"]);
                    oTL.OrderAmount = DBUtility.ClsPub.isSingle(Ds.Tables[0].Rows[i]["OrderAmount"]);
                    oTL.RQ = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["RQ"]);
                    oTL.SCRWDH = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["SCRWDH"]);
                    oTL.StockAmount = DBUtility.ClsPub.isSingle(Ds.Tables[0].Rows[i]["StockAmount"]);
                    oTL.TLDH = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["TLDH"]);
                    oTL.WFS = DBUtility.ClsPub.isSingle(Ds.Tables[0].Rows[i]["WFS"]);
                    oTL.WLDM = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["WLDM"]);
                    oTL.WLMC = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["WLMC"]);
                    oTL.YFSL = DBUtility.ClsPub.isSingle(Ds.Tables[0].Rows[i]["YFSL"]);
                    oDetailColl.Add(oTL);
                }
                FillTag = true;
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
        //
        public List<Cls_ICTLDetail>  GetTLColl(string sSCRWDH)
        {
            List<Cls_ICTLDetail> oColl=new List<Cls_ICTLDetail>();  
            foreach(Cls_ICTLDetail oTL in oDetailColl)
            {
                if(oTL.SCRWDH.Trim()==sSCRWDH)
                {
                    oColl.Add(oTL);
                }
            }
            return oColl;
        }
 
        //设置计划开工日期
        public bool Sub_setPlanBeginDate(Int64 lngBillKey,DateTime sDate, ref string sReturn)
        {
            try
            {
                oCn.RunProc("exec h_p_K3_SetICMOSortBillBeginDate "+lngBillKey.ToString()+",'"+sDate.ToShortDateString()+"'" );
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message; 
                return false;
            }
        }
 
        //设置计划完工日期
        public bool Sub_setPlanEndDate(Int64 lngBillKey, DateTime sDate, ref string sReturn)
        {
            try
            {
                oCn.RunProc("exec h_p_K3_SetICMOSortBillEndDate " + lngBillKey.ToString() + ",'" + sDate.ToShortDateString() + "'");
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                return false;
            }
        }
 
        //根据ID得到生产计划
        public DataSet Sub_GetScInfoByMainID(Int64 lngBillKey, ref string sReturn)
        {
            try
            {
                DataSet ds;
                ds = oCn.RunProcReturn("select  生产任务单号,部门名称,总计划数,本日计划,产品代码,产品名称,产品规格,资源名称,日期 from h_v_Sc_ProcPlanSortBillList Where HMainID="+lngBillKey.ToString(), "xt_xtgnb");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    return null;
                }
                return ds;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                return null;
            }
        }
        
 
    }
 
}