1
duhe
2024-09-11 bb001d64dcb47dd59179f334719a8dd95d2908a0
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
using System;
using System.Collections.Generic;
using System.Text;
using SQLHelper;
using DBUtility;
using System.Data;
 
namespace DAL
{
    public class Cls_S_Xt_BaseBill1
    {
       
        public string mvarReportTitle;
        public string mvarItemKey;
        public string ViewName = "";
        public string sCondtion = "";
        public string sOrderSql = "";
        public string sKeyCol = "";
        public string sShowItemSql = "";
        //================================
        public string mvarReportTitle2;
        public string mvarItemKey2;
        public string ViewName2 = "";
        public string sCondtion2 = "";
        public string sOrderSql2 = "";
        public string sKeyCol2 = "";
        public string sShowItemSql2 = "";
        public frmHlpBillList1 oFrm;
        //public DAL.frmHlpBillList oFrm = new DAL.frmHlpBillList();
        public List<DBUtility.BillSelect> oBillSelectColl = new List<DBUtility.BillSelect>();
        public List<DBUtility.BillSelect_A3> oBillSelectColl2 = new List<DBUtility.BillSelect_A3>();
        //
        public Cls_S_Xt_BaseBill1()
        {
            //---
        }
 
 
        //显示数据
        /// <summary>
        /// 显示数据
        /// </summary>
        /// <param name="sWhere">主SQL</param>
        /// <param name="sCondtion">过滤条件</param>
        /// <param name="sOrderSql">排序条件</param>
        /// <param name="sKeyCol">不可重复列</param>
        /// <returns></returns>
        public virtual bool Refresh(string sWhere)
        {
            string sErr = "";
            int MainIDCol, SubIDCol, BillNoCol;
            string tSQL;
            ClsCN oCn = new ClsCN();
            tSQL = sWhere + sCondtion + sOrderSql;
            try
            {
                oFrm = new frmHlpBillList1();
                oFrm.sPrimaryCol = sKeyCol;
                oFrm.Text = mvarReportTitle;
                oFrm.lblCaption.Text = mvarReportTitle;
                oFrm.tSQL = tSQL;
                oFrm.ViewName = ViewName;
                
                oFrm.ShowDialog();
                if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
                {
                    //返回数据到集合中
                    oBillSelectColl.Clear();
                    MainIDCol = oFrm.Fun_GetCol("hmainid");
                    SubIDCol = oFrm.Fun_GetCol("hsubid");
                    BillNoCol = oFrm.Fun_GetCol("单据号");
 
                    //循环 选中行
                    for (int i = 0; i < oFrm.grdMain.SelectedRows.Count; i++)
                    {
                        BillSelect oSelect = new BillSelect();
                        oSelect.BillNo = ClsPub.isStrNull(oFrm.grdMain.Rows[oFrm.grdMain.SelectedRows[i].Index].Cells[BillNoCol].Value);
                        oSelect.BillMainID = ClsPub.isLong(oFrm.grdMain.Rows[oFrm.grdMain.SelectedRows[i].Index].Cells[MainIDCol].Value);
                        oSelect.BillSubID = ClsPub.isLong(oFrm.grdMain.Rows[oFrm.grdMain.SelectedRows[i].Index].Cells[SubIDCol].Value);
                        oSelect.BillTitle = mvarReportTitle;
                        oSelect.BillType = mvarItemKey;
                        oBillSelectColl.Add(oSelect);
                    }
                }
                //
                if (oBillSelectColl.Count > 0)
                    return true;
                else
                    return false;
            }
            catch (Exception e)
            {
                sErr = e.Message;
            }
            return true;
        }
 
 
        //显示数据2
        /// <summary>
        /// 显示数据2
        /// </summary>
        /// <param name="sWhere">主SQL</param>
        /// <param name="sCondtion">过滤条件</param>
        /// <param name="sOrderSql">排序条件</param>
        /// <param name="sKeyCol">不可重复列</param>
        /// <returns></returns>
        public virtual bool Refresh2(string sWhere)
        {
            string sErr = "";
            int MainIDCol, SubIDCol, BillNoCol;
            string tSQL;
            ClsCN oCn = new ClsCN();
            tSQL = sWhere + sCondtion2 + sOrderSql2;
            try
            {
                oFrm = new frmHlpBillList1();
                oFrm.sPrimaryCol = sKeyCol2;
                oFrm.Text = mvarReportTitle2;
                oFrm.lblCaption.Text = mvarReportTitle2;
                oFrm.tSQL = tSQL;
                oFrm.ViewName = ViewName2;
                oFrm.ShowDialog();
                if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
                {
                    //返回数据到集合中
                    oBillSelectColl.Clear();
                    MainIDCol = oFrm.Fun_GetCol("hmainid");
                    SubIDCol = oFrm.Fun_GetCol("hsubid");
                    BillNoCol = oFrm.Fun_GetCol("单据号");
                    //循环 选中行
                    for (int i = 0; i < oFrm.grdMain.SelectedRows.Count; i++)
                    {
                        BillSelect oSelect = new BillSelect();
                        oSelect.BillNo = ClsPub.isStrNull(oFrm.grdMain.Rows[oFrm.grdMain.SelectedRows[i].Index].Cells[BillNoCol].Value);
                        oSelect.BillMainID = ClsPub.isLong(oFrm.grdMain.Rows[oFrm.grdMain.SelectedRows[i].Index].Cells[MainIDCol].Value);
                        oSelect.BillSubID = ClsPub.isLong(oFrm.grdMain.Rows[oFrm.grdMain.SelectedRows[i].Index].Cells[SubIDCol].Value);
                        oSelect.BillTitle = mvarReportTitle2;
                        oSelect.BillType = mvarItemKey2;
                        oBillSelectColl.Add(oSelect);
                    }
                }
                //
                if (oBillSelectColl.Count > 0)
                    return true;
                else
                    return false;
            }
            catch (Exception e)
            {
                sErr = e.Message;
            }
            return true;
        }
 
