YL
2021-09-10 26f8b83cda74150d83dc09ab0b92b10b6f1286b1
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
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
 
namespace DAL
{
    public  class ClsKf_SellOutBill_CLD:DBUtility.ClsXt_BaseBill
    {
        public Model.ClsKf_SellOutBillMain_CLD omodel = new Model.ClsKf_SellOutBillMain_CLD();
        public List<Model.ClsKf_SellOutBillSub_CLD> DetailColl = new List<Model.ClsKf_SellOutBillSub_CLD>();
        public List<Model.ClsKf_SellOutBillScheme_CLD> DetailSubColl = new List<Model.ClsKf_SellOutBillScheme_CLD>();
        public SQLHelper.ClsCNK3 oCnK3 = new SQLHelper.ClsCNK3();
 
        public ClsKf_SellOutBill_CLD()
        {
            base.MvarItemKeySub = "ICStockBillEntry";
            base.MvarItemKeySub2 = "";
            base.MvarItemKeySub3 = "";
            base.MvarItemKeySub4 = "";
            base.MvarItemKey = "ICStockBill";
            base.MvarReportTitle = "销售出库单";
            base.BillType="21"; 
        }
 
        #region 固定代码
 
        ~ClsKf_SellOutBill_CLD()
        {
            DetailColl = null;
        }
       
