wtt
2025-04-22 770c739aeadfd1025bd6b64aa6790201b0b1047d
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
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
 
namespace DBUtility
{
    public class ClsGy_Base_View:IDisposable
    {
        public string MvarReportTitle;   //标题
        public string MvarItemKey;        //key  表名 视图名
        public string WherePart;        //查找
        public string SQLName;         //选择SQL
        public string SQLOrder;         //选择SQL
        public string SQLWhere;         //选择SQL
        public string SQLNameForNew;         //选择SQL
        public string SQLOrderForNew;         //选择SQL
        public string SQLWhereForNew;         //选择SQL
        public string SQLNameByRelation;  //选择SQL根据关联
        public string ViewNameForWeb;   //根据内码返回视图
        public string SQLNameForDown;         //选择SQL
        public string SQLOrderForDown;         //选择SQL
        public string SQLWhereForDown;         //选择SQL
        //big
        public string sBillView; 
        public string sBillShowItem;
        public string sBillColName;
        public string sBillColNumber;
        public string sBillOrder;
        //
        public string SQLList;
        //
        Pub_Class.ClsSqlHelper oCN = new Pub_Class.ClsSqlHelper();
        public ClsGy_Base_Model oModel = new ClsGy_Base_Model();
        public List<ClsGy_Base_Model> oModelList = new List<ClsGy_Base_Model>(); 
 
        public ClsGy_Base_View()
        {
             
        }
        //
        public void Dispose()
        {
            GC.SuppressFinalize(this);
        }
        //
 
 
 