        //显示数据3
        /// <summary>
        /// 显示数据3
        /// </summary>
        /// <param name="sWhere">主SQL</param>
        /// <param name="sCondtion">过滤条件</param>
        /// <param name="sOrderSql">排序条件</param>
        /// <param name="sKeyCol">不可重复列</param>
        /// <returns></returns>
        public virtual bool Refresh_A3(string sWhere)
        {
            string sErr = "";
            int MainIDCol, SubIDCol, BillNoCol;
            string tSQL;
            ClsCN oCn = new ClsCN();
            tSQL = sWhere + sCondtion2 + sOrderSql2;
            try
            {
                oFrm = new frmHlpBillList1();
                oFrm.sPrimaryCol = sKeyCol2;
                oFrm.Text = mvarReportTitle2;
                oFrm.lblCaption.Text = mvarReportTitle2;
                oFrm.tSQL = tSQL;
                oFrm.ViewName = ViewName2;
                oFrm.ShowDialog();
                if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
                {
                    //返回数据到集合中
                    oBillSelectColl2.Clear();
                    MainIDCol = oFrm.Fun_GetCol("hmainid");
                    SubIDCol = oFrm.Fun_GetCol("hsubid");
                    BillNoCol = oFrm.Fun_GetCol("单据号");
                    //循环 选中行
                    for (int i = 0; i < oFrm.grdMain.SelectedRows.Count; i++)
                    {
                        BillSelect_A3 oSelect = new BillSelect_A3();
                        oSelect.BillNo = ClsPub.isStrNull(oFrm.grdMain.Rows[oFrm.grdMain.SelectedRows[i].Index].Cells[BillNoCol].Value);
                        oSelect.BillMainID = ClsPub.isStrNull(oFrm.grdMain.Rows[oFrm.grdMain.SelectedRows[i].Index].Cells[MainIDCol].Value);
                        oSelect.BillSubID = ClsPub.isStrNull(oFrm.grdMain.Rows[oFrm.grdMain.SelectedRows[i].Index].Cells[SubIDCol].Value);
                        oSelect.BillTitle = mvarReportTitle2;
                        oSelect.BillType = mvarItemKey2;
                        oBillSelectColl2.Add(oSelect);
                    }
                }
                //
                if (oBillSelectColl2.Count > 0)
                    return true;
                else
                    return false;
            }
            catch (Exception e)
            {
                sErr = e.Message;
            }
            return true;
        }
 
 
 
 
 
        //返回单据列表
        /// <summary>
        /// 返回单据列表
        /// </summary>
        /// <param name="sWhere">过滤条件</param>
        public DataSet DisSourceBillList(string sWhere)
        {
            try
            {
                ClsCN oCn = new ClsCN();
                return oCn.RunProcReturn("select "+sShowItemSql+" from " + ViewName + "  " + sWhere + sCondtion + sOrderSql, ViewName, ref DBUtility.ClsPub.sExeReturnInfo);
            }
            catch (Exception e)
            {
                DBUtility.ClsPub.sExeReturnInfo += "返回单据列表失败!" + e.Message;
                return null;
            }
        }
 