        #endregion   自定义方法
        //修改单据
        public override bool ModifyBill(Int64 lngBillKey, ref string sReturn)
        {
            try
            {
                //      //得到用户ID
                long FBillerID = 16394;
                DataSet Ds1;
                oCnK3.BeginTran();
                omodel.HInterID = lngBillKey;
                //删除主表
                oCnK3.RunProc("Delete From ICStockBill  where FInterID=" + lngBillKey.ToString());
                //插入子表
                foreach (Model.ClsKf_SellOutBillSub_CLD oSub in DetailColl)
                {
                    oCnK3.RunProc("INSERT INTO ICStockBillEntry (" +
                                "FInterID,FEntryID,FBrNo,FMapNumber,FMapName," +
                                "FItemID,FAuxPropID,FBatchNo,FQty,FUnitID," +
                                "FAuxQtyMust,Fauxqty,FSecCoefficient,FSecQty," +
                                "FAuxPlanPrice,FPlanAmount,Fauxprice,Famount," +
                                "Fnote,FKFDate,FKFPeriod,FPeriodDate," +
                                "FDCStockID,FDCSPID,FConsignPrice," +
                                "FDiscountRate,FDiscountAmount,FConsignAmount,FOrgBillEntryID,FSNListID," +
                                "FSourceBillNo,FSourceTranType,FSourceInterId,FSourceEntryID," +
                                "FContractBillNo,FContractInterID,FContractEntryID," +
                                "FOrderBillNo,FOrderInterID,FOrderEntryID," +
                                "FAllHookQTY,FCurrentHookQTY,FQtyMust,FSepcialSaleId," +
                                "FAuxQtyInvoice,FQtyInvoice" +
                                ") VALUES (" +
                                omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + ",'0','',''" +
                                "," + oSub.HMaterID.ToString() + ",0,'" + oSub.HBatchNo + "'," + oSub.HQty.ToString() + "," + oSub.HUnitID.ToString() +
                                "," + oSub.HAuxQtyMust.ToString() + "," + oSub.HAuxQty.ToString() + ",0," + oSub.HSecQty.ToString() +
                                "," + oSub.HAuxPlanPrice.ToString() + "," + oSub.HPlanAmount.ToString() + "," + oSub.HAuxPrice.ToString() + "," + oSub.HAmount.ToString() + "" +
                                ",'" + oSub.HRemark + "',null,0,null" +
                                "," + oSub.HWhID.ToString() + "," + oSub.HSPID.ToString() + ",0" +
                                ",0,0,0,0,0" +
                                ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceTranType + "'," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() +
                                ",'',0,0" +
                                ",'',0,0" +
                                ",0,0," + oSub.HQtyMust.ToString() + ",0" +
                                ",0,0" +
                                ")");
                }
                //更新主表
                oCnK3.RunProc("INSERT INTO ICStockBill(" +
                           "FInterID,FBillNo,FBrNo,FTranType,FCancellation," +
                           "FStatus,FUpStockWhenSave,FROB,FHookStatus,Fdate," +
                           "FSupplyID,FSaleStyle,FCheckDate,FFManagerID," +
                           "FSManagerID,FBillerID,FDCStockID," +
                           "FMultiCheckDate1,FMultiCheckDate2,FMultiCheckDate3,FVchInterID," +
                           "FMultiCheckDate4,FMultiCheckDate5,FPOOrdBillNo,FMultiCheckDate6," +
                           "FRelateBrID,FOrgBillInterID,FMarketingStyle,FSelTranType," +
                           "FBrID,FFetchAdd,FExplanation,FDeptID,FEmpID," +
                           "FManagerID,FVIPCardID,FVIPScore,FHolisticDiscountRate,FPOSName," +
                           "FWorkShiftId,FLSSrcInterID,FNote" +
                           ") VALUES (" +
                           omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "','0','" + this.BillType + "',0" +
                           ",0,0,1,0,'" + omodel.HDate.ToString() + "'" +
                           "," + omodel.HSupID + ",0,null," + omodel.HSecManagerID +
                           "," + omodel.HKeeperID + "," + FBillerID + "," + omodel.HWHID +
                           ",null,null,null,0" +
                           ",null,null,'',null" +
                           ",0,0,0,83" +
                           ",0,'" + omodel.HAddress + "','" + omodel.HExplanation + "'," + omodel.HDeptID.ToString() + "," + omodel.HEmpID.ToString() +
                           "," + omodel.HManagerID.ToString() + ",0,0,0,''" +
                           ",0,0,'" + omodel.HRemark + "')");
                //更新关联数量
                //更新K3关联数量
                oCnK3.RunProc("EXEC p_UpdateBillRelateData " + this.BillType + "," + omodel.HInterID.ToString() + ",'ICStockBill','ICStockBillEntry'");
 
                sReturn = "修改单据成功!";
                oCnK3.Commit();
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                oCnK3.RollBack();
                throw (e);
            }
        }
        //新增单据
        public override bool AddBill(ref string sReturn)
        {
            try
            {   
                //得到用户ID
                long FBillerID=16394;
                DataSet Ds1;
                //得到mainid
                Ds1 = oCnK3.RunProcReturn("declare @InterID int set @InterID=0 exec GetICMaxNumOld  'ICStockBill',@InterID output select ltrim(@InterID)", "xt_xtgnb");
                if (Ds1.Tables[0].Rows.Count != 0)
                {
                    omodel.HInterID = DBUtility.ClsPub.isLong(Ds1.Tables[0].Rows[0][0]);
                }
                //若MAINDI重复则重新获取
                oCnK3.BeginTran();
                //插入子表
                foreach (Model.ClsKf_SellOutBillSub_CLD oSub in DetailColl)
                {
                    oCnK3.RunProc("INSERT INTO ICStockBillEntry (" +
                         "FInterID,FEntryID,FBrNo,FMapNumber,FMapName," +
                         "FItemID,FAuxPropID,FBatchNo,FQty,FUnitID," +
                         "FAuxQtyMust,Fauxqty,FSecCoefficient,FSecQty," +
                         "FAuxPlanPrice,FPlanAmount,Fauxprice,Famount," +
                         "Fnote,FKFDate,FKFPeriod,FPeriodDate," +
                         "FDCStockID,FDCSPID,FConsignPrice," +
                         "FDiscountRate,FDiscountAmount,FConsignAmount,FOrgBillEntryID,FSNListID," +
                         "FSourceBillNo,FSourceTranType,FSourceInterId,FSourceEntryID," +
                         "FContractBillNo,FContractInterID,FContractEntryID," +
                         "FOrderBillNo,FOrderInterID,FOrderEntryID," +
                         "FAllHookQTY,FCurrentHookQTY,FQtyMust,FSepcialSaleId," +
                         "FAuxQtyInvoice,FQtyInvoice" +
                         ") VALUES (" +
                     omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + ",'0','',''" +
                     "," + oSub.HMaterID.ToString() + ",0,'" + oSub.HBatchNo + "'," + oSub.HQty.ToString() + "," + oSub.HUnitID.ToString() +
                     "," + oSub.HAuxQtyMust.ToString() + "," + oSub.HAuxQty.ToString() + ",0," + oSub.HSecQty.ToString() +
                     "," + oSub.HAuxPlanPrice.ToString() + "," + oSub.HPlanAmount.ToString() + "," + oSub.HAuxPrice.ToString() + "," + oSub.HAmount.ToString() + "" +
                     ",'" + oSub.HRemark + "',null,0,null" +
                     "," + oSub.HWhID.ToString() + "," + oSub.HSPID.ToString() + ",0" +
                     ",0,0,0,0,0" +
                     ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceTranType + "'," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() +
                     ",'',0,0" +
                     ",'',0,0" +
                     ",0,0," + oSub.HQtyMust.ToString() + ",0" +
                     ",0,0" +
                     ")");
                }
                //主表
                oCnK3.RunProc("INSERT INTO ICStockBill(" +
                         "FInterID,FBillNo,FBrNo,FTranType,FCancellation," +
                         "FStatus,FUpStockWhenSave,FROB,FHookStatus,Fdate," +
                         "FSupplyID,FSaleStyle,FCheckDate,FFManagerID," +
                         "FSManagerID,FBillerID,FDCStockID," +
                         "FMultiCheckDate1,FMultiCheckDate2,FMultiCheckDate3,FVchInterID," +
                         "FMultiCheckDate4,FMultiCheckDate5,FPOOrdBillNo,FMultiCheckDate6," +
                         "FRelateBrID,FOrgBillInterID,FMarketingStyle,FSelTranType," +
                         "FBrID,FFetchAdd,FExplanation,FDeptID,FEmpID," +
                         "FManagerID,FVIPCardID,FVIPScore,FHolisticDiscountRate,FPOSName," +
                         "FWorkShiftId,FLSSrcInterID,FNote" +
                         ") VALUES (" +
                         omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "','0','" + this.BillType + "',0" +
                         ",0,0,1,0,'" + omodel.HDate.ToString() + "'" +
                         "," + omodel.HSupID + ",0,null," + omodel.HSecManagerID +
                         "," + omodel.HKeeperID + "," + FBillerID + "," + omodel.HWHID +
                         ",null,null,null,0" +
                         ",null,null,'',null" +
                         ",0,0,0,83" +
                         ",0,'" + omodel.HAddress + "','" + omodel.HExplanation + "'," + omodel.HDeptID.ToString() + "," + omodel.HEmpID.ToString() +
                         "," + omodel.HManagerID.ToString() + ",0,0,0,''" +
                         ",0,0,'" + omodel.HRemark + "')");
 
                //更新K3关联数量
                oCnK3.RunProc("EXEC p_UpdateBillRelateData " + this.BillType + "," + omodel.HInterID.ToString() + ",'ICStockBill','ICStockBillEntry'");
 
                //更新关联数量
                sReturn = "新增单据成功!";
                oCnK3.Commit();
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                oCnK3.RollBack();
                throw (e);
            }
        }
        //显示单据
        public override bool ShowBill(Int64 lngBillKey, ref string sReturn)
        {
            try
            {
                //查询主表
                DataSet Ds ;
                Ds = oCnK3.RunProcReturn("Select * from ICStockBill Where FInterID=" + lngBillKey.ToString(), "ICStockBill");
                if(Ds.Tables[0].Rows.Count==0)
                {
                    sReturn = "单据未找到!";
                    return false;
                }
                //赋值
                omodel.HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FInterID"].ToString());
                omodel.HBillNo = Ds.Tables[0].Rows[0]["FBillNo"].ToString().Trim();
                omodel.HDate = Convert.ToDateTime(Ds.Tables[0].Rows[0]["FDate"].ToString().Trim());
                omodel.HDeptID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FDeptID"].ToString());
                omodel.HEmpID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FEmpID"].ToString());
                omodel.HManagerID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FManagerID"].ToString());
                omodel.HSupID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FSupplyID"].ToString());
                omodel.HKeeperID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FSManagerID"].ToString());
                omodel.HSecManagerID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FFManagerID"].ToString());
                omodel.HWHID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FDCStockID"].ToString());
                omodel.HExplanation = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FExplanation"].ToString());
                omodel.HRemark = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["FNote"].ToString());
                //
                DataSet Ds1;
                Ds1 = oCnK3.RunProcReturn("select fname from t_User where fuserid=" + DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FBillerID"]), "t_User");
                if (Ds1.Tables[0].Rows.Count != 0)
                {
                    omodel.HMaker = Ds1.Tables[0].Rows[0][0].ToString();
                }
                omodel.HCheckDate = Ds.Tables[0].Rows[0]["FCheckDate"].ToString().Trim();
                if (DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FCheckerID"]) != 0)
                {
                    DataSet Ds2;
                    Ds2 = oCnK3.RunProcReturn("select fname from t_User where fuserid=" + DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["FCheckerID"]), "t_User");
                    if (Ds2.Tables[0].Rows.Count != 0)
                    {
                        omodel.HChecker = Ds2.Tables[0].Rows[0][0].ToString();
                    }
                }
                else
                {
                    omodel.HChecker = "";
                }
                //循环
                DataSet DsSub;
                DsSub = oCnK3.RunProcReturn("Select * from ICStockBillEntry Where FInterID=" + lngBillKey.ToString() + " order by HEntryID ", "ICStockBillEntry");
                DetailColl.Clear();//清空
                for (int i = 0; i < DsSub.Tables[0].Rows.Count; i++)
                {
                    Model.ClsKf_SellOutBillSub_CLD oSub = new Model.ClsKf_SellOutBillSub_CLD();
                    oSub.HInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["FInterID"].ToString());
                    oSub.HEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["FEntryID"].ToString());
                    oSub.HMaterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["FItemID"].ToString());
                    oSub.HAuxPropID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["FAuxPropID"].ToString());
                    oSub.HUnitID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["FUnitID"].ToString());
                    //oSub.FSecUnitID = ClsPub.isLong(DsSub.Tables[0].Rows[i]["FSecUnitID"].ToString());
                    oSub.HSecCoefficient = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["FSecCoefficient"].ToString());
                    oSub.HBatchNo = DsSub.Tables[0].Rows[i]["FBatchNo"].ToString().Trim();
                    oSub.HQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["FQty"].ToString());
                    oSub.HQtyMust = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["FQtyMust"].ToString());
                    oSub.HAuxQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["FAuxqty"].ToString());
                    oSub.HAuxQtyMust = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["FAuxQtyMust"].ToString());
                    oSub.HSecQty = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["FSecQty"].ToString());
                    oSub.HAuxPrice = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["FAuxprice"].ToString());
                    oSub.HAuxPlanPrice = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["FAuxPlanPrice"].ToString());
                    oSub.HAmount = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["FAmount"].ToString());
                    oSub.HPlanAmount = DBUtility.ClsPub.isDoule(DsSub.Tables[0].Rows[i]["FPlanAmount"].ToString());
                    //oSub.FEntrySupply = ClsPub.isLong(DsSub.Tables[0].Rows[i]["FEntrySupply"].ToString());
                    oSub.HWhID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["FDCStockID"].ToString());
                    oSub.HSPID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["FDCSPID"].ToString());
                    oSub.HRemark = DsSub.Tables[0].Rows[i]["FNote"].ToString().Trim();
 
                    //
                    oSub.HSourceInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["FSourceInterId"].ToString());
                    oSub.HSourceEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["FSourceEntryID"].ToString());
                    oSub.HSourceBillNo = DsSub.Tables[0].Rows[i]["FSourceBillNo"].ToString().Trim();
                    oSub.HSourceTranType = DsSub.Tables[0].Rows[i]["FSourceTranType"].ToString().Trim();
                    oSub.HOrderInterID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["FOrderInterID"].ToString());
                    oSub.HOrderEntryID = DBUtility.ClsPub.isLong(DsSub.Tables[0].Rows[i]["FOrderEntryID"].ToString());
                    oSub.HOrderBillNo = DsSub.Tables[0].Rows[i]["FOrderBillNo"].ToString().Trim();
                    //oSub.FSEOutInterID = ClsPub.isLong(DsSub.Tables[0].Rows[i]["FSEOutInterID"].ToString());
                    //oSub.FSEOutEntryID = ClsPub.isLong(DsSub.Tables[0].Rows[i]["FSEOutEntryID"].ToString());
                    //oSub.FSEOutBillNo = DsSub.Tables[0].Rows[i]["FSEOutBillNo"].ToString().Trim();
                    DetailColl.Add(oSub);
                }
                sReturn = "显示单据成功!";
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                throw (e);
            }
        }
 
        //删除单据
        public virtual bool DeleteBill(Int64 lngBillKey, ref string sReturn)
        {
            try
            {
                DataSet Ds;
                oCnK3.BeginTran();
                //
                //Ds = oCnK3.RunProcReturn("select FSourceInterID from  ICStockBillEntry where finterid=" + lngBillKey, "ICStockBillEntry");
                //删除关联 
                //删除明细表 
                //oCnK3.RunProc("Delete From  ICStockBillEntry where FInterID=" + lngBillKey.ToString());
                //删除主表
                //DeleteBillMain(lngBillKey);
                oCnK3.RunProc("Delete From icstockbill where FInterID=" + lngBillKey.ToString());
                //删除关联
 
                sReturn = "删除单据成功!";
                oCnK3.Commit();
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                oCnK3.RollBack();
                throw (e);
            }
        }
 
        //删除关联
        public override void DeleteRelation(ref string sReturn, Int64 lngBillKey)
        {
            //oCn.RunProc("exec h_p_K3_ProductInRequestRelationQtyBack " + lngBillKey + ",'3710'");
            //sReturn = "";
            return;
        }
        //单据号是否重复
        public virtual bool IsExistBillNo(ref string sReturn, string sBillNo, DBUtility.ClsPub.Enum_BillStatus oBillStatus, Int64 lngBillKey)
        {
            try
            {
                string sSql = "";
                if (oBillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew)
                {
                    sSql = "Select FInterID from ICStockBill where FTranType='" + MvarItemKey + "' and FBillNo ='" + sBillNo + "'";
                }
                else
                {
                    sSql = "Select FInterID from ICStockBill where FTranType='" + MvarItemKey + "' and FBillNo ='" + sBillNo + "' and FInterID<>" + lngBillKey.ToString();
                }
                DataSet Ds;
                Ds = oCnK3.RunProcReturn(sSql, "ICStockBill");
                if (Ds.Tables[0].Rows.Count != 0)
                {
                    sReturn = "单号重复";
                    return true;
                }
                sReturn = "单号未重复";
                return false;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                return false;
            }
        }
 
        //根据条码档案获取信息
        public Model.ClsKf_SellOutBillSub_CLD get_SellOutInfoByBarCode(string sBarCode)
        {
            try
            {
                Model.ClsKf_SellOutBillSub_CLD oSub = new Model.ClsKf_SellOutBillSub_CLD();
                DataSet Ds;
                Ds = oCn.RunProcReturn("exec h_p_Kf_SellOutInfoByBarCode '" + sBarCode + "'", "xt_xtgnb", ref DBUtility.ClsPub.sExeReturnInfo);
                if (Ds == null || Ds.Tables[0].Rows.Count == 0)
                {
                    return null;
                }
                oSub.HAmount = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HAmount"]);
                oSub.HAuxPrice = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HPrice"]);
                oSub.HAuxQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HQty"]);
                oSub.HBarCode = sBarCode;
                oSub.HBatchNo = Ds.Tables[0].Rows[0]["HBatchNo"].ToString();
                oSub.HMaterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HMaterID"]);
                return oSub;
            }
            catch (Exception e)
            {
                DBUtility.ClsPub.sExeReturnInfo += "根据条码获取相应信息失败!" + e.Message;
                return null;
            }
        }
 
        //条码扫描记录,新增到产品入库
        public bool AddBill_PDA(ref string sReturn)
        {
            try
            {
                DataSet Ds;
                oCnK3.BeginTran();
                //删除主表
                oCnK3.RunProc("Delete From ICStockBill  where FInterID=" + omodel.HInterID.ToString());
                //插入子表
                oCnK3.RunProc("EXEC h_p_Kf_SellOutBillSub_Insert_CLD " + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "'");
                //插入主表
                oCnK3.RunProc("INSERT INTO ICStockBill " +
                         "(FInterID,FBillNo,FBrNo,FTranType,FCancellation " +
                        ",FStatus,FUpStockWhenSave,FROB,FHookStatus,Fdate " +
                        ",FSupplyID,FSaleStyle,FCheckDate " +
                        ",FFManagerID,FSManagerID,FBillerID " +
                        ",FMultiCheckDate1,FMultiCheckDate2,FMultiCheckDate3 " +
                        ",FMultiCheckDate4,FMultiCheckDate5,FMultiCheckDate6 " +
                        ",FVchInterID,FPOOrdBillNo,FRelateBrID,FOrgBillInterID " +
                        ",FMarketingStyle,FSelTranType,FPrintCount,FBrID,FFetchAdd " +
                        ",FExplanation,FDeptID,FEmpID,FManagerID " +
                        ",FVIPCardID,FVIPScore,FHolisticDiscountRate,FPOSName " +
                        ",FWorkShiftId,FLSSrcInterID,FManageType,FSettleDate,FConsignee " +
                         ") VALUES (" +
                         omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "','0','" + this.BillType + "',0" +
                         ",0,0,1,0,convert(varchar(10),getdate(),120)" +
                         "," + omodel.HSupID.ToString() + ",101,Null " +
                         "," + omodel.HSecManagerID.ToString() + "," + omodel.HKeeperID.ToString() + "," + omodel.HBillerID.ToString() + 
                         ",null,null,null" +
                         ",null,null,null" +
                         ",0,'',0,0" +
                         ",12530,83,0,0,''" +
                         ",''," + omodel.HDeptID.ToString() + "," + omodel.HEmpID.ToString() + "," + omodel.HManagerID.ToString() +
                         ",0,0,0,''" +
                         ",0,0,0,convert(varchar(10),getdate(),120),0" +
                         ")");
                //更新K3关联数量
                //oCnK3.RunProc("EXEC p_UpdateBillRelateData " + this.BillType + "," + omodel.HInterID.ToString() + ",'ICStockBill','ICStockBillEntry'");
                oCnK3.RunProc("EXEC h_p_CLD_UpdateBillRelateData_SellOut_New " + omodel.HInterID.ToString());
                //更新单据NEWid
                //oCnK3.RunProc("UPDATE ICStockBill SET FUUID=NEWID() WHERE FInterID=" + omodel.HInterID.ToString());
                sReturn = "新增单据成功!";
                oCnK3.Commit();
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                oCnK3.RollBack();
                throw (e);
            }
        }
 
 
        //显示单据条码信息
        public bool ShowBill_Scheme(Int64 lngBillKey, ref string sReturn)
        {
            try
            {
                //循环子表2
                DataSet DsSubSec;
                DsSubSec = oCn.RunProcReturn("Select * from Kf_ICStockBillSub_WMS   with (nolock) Where HInterID=" + lngBillKey.ToString() + " and HBillType='" + this.BillType + "'", "Kf_ICStockBillSub_WMS");
                DetailSubColl.Clear();//清空
                for (int i = 0; i < DsSubSec.Tables[0].Rows.Count; i++)
                {
                    Model.ClsKf_SellOutBillScheme_CLD oSubSec = new Model.ClsKf_SellOutBillScheme_CLD();
                    oSubSec.HInterID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HInterID"].ToString());
                    oSubSec.HEntryID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HEntryID"].ToString());
                    oSubSec.HItemID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HItemID"].ToString());
                    oSubSec.HBillType = DsSubSec.Tables[0].Rows[i]["HBillType"].ToString();
                    oSubSec.HMaterID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HMaterID"].ToString());
                    oSubSec.HProcID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HProcID"].ToString());
                    oSubSec.HWhID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HWhID"].ToString());
                    oSubSec.HGroupID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HGroupID"].ToString());
                    oSubSec.HQty = DBUtility.ClsPub.isDoule(DsSubSec.Tables[0].Rows[i]["HQty"].ToString());
                    oSubSec.HBarCode = DsSubSec.Tables[0].Rows[i]["HBarCode"].ToString();
                    oSubSec.HAddr = DsSubSec.Tables[0].Rows[i]["HAddr"].ToString();
                    oSubSec.HMaker = DsSubSec.Tables[0].Rows[i]["HMaker"].ToString();
                    oSubSec.HMakeDate = DBUtility.ClsPub.isDate(DsSubSec.Tables[0].Rows[i]["HMakeDate"].ToString());
                    oSubSec.HSourceInterID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HSourceInterID"].ToString());
                    oSubSec.HSourceEntryID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HSourceEntryID"].ToString());
                    oSubSec.HSourceBillType = DsSubSec.Tables[0].Rows[i]["HSourceBillType"].ToString();
                    oSubSec.HSourceBillNo = DsSubSec.Tables[0].Rows[i]["HSourceBillNo"].ToString();
                    oSubSec.HSourceItemID = DBUtility.ClsPub.isLong(DsSubSec.Tables[0].Rows[i]["HSourceItemID"].ToString());
                    //
                    DetailSubColl.Add(oSubSec);
                }
                sReturn = "显示单据成功!";
                return true;
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                throw (e);
            }
        }
 
 
 
    }
}