        //帮助
        public virtual bool RefreshView(string sLike)
        {
            try
            {//
                Pub_Control.frmHlpInfo_View ofrm = new Pub_Control.frmHlpInfo_View();
                //
                string sSQL = SQLName + SQLWhere + sLike + SQLOrder;
                //编辑ofrm
                ofrm.sTitle = MvarReportTitle;
                ofrm.sBill = MvarItemKey;
                ofrm.txtFindInfo.Text = WherePart;
                //
                DataSet Ds;
                Pub_Class.ClsSqlHelper oCn = new Pub_Class.ClsSqlHelper();
                Ds = oCn.RunProcReturn(sSQL, MvarItemKey);
                if (Ds == null || Ds.Tables[0].Rows.Count == 0)
                {
                    return false;
                }
                //绑定
                ofrm.grdShow.DataSource = Ds.Tables[0].DefaultView;
                Ds.Dispose();
                Ds = null;
                ofrm.grdShow.SuspendLayout();
                ofrm.grdShow.Columns[0].Visible = false;
                ofrm.ShowDialog(); 
                //得到对应列 
                int HItemIDCol = 0;
                int HNumberCol = 1;
                int HNameCol = 2;
                //
                if (ofrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
                {
                    if (ofrm.grdShow.CurrentRow == null)
                    {
                        return false;
                    }
                    oModel = new ClsGy_Base_Model();
                    oModel.HItemID = Pub_Class.ClsPub.isLong(ofrm.grdShow.Rows[ofrm.grdShow.CurrentRow.Index].Cells[0].Value);
                    oModel.HNumber = Pub_Class.ClsPub.isStrNull(ofrm.grdShow.Rows[ofrm.grdShow.CurrentRow.Index].Cells[1].Value);
                    oModel.HName = Pub_Class.ClsPub.isStrNull(ofrm.grdShow.Rows[ofrm.grdShow.CurrentRow.Index].Cells[2].Value);
                }
                else
                {
                    return false;
                }
                //
                ofrm.Dispose();
                ofrm = null;
                //
                return true;
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
 
        /// <summary>
        /// 基础资料帮助-关联物料型
        /// </summary>
        /// <param name="HMaterID"></param>
        /// <returns></returns>
        public virtual bool RefreshViewByRelation(long HMaterID)
        {
            try
            {//
                Pub_Control.frmHlpInfo_View ofrm = new Pub_Control.frmHlpInfo_View();
                //
                string sSQL = SQLNameByRelation + " where HMaterID=" + HMaterID.ToString() + " order by HItemID";
                //编辑ofrm
                ofrm.sTitle = MvarReportTitle;
                ofrm.sBill = MvarItemKey;
                ofrm.txtFindInfo.Text = WherePart; 
                //
                DataSet Ds;
                Pub_Class.ClsSqlHelper oCn = new Pub_Class.ClsSqlHelper();
                Ds = oCn.RunProcReturn(sSQL, MvarItemKey);
                if (Ds == null || Ds.Tables[0].Rows.Count == 0)
                {
                    return false;
                }
                //绑定
                ofrm.grdShow.DataSource = Ds.Tables[0].DefaultView;
                Ds.Dispose();
                Ds = null;
                ofrm.grdShow.SuspendLayout();
                ofrm.grdShow.Columns[0].Visible = false;
                ofrm.ShowDialog();
                //得到对应列 
                int HItemIDCol = 0;
                int HNumberCol = 1;
                int HNameCol = 2;
                //
                if (ofrm.grdShow.CurrentRow == null)
                {
                    return false;
                }
                //
                if (ofrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
                {
                    if (ofrm.grdShow.CurrentRow == null)
                    {
                        return false;
                    }
                    oModel = new ClsGy_Base_Model();
                    oModel.HItemID = Pub_Class.ClsPub.isLong(ofrm.grdShow.Rows[ofrm.grdShow.CurrentRow.Index].Cells[0].Value);
                    oModel.HNumber = Pub_Class.ClsPub.isStrNull(ofrm.grdShow.Rows[ofrm.grdShow.CurrentRow.Index].Cells[1].Value);
                    oModel.HName = Pub_Class.ClsPub.isStrNull(ofrm.grdShow.Rows[ofrm.grdShow.CurrentRow.Index].Cells[2].Value);
                }
                else
                {
                    return false;
                }
                //
                ofrm.Dispose();
                ofrm = null;
                //
                return true;
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
        /// <summary>
        /// 基础资料帮助-全部型
        /// </summary>
        /// <returns></returns>
        public virtual bool RefreshView()
        {
            try
            {//
                Pub_Control.frmHlpInfo_View ofrm = new Pub_Control.frmHlpInfo_View();
                //
                string sSQL = SQLName + SQLWhere + SQLOrder;
                //编辑ofrm
                ofrm.sTitle = MvarReportTitle;
                ofrm.sBill = MvarItemKey;
                ofrm.txtFindInfo.Text = WherePart;
                
                //
                DataSet Ds;
                Pub_Class.ClsSqlHelper oCn = new Pub_Class.ClsSqlHelper();
                Ds = oCn.RunProcReturn(sSQL, MvarItemKey);
                if (Ds == null || Ds.Tables[0].Rows.Count == 0)
                {
                    return false;
                }
 
                //绑定
                ofrm.grdShow.DataSource = Ds.Tables[0].DefaultView;
                Ds.Dispose();
                Ds = null;
                ofrm.grdShow.SuspendLayout();
                ofrm.grdShow.Columns[0].Visible = false;
                ofrm.ShowDialog();
                //得到对应列 
                int HItemIDCol = 0;
                int HNumberCol = 1;
                int HNameCol = 2;
                //
                if (ofrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
                {
                    if (ofrm.grdShow.CurrentRow == null)
                    {
                        return false;
                    }
                    oModel = new ClsGy_Base_Model();
                    oModel.HItemID = Pub_Class.ClsPub.isLong(ofrm.grdShow.Rows[ofrm.grdShow.CurrentRow.Index].Cells[0].Value);
                    oModel.HNumber = Pub_Class.ClsPub.isStrNull(ofrm.grdShow.Rows[ofrm.grdShow.CurrentRow.Index].Cells[1].Value);
                    oModel.HName = Pub_Class.ClsPub.isStrNull(ofrm.grdShow.Rows[ofrm.grdShow.CurrentRow.Index].Cells[2].Value);
                }
                else
                {
                    return false;
                }
                //
                ofrm.Dispose();
                ofrm = null;
                //
                return true;
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
 
        /// <summary>
        /// 基础资料帮助-过滤条件型
        /// </summary>
        /// <param name="sWhere"></param>
        /// <returns></returns>
        public virtual bool RefreshViewForNew(string sWhere )
        {
            try
            {//
                Pub_Control.frmHlpInfo_View ofrm = new Pub_Control.frmHlpInfo_View();
                //
                string sSQL = SQLNameForNew + SQLWhereForNew + sWhere + SQLOrderForNew;
                //编辑ofrm
                ofrm.sTitle = MvarReportTitle;
                ofrm.sBill = MvarItemKey;
                ofrm.txtFindInfo.Text = WherePart;
 
                //
                DataSet Ds;
                Pub_Class.ClsSqlHelper oCn = new Pub_Class.ClsSqlHelper();
                Ds = oCn.RunProcReturn(sSQL, MvarItemKey);
                if (Ds == null || Ds.Tables[0].Rows.Count == 0)
                {
                    return false;
                }
 
                //绑定
                ofrm.grdShow.DataSource = Ds.Tables[0].DefaultView;
                Ds.Dispose();
                Ds = null;
                ofrm.grdShow.SuspendLayout();
                ofrm.grdShow.Columns[0].Visible = false;
                ofrm.ShowDialog();
                //得到对应列 
                int HItemIDCol = 0;
                int HNumberCol = 1;
                int HNameCol = 2;
                //
                if (ofrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
                {
                    if (ofrm.grdShow.CurrentRow == null)
                    {
                        return false;
                    }
                    oModel = new ClsGy_Base_Model();
                    oModel.HItemID = Pub_Class.ClsPub.isLong(ofrm.grdShow.Rows[ofrm.grdShow.CurrentRow.Index].Cells[0].Value);
                    oModel.HNumber = Pub_Class.ClsPub.isStrNull(ofrm.grdShow.Rows[ofrm.grdShow.CurrentRow.Index].Cells[1].Value);
                    oModel.HName = Pub_Class.ClsPub.isStrNull(ofrm.grdShow.Rows[ofrm.grdShow.CurrentRow.Index].Cells[2].Value);
                }
                else
                {
                    return false;
                }
                //
                ofrm.Dispose();
                ofrm = null;
                //
                return true;
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
 
        /// <summary>
        /// 基础资料帮助-返回多个项目型
        /// </summary>
        /// <returns></returns>
        public virtual bool RefreshViewMul()
        {
            try
            {//
                Pub_Control.frmHlpInfo_View ofrm = new Pub_Control.frmHlpInfo_View();
                //
                string sSQL = SQLName + SQLWhere + SQLOrder;
                //编辑ofrm
                ofrm.sTitle = MvarReportTitle;
                ofrm.sBill = MvarItemKey;
                ofrm.txtFindInfo.Text = WherePart;
 
                //
                DataSet Ds;
                Pub_Class.ClsSqlHelper oCn = new Pub_Class.ClsSqlHelper();
                Ds = oCn.RunProcReturn(sSQL, MvarItemKey);
                if (Ds == null || Ds.Tables[0].Rows.Count == 0)
                {
                    return false;
                }
 
                //绑定
                ofrm.grdShow.DataSource = Ds.Tables[0].DefaultView;
                Ds.Dispose();
                Ds = null;
                ofrm.grdShow.SuspendLayout();
                ofrm.grdShow.Columns[0].Visible = false;
                ofrm.ShowDialog();
                //得到对应列 
                int HItemIDCol = 0;
                int HNumberCol = 1;
                int HNameCol = 2;
                //
                oModelList.Clear();
                if (ofrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
                {
                    if (ofrm.grdShow.SelectedRows == null)
                    {
                        return false;
                    }
                    for (int i = 0; i < ofrm.grdShow.SelectedRows.Count; i++)
                    {
                        oModel = new ClsGy_Base_Model();
                        oModel.HItemID = Pub_Class.ClsPub.isLong(ofrm.grdShow.Rows[ofrm.grdShow.SelectedRows[i].Index].Cells[0].Value);
                        oModel.HNumber = Pub_Class.ClsPub.isStrNull(ofrm.grdShow.Rows[ofrm.grdShow.SelectedRows[i].Index].Cells[1].Value);
                        oModel.HName = Pub_Class.ClsPub.isStrNull(ofrm.grdShow.Rows[ofrm.grdShow.SelectedRows[i].Index].Cells[2].Value);
                        oModelList.Add(oModel);
                    }
                }
                else
                {
                    return false;
                }
                //
                ofrm.Dispose();
                ofrm = null;
                //
                return true;
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
 
        /// <summary>
        /// 基础资料帮助-大数据型
        /// </summary>
        /// <returns></returns>
        public virtual bool RefreshViewForBig(string sLike)
        {
            try
            {//
                Pub_Control.frmHlpInfoForBig ofrm = new Pub_Control.frmHlpInfoForBig();
                //
                //string sSQL = SQLName + SQLWhere + SQLOrder;
                //编辑ofrm
                ofrm.sTitle = MvarReportTitle;
                ofrm.sBill = sBillView;
                ofrm.txtFindInfo.Text = "";
                ofrm.sOtherItem = sBillShowItem;
                ofrm.sNameColName =sBillColName;
                ofrm.sNumberColName = sBillColNumber;
                ofrm.sOrderItem = sBillOrder;
                ofrm.sLike = sLike;
 
                //
                DataSet Ds;
                Pub_Class.ClsSqlHelper oCn = new Pub_Class.ClsSqlHelper();
                //Ds = oCn.RunProcReturn(sSQL, MvarItemKey);
                //if (Ds == null || Ds.Tables[0].Rows.Count == 0)
                //{
                //    return false;
                //}
 
                //绑定
                //ofrm.grdShow.DataSource = Ds.Tables[0].DefaultView;
                //Ds.Dispose();
                //Ds = null;
                ofrm.grdShow.SuspendLayout();
                //ofrm.grdShow.Columns[0].Visible = false;
                ofrm.ShowDialog();
                //得到对应列 
                int HItemIDCol = 0;
                int HNumberCol = 1;
                int HNameCol = 2;
                //
                if (ofrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
                {
                    if (ofrm.grdShow.CurrentRow == null)
                    {
                        return false;
                    }
                    //for (int i = 0; i < ofrm.grdShow.SelectedRows.Count; i++)
                    //{
                        oModel = new ClsGy_Base_Model();
                        oModel.HItemID = Pub_Class.ClsPub.isLong(ofrm.grdShow.Rows[ofrm.grdShow.SelectedRows[0].Index].Cells[0].Value); 
                        oModelList.Add(oModel);
                    //}
                }
                else
                {
                    return false;
                }
                //
                ofrm.Dispose();
                ofrm = null;
                //
                return true;
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
 
        /// <summary>
        /// 基础资料帮助-下拉框型
        /// </summary>
        /// <param name="s"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        public virtual bool RefreshViewDownMenu(string s,int x,int y)
        {
            try
            {//
                Pub_Control.frmDownMenu ofrm = new Pub_Control.frmDownMenu();
                //
                string sSQL = SQLNameForDown + SQLWhereForDown + s + SQLOrderForDown;
                //编辑ofrm
                ofrm.x = x;
                ofrm.y = y;
                ofrm.sWhere = s;
                ofrm.sTitle = this.MvarReportTitle;
 
                //
                DataSet Ds;
                Pub_Class.ClsSqlHelper oCn = new Pub_Class.ClsSqlHelper();
                Ds = oCn.RunProcReturn(sSQL, MvarItemKey);
                if (Ds == null || Ds.Tables[0].Rows.Count == 0)
                {
                    return false;
                } 
                //绑定
                ofrm.grdMain.DataSource = Ds.Tables[0].DefaultView;
                Ds.Dispose();
                Ds = null;
                ofrm.grdMain.SuspendLayout();
                ofrm.grdMain.Columns[0].Visible = false;
                ofrm.ShowDialog();
                //得到对应列 
                int HItemIDCol = 0;
                int HNumberCol = 1;
                int HNameCol = 2;
                //
                if (ofrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
                {
                    if (ofrm.grdMain.CurrentRow == null)
                    {
                        return false;
                    }
                    oModel = new ClsGy_Base_Model();
                    oModel.HItemID = Pub_Class.ClsPub.isLong(ofrm.grdMain.Rows[ofrm.grdMain.CurrentRow.Index].Cells[HItemIDCol].Value);
                    oModel.HNumber = Pub_Class.ClsPub.isStrNull(ofrm.grdMain.Rows[ofrm.grdMain.CurrentRow.Index].Cells[HNumberCol].Value);
                    oModel.HName = Pub_Class.ClsPub.isStrNull(ofrm.grdMain.Rows[ofrm.grdMain.CurrentRow.Index].Cells[HNameCol].Value);
                }
                else
                {
                    return false;
                }
                //
                ofrm.Dispose();
                ofrm = null;
                //
                return true;
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
        /// <summary>
        /// 根据内码返回Dataset
        /// </summary>
        /// <param name="sItemID"></param>
        /// <returns></returns>
        public virtual DataSet GetDSByID(Int64 sItemID)
        {
            DataSet DS;
            try
            {
                DS = oCN.RunProcReturn("Select * from " + ViewNameForWeb + " Where HItemID='" + sItemID + "'", ViewNameForWeb, ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                {
                    return DS;
                }
                else
                {
                    return DS;
                }
            }
            catch (Exception e)
            {
                return null;
            }
        }
 
 
        //返回项目信息
        public virtual bool GetInfoByID(Int64 sItemID)
        {
            return true;
        }
        //根据代码返回项目信息
        public virtual bool GetInfoByNumber(string sNumber)
        {
            return true;
        }
        //根据名称返回项目信息
        public virtual bool GetInfoByName(string sName)
        {
            DataSet DS;
            try
            {
                DS = oCN.RunProcReturn("Select * from " + MvarItemKey + " Where HName='" + sName + "'", MvarItemKey, ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                    return false;
                else
                {
                    return GetInfo(DS);
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
        //返回项目信息
        public virtual bool GetInfo(DataSet DS)
        {
            return true;
        }
 
        /// <summary>
        /// 根据sWhere 返回项目集合Dataset
        /// </summary>
        /// <param name="sWhere"></param>
        /// <returns></returns>
        public virtual DataSet GetList(string sWhere)
        {
            try
            {
                return oCN.RunProcReturn(SQLList + " " + sWhere + " Order by HNumber ", this.MvarItemKey, ref ClsPub.sExeReturnInfo);
            }
            catch (Exception e)
            {
                ClsPub.sExeReturnInfo += "返回列表失败!" + e.Message;
                return null;
            }
        }
    }
}