        //返回单据列表
        /// <summary>
        /// 返回单据列表
        /// </summary>
        /// <param name="sWhere">过滤条件</param>
        public  DataSet DisSourceBillList2(string sWhere)
        {
            try
            {
                ClsCN oCn = new ClsCN();
                return oCn.RunProcReturn("select " + sShowItemSql2 + " from " + ViewName2 + "  " + sWhere + sCondtion2 + sOrderSql2, ViewName2, ref DBUtility.ClsPub.sExeReturnInfo);
            }
            catch (Exception e)
            {
                DBUtility.ClsPub.sExeReturnInfo += "返回单据列表失败!" + e.Message;
                return null;
            }
        }
 
        public virtual bool Refresh3(string sWhere)
        {
            string sErr = "";
            int MainIDCol, SubIDCol, BillNoCol;
            string tSQL;
            ClsCN oCn = new ClsCN();
            tSQL = sWhere + sCondtion + sOrderSql;
            try
            {
                oFrm = new frmHlpBillList1();
                oFrm.sPrimaryCol = sKeyCol;
                oFrm.Text = mvarReportTitle;
                oFrm.lblCaption.Text = mvarReportTitle;
                oFrm.tSQL = tSQL;
                oFrm.ViewName = ViewName;
                oFrm.ShowDialog();
                //返回数据到集合中
                oBillSelectColl.Clear();
                if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
                {
                    MainIDCol = oFrm.Fun_GetCol("HMaterID");
                    //SubIDCol = oFrm.Fun_GetCol("hsubid");
                    //BillNoCol = oFrm.Fun_GetCol("单据号");
                    //循环 选中行
                    for (int i = 0; i < oFrm.grdMain.SelectedRows.Count; i++)
                    {
                        BillSelect oSelect = new BillSelect();
                        //oSelect.BillNo = ClsPub.isStrNull(oFrm.grdMain.Rows[oFrm.grdMain.SelectedRows[i].Index].Cells[BillNoCol].Value);
                        oSelect.BillMainID = ClsPub.isLong(oFrm.grdMain.Rows[oFrm.grdMain.SelectedRows[i].Index].Cells[MainIDCol].Value);
                        //oSelect.BillSubID = ClsPub.isLong(oFrm.grdMain.Rows[oFrm.grdMain.SelectedRows[i].Index].Cells[SubIDCol].Value);
                        oSelect.BillTitle = mvarReportTitle;
                        oSelect.BillType = mvarItemKey;
                        oBillSelectColl.Add(oSelect);
                    }
                }
                //
                if (oBillSelectColl.Count > 0)
                    return true;
                else
                    return false;
            }
            catch (Exception e)
            {
                sErr = e.Message;
            }
            return true;
        }
 
        //根据源单号 模拟查询数据
        /// <summary>
        /// 显示数据
        /// </summary>
        /// <param name="sWhere">主SQL</param>
        /// <param name="sCondtion">过滤条件</param>
        /// <param name="sOrderSql">排序条件</param>
        /// <param name="sKeyCol">不可重复列</param>
        /// <returns></returns>
        public virtual bool RefreshBySourceBillNo(string sWhere)
        {
            string sErr = "";
            string tSQL;
            ClsCN oCn = new ClsCN();
            tSQL = " select hmainid,hsubid,单据号 from " + ViewName + sWhere + sOrderSql;
            try
            {
                DataSet ds = oCn.RunProcReturn(tSQL, ViewName, ref DBUtility.ClsPub.sExeReturnInfo);
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    return false;
                }
                //返回数据到集合中
                oBillSelectColl.Clear();
 
                //循环 选中行
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    BillSelect oSelect = new BillSelect();
                    oSelect.BillNo = ClsPub.isStrNull(ds.Tables[0].Rows[i]["单据号"]);
                    oSelect.BillMainID = ClsPub.isLong(ds.Tables[0].Rows[i]["hmainid"]);
                    oSelect.BillSubID = ClsPub.isLong(ds.Tables[0].Rows[i]["hsubid"]);
                    oSelect.BillTitle = mvarReportTitle;
                    oSelect.BillType = mvarItemKey;
                    oBillSelectColl.Add(oSelect);
                }
                //
                if (oBillSelectColl.Count > 0)
                    return true;
                else
                    return false;
            }
            catch (Exception e)
            {
                sErr = e.Message;
            }
            return true;
        }
 
 
 
    }
}