yxj
2023-09-23 fc8127e549c87edefe168cf48ebbfa90cbe62b84
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
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DBUtility;
using DAL;
 
namespace BLL
{
    public partial class Xt_UserNew : Form
    {
        public Xt_UserNew()
        {
            InitializeComponent();
        }
 
        public Pub_Class.ClsPub.Enum_InputMode InputMode;  //¼Èë״̬±êÖ¾(0-·Ç¼Èë״̬ 1-Ôö¼Ó 2-ÐÞ¸Ä)
        public string Czybm;
        public Int64 HOrgID = -1;
        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
        //´°Ìå¼ÓÔØ
        private void Xt_UserNew_Load(object sender, EventArgs e)
        {
            lblError.Text = "";
            LbYes.Items.Clear();
            LbNo.Items.Clear();
            cmbHUserType.SelectedIndex = 0;
            //¼ÓÔØ×éÖ¯ÐÅÏ¢
            Sub_AddOrdList();
            Init();
            Display();
        }
 
        //¼ÓÔØ×éÖ¯ÐÅÏ¢
        private void Sub_AddOrdList()
        {
            DataSet ds;
            DAL.ClsGy_ORGANIZATIONS_View oClsGy_ORGANIZATIONS_View = new DAL.ClsGy_ORGANIZATIONS_View();
            ds = oClsGy_ORGANIZATIONS_View.GetList();
            if (ds == null || ds.Tables[0].Rows.Count == 0)
            {
                MessageBox.Show("»ñÈ¡×é֯ʧ°Ü");
                return;
            }
            cmbHOrgID.Items.Clear();
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                cmbHOrgID.Items.Add(DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HName"]));
            }
        }
 
        //²éÕÒÊý¾Ý----Óû§×é
        private void Display()
        {
            if (InputMode == Pub_Class.ClsPub.Enum_InputMode.InputMode_AddNew)
            {
                try
                {
                    SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
                    DataSet oDs = new DataSet();
                    oDs = oCn.RunProcReturn("select GroupID,GroupName from  System_UserGroup order by GroupName", "System_UserGroup", ref ClsPub.sExeReturnInfo);
                    if (oDs == null)
                    {
                        MessageBox.Show("ÏÔʾʧ°Ü£¡Ô­Òò£º" + ClsPub.sExeReturnInfo);
                        return;
                    }
                    //
                    for (int i = 0; i <= oDs.Tables[0].Rows.Count - 1; i++)
                    {
                        LbNo.Items.Add(oDs.Tables[0].Rows[i][0].ToString().Trim() + "-" + oDs.Tables[0].Rows[i][1].ToString().Trim());
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "Ìáʾ");
                    return;
                }
            }
            else
            {
                try
                {
                    SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
                    DataSet oDs = new DataSet();
                    DataSet oDS = new DataSet();
                    //¼ÓÔØ²»Êô×é
                    oDs = oCn.RunProcReturn("select GroupID,GroupName from  System_UserGroup"
                    +" where Groupid not IN (select Groupid  from  system_UserGroupInfo where userid='"+Czybm+"')", "System_UserGroup", ref ClsPub.sExeReturnInfo);
                    if (oDs == null)
                    {
                        MessageBox.Show("ÏÔʾʧ°Ü£¡Ô­Òò£º" + ClsPub.sExeReturnInfo);
                        return;
                    }
                    //
                    if (oDs.Tables[0].Rows.Count != 0)
                    {
                        for (int i = 0; i <= oDs.Tables[0].Rows.Count - 1; i++)
                        {
 
                            LbNo.Items.Add(oDs.Tables[0].Rows[i][0].ToString().Trim() + "-" + oDs.Tables[0].Rows[i][1].ToString().Trim());
                        }
                    }
                    //¼ÓÔØÊôÓÚ×é
                    oDS = oCn.RunProcReturn("select GroupID,GroupName from  System_UserGroup"
                    + " where Groupid IN (select Groupid  from   system_UserGroupInfo where userid='" + Czybm + "')", "System_UserGroup", ref ClsPub.sExeReturnInfo);
                    if (oDS == null)
                    {
                        MessageBox.Show("ÏÔʾʧ°Ü£¡Ô­Òò£º" + ClsPub.sExeReturnInfo);
                        return;
                    }
                    //
                    if (oDS.Tables[0].Rows.Count != 0)
                    {
                        for (int i = 0; i <= oDS.Tables[0].Rows.Count - 1; i++)
                        {
 
                            LbYes.Items.Add(oDS.Tables[0].Rows[i][0].ToString().Trim() + "-" + oDS.Tables[0].Rows[i][1].ToString().Trim());
                        }
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "Ìáʾ");
                    return;
                }
            }
        }
        //³õʼ»¯½çÃæ
        private void Init()
        {
            txtHK3UserID.ReadOnly = true;
            txtHKeeperID.ReadOnly = true;
            txtHSecManagerID.ReadOnly = true;
            txtHSellManID.ReadOnly = true;
            txtHDeptID.ReadOnly = true;
            txtHWhID.ReadOnly = true;
            txtHSCWH.ReadOnly = true;
            txtHSupID.ReadOnly = true;
            if (InputMode == Pub_Class.ClsPub.Enum_InputMode.InputMode_AddNew)
            {
                txtCzybm.Text = "";
                txtCzymc.Text = "";
                txtCzymm.Text = "";
                txtCzyyz.Text = "";
                txtExplain.Text = "";
                txtHEmpID.Text = "";
                txtHK3UserID.Text = "";
                txtHKeeperID.Text = "";
                txtHSecManagerID.Text = "";
                txtHSellManID.Text = "";
                txtHDeptID.Text = "";
                txtHWhID.Text = "";
                txtHSCWH.Text = "";
                txtHSupID.Text = "";
                txtHCloudUserName.Text = "";
                txtHCloudUserPsd.Text = "";
                cmdAllRight.PerformClick();
 
                //»ñÈ¡µ±Ç°×éÖ¯ÐÅÏ¢
                DataSet Ds1 = oCn.RunProcReturn("select * from Xt_ORGANIZATIONS with(nolock) where HItemID=" + ClsPub.HOrgID, "Xt_ORGANIZATIONS", ref DBUtility.ClsPub.sExeReturnInfo);
                if (Ds1.Tables[0].Rows.Count != 0)
                {
                    cmbHOrgID.Text = DBUtility.ClsPub.isStrNull(Ds1.Tables[0].Rows[0]["HName"]);
                }
            }
            else
            {
                txtCzybm.ReadOnly = true;
                txtCzymm.ReadOnly = true;
                txtCzyyz.ReadOnly = true;
                ShowData(Czybm);
            }
        }
        //¼ÓÔØ±íÍ·
        private void ShowData(string sCzybm)
        {
            DataSet oDs = new DataSet();
            DAL.ClsIF_User_View oUser = new ClsIF_User_View();
            DAL.ClsIF_Employee_View oEmp = new DAL.ClsIF_Employee_View();
            DAL.ClsIF_ORGANIZATIONS_View oORG = new DAL.ClsIF_ORGANIZATIONS_View();
            DAL.ClsIF_Department_View oDep = new DAL.ClsIF_Department_View();
            DAL.ClsIF_Warehouse_View oWh = new DAL.ClsIF_Warehouse_View();
            DAL.ClsIF_Supplier_View oSup = new DAL.ClsIF_Supplier_View();
            try
            {
                oDs = oCn.RunProcReturn("select Czybm,Czymc,Explain,HEmpID,HK3UserID,HCloudUserName,HCloudUserPsd,HKeeperID,HKeeper,HSecManagerID,HSecManager,HSellManID,HSellMan,HDeptID,HDept,HWhID,HWHName,HSCWHID,HSCWHName,HSupID,HSupName,HUSEORGID,HUserType from Gy_Czygl where Czybm='" + sCzybm + "'", "Gy_Czygl", ref ClsPub.sExeReturnInfo);
                if (oDs == null)
                {
                    MessageBox.Show("ÏÔʾʧ°Ü£¡Ô­Òò£º" + ClsPub.sExeReturnInfo);
                    return;
                }
                else if (oDs.Tables[0].Rows.Count != 0)
                {
                    txtCzybm.Text = oDs.Tables[0].Rows[0]["Czybm"].ToString().Trim();
                    txtCzymc.Text = oDs.Tables[0].Rows[0]["Czymc"].ToString().Trim();
                    txtCzymm.Text = "*****";
                    txtCzyyz.Text = "*****";
                    txtExplain.Text = oDs.Tables[0].Rows[0]["Explain"].ToString().Trim();
 
                    if (oORG.GetInfoByID(ClsPub.isLong(oDs.Tables[0].Rows[0]["HUSEORGID"])))
                    {
                        cmbHOrgID.Text = ClsPub.isStrNull(oORG.omodel.HName);
                    }
                    else
                    {
                        cmbHOrgID.Text = "";
                    }
                    if (oEmp.GetInfoByID(ClsPub.isLong(oDs.Tables[0].Rows[0]["HEmpID"])))
                    {
                        txtHEmpID.Text = ClsPub.isStrNull(oEmp.omodel.HName);
                        txtHEmpID.Tag = ClsPub.isLong(oEmp.omodel.HItemID);
                    }
                    else
                    {
                        txtHEmpID.Text = "";
                        txtHEmpID.Tag = 0;
                    }
                    if (oUser.GetInfoByID(ClsPub.isLong(oDs.Tables[0].Rows[0]["HK3UserID"])))
                    {
                        txtHK3UserID.Text = ClsPub.isStrNull(oUser.omodel.HName);
                        txtHK3UserID.Tag = ClsPub.isLong(oUser.omodel.HItemID);
                    }
                    else
                    {
                        txtHK3UserID.Text = "";
                        txtHK3UserID.Tag = 0;
                    }
                    if (oEmp.GetInfoByID(ClsPub.isLong(oDs.Tables[0].Rows[0]["HKeeperID"])))
                    {
                        txtHKeeperID.Text = ClsPub.isStrNull(oEmp.omodel.HName);
                        txtHKeeperID.Tag = ClsPub.isLong(oEmp.omodel.HItemID);
                    }
                    else
                    {
                        txtHKeeperID.Text = "";
                        txtHKeeperID.Tag = 0;
                    }
                    if (oEmp.GetInfoByID(ClsPub.isLong(oDs.Tables[0].Rows[0]["HSecManagerID"])))
                    {
                        txtHSecManagerID.Text = ClsPub.isStrNull(oEmp.omodel.HName);
                        txtHSecManagerID.Tag = ClsPub.isLong(oEmp.omodel.HItemID);
                    }
                    else
                    {
                        txtHSecManagerID.Text = "";
                        txtHSecManagerID.Tag = 0;
                    }
                    if (oEmp.GetInfoByID(ClsPub.isLong(oDs.Tables[0].Rows[0]["HSellManID"])))
                    {
                        txtHSellManID.Text = ClsPub.isStrNull(oEmp.omodel.HName);
                        txtHSellManID.Tag = ClsPub.isLong(oEmp.omodel.HItemID);
                    }
                    else
                    {
                        txtHSellManID.Text = "";
                        txtHSellManID.Tag = 0;
                    }
                    if (oDep.GetInfoByIDandOrgID(ClsPub.isLong(oDs.Tables[0].Rows[0]["HDeptID"]), ClsPub.isLong(oDs.Tables[0].Rows[0]["HUSEORGID"])))
                    {
                        txtHDeptID.Text = ClsPub.isStrNull(oDep.omodel.HName);
                        txtHDeptID.Tag = ClsPub.isLong(oDep.omodel.HItemID);
                    }
                    else
                    {
                        txtHDeptID.Text = "";
                        txtHDeptID.Tag = 0;
                    }
                    if (oWh.GetInfoByIDandOrgID(ClsPub.isLong(oDs.Tables[0].Rows[0]["HWhID"]), ClsPub.isLong(oDs.Tables[0].Rows[0]["HUSEORGID"])))
                    {
                        txtHWhID.Text = ClsPub.isStrNull(oWh.omodel.HName);
                        txtHWhID.Tag = ClsPub.isLong(oWh.omodel.HItemID);
                    }
                    else
                    {
                        txtHWhID.Text = "";
                        txtHWhID.Tag = 0;
                    }
                    if (oWh.GetInfoByIDandOrgID(ClsPub.isLong(oDs.Tables[0].Rows[0]["HSCWHID"]), ClsPub.isLong(oDs.Tables[0].Rows[0]["HUSEORGID"])))
                    {
                        txtHSCWH.Text = ClsPub.isStrNull(oWh.omodel.HName);
                        txtHSCWH.Tag = ClsPub.isLong(oWh.omodel.HItemID);
                    }
                    else
                    {
                        txtHSCWH.Text = "";
                        txtHSCWH.Tag = 0;
                    }
                    if (oSup.GetInfoByIDandOrgID(ClsPub.isLong(oDs.Tables[0].Rows[0]["HSupID"]), ClsPub.isLong(oDs.Tables[0].Rows[0]["HUSEORGID"])))
                    {
                        txtHSupID.Text = ClsPub.isStrNull(oSup.omodel.HName);
                        txtHSupID.Tag = ClsPub.isLong(oSup.omodel.HItemID);
                    }
                    else
                    {
                        txtHSupID.Text = "";
                        txtHSupID.Tag = 0;
                    }
                    txtHCloudUserName.Text = oDs.Tables[0].Rows[0]["HCloudUserName"].ToString().Trim();
                    txtHCloudUserPsd.Text = oDs.Tables[0].Rows[0]["HCloudUserPsd"].ToString().Trim();
                    if (oDs.Tables[0].Rows[0]["HUserType"].ToString() != "")
                    {
                        cmbHUserType.Text = oDs.Tables[0].Rows[0]["HUserType"].ToString().Trim();
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Ìáʾ");
                return;
            }
        }
        //È¡Ïû
        private void cmdCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        //×óÒÆ
        private void cmdLeft_Click(object sender, EventArgs e)
        {
            if (this.LbNo.SelectedItems.Count > 0)
            {
                int i = this.LbNo.SelectedIndex;
                this.LbYes.Items.Add(this.LbNo.SelectedItem.ToString());
                this.LbNo.Items.RemoveAt(i);
            }
        }
        //È«²¿×óÒÆ
        private void cmdAllLeft_Click(object sender, EventArgs e)
        {
            if (this.LbNo.Items.Count > 0)
            {
                for (int i = 0; i <= this.LbNo.Items.Count - 1; i++)
                {
                    this.LbYes.Items.Add(this.LbNo.Items[i].ToString());
                    this.LbNo.Items.RemoveAt(i);
                    i--;
                }
            }
        }
        //ÓÒÒÆ
        private void cmdRight_Click(object sender, EventArgs e)
        {
            if (this.LbYes.SelectedItems.Count > 0)
            {
                int i = this.LbYes.SelectedIndex;
                this.LbNo.Items.Add(this.LbYes.SelectedItem.ToString());
                this.LbYes.Items.RemoveAt(i);
            }
        }
        //È«²¿ÓÒÒÆ
        private void cmdAllRight_Click(object sender, EventArgs e)
        {
            if (this.LbYes.Items.Count > 0)
            {
                for (int i = 0; i <= this.LbYes.Items.Count - 1; i++)
                {
                    this.LbNo.Items.Add(this.LbYes.Items[i].ToString());
                    this.LbYes.Items.RemoveAt(i);
                    i--;
                }
            }
        }
        //È·¶¨
        private void cmdOK_Click(object sender, EventArgs e)
        {
            lblError.Text = "";
            DataSet oDs = new DataSet();
            if (!Sub_AllowSave())   //µ¥¾ÝÍêÕûÐÔÅжÏ
            {
                tabControl1.SelectedIndex = 0;
                return;
            }
 
            DAL.ClsGy_ORGANIZATIONS_View oClsGy_ORGANIZATIONS_View = new DAL.ClsGy_ORGANIZATIONS_View();
            if (oClsGy_ORGANIZATIONS_View.GetInfoByName(cmbHOrgID.Text))
            {
                HOrgID = oClsGy_ORGANIZATIONS_View.omodel.HItemID;
            }
            if (HOrgID == -1)
            {
                MessageBox.Show("Ñ¡Ôñ×éÖ¯ÓдíÎó£¡");
                return;
            }
 
            if (InputMode == Pub_Class.ClsPub.Enum_InputMode.InputMode_AddNew)
            {
                oCn.RunProc("insert into Gy_Czygl (Czybm,Czymc,Czmm,Explain,HempID,HK3UserID " +
                    ",HKeeperID,HKeeper,HSecManagerID,HSecManager " +
                    ",HSellManID,HSellMan,HDeptID,HDept " +
                    ",HWhID,HWHName,HSupID,HSupName " +
                    ",HSCWHID,HSCWHName,HUserType " +
                    ",HCloudUserName,HCloudUserPsd,HUSEORGID)" +
                    "values ("
                    + "'" + txtCzybm.Text.ToString() + "','" + txtCzymc.Text.ToString() + "','" + ClsPub.StrToPsd(txtCzymm.Text.ToString()) + "','" + txtExplain.Text.ToString() + "'," + ClsPub.isLong(txtHEmpID.Tag).ToString() + "," + ClsPub.isLong(txtHK3UserID.Tag).ToString() +
                    "," + ClsPub.isLong(txtHKeeperID.Tag).ToString() + ",'" + txtHKeeperID.Text.ToString() + "'," + ClsPub.isLong(txtHSecManagerID.Tag).ToString() + ",'" + txtHSecManagerID.Text.ToString() + "'" +
                    "," + ClsPub.isLong(txtHSellManID.Tag).ToString() + ",'" + txtHSellManID.Text.ToString() + "'," + ClsPub.isLong(txtHDeptID.Tag).ToString() + ",'" + txtHDeptID.Text.ToString() + "'" +
                    "," + ClsPub.isLong(txtHWhID.Tag).ToString() + ",'" + txtHWhID.Text.ToString() + "'," + ClsPub.isLong(txtHSupID.Tag).ToString() + ",'" + txtHSupID.Text.ToString() + "'" +
                    "," + ClsPub.isLong(txtHSCWH.Tag).ToString() + ",'" + txtHSCWH.Text.ToString() + "'" + ",'" + cmbHUserType.Text + "'" +
                    ",'" + txtHCloudUserName.Text.ToString() + "','" + txtHCloudUserPsd.Text.ToString() + "'," + HOrgID +
                    ")");
                oDs = oCn.RunProcReturn("Select * from  Gy_Czygl where Czybm='" + txtCzybm.Text.ToString()+"'", "Gy_Czygl");
                if (oDs == null || oDs.Tables[0].Rows.Count == 0)
                {
                    MessageBox.Show("ÐÂÔöʧ°Ü£¡", "Ìáʾ");
                }
                this.Czybm = oDs.Tables[0].Rows[0]["Czybm"].ToString();
                oCn.RunProc("delete from  System_UserGroupInfo where UserId='" + Czybm.ToString()+"'");
                for (int i = 0; i <= LbYes.Items.Count - 1; i++)
                {
                    oCn.RunProc("insert into System_UserGroupInfo (GroupId,UserId) values (" +ClsPub.isLong(Get_Code(this.LbYes.Items[i].ToString())) + ",'" + Czybm.ToString() + "')");
                }
                lblError.Text = "* ÐÂÔö³É¹¦£¡";
                Init();
                tabControl1.SelectedIndex = 0;
            }
            else
            {
                oCn.RunProc("update Gy_Czygl set Czymc='" + txtCzymc.Text.ToString() + "'" +
                    ",Explain='" + txtExplain.Text.ToString() + "'" +
                    ",HEmpID=" + ClsPub.isLong(txtHEmpID.Tag).ToString() +
                    ",HK3UserID=" + ClsPub.isLong(txtHK3UserID.Tag).ToString() +
                    ",HKeeperID=" + ClsPub.isLong(txtHKeeperID.Tag).ToString() +
                    ",HKeeper='" + txtHKeeperID.Text.ToString() + "'" +
                    ",HSecManagerID=" + ClsPub.isLong(txtHSecManagerID.Tag).ToString() +
                    ",HSecManager='" + txtHSecManagerID.Text.ToString() + "'" +
                    ",HSellManID=" + ClsPub.isLong(txtHSellManID.Tag).ToString() +
                    ",HSellMan='" + txtHSellManID.Text.ToString() + "'" +
                    ",HDeptID=" + ClsPub.isLong(txtHDeptID.Tag).ToString() +
                    ",HDept='" + txtHDeptID.Text.ToString() + "'" +
                    ",HWhID=" + ClsPub.isLong(txtHWhID.Tag).ToString() +
                    ",HWHName='" + txtHWhID.Text.ToString() + "'" +
                    ",HSCWHID=" + ClsPub.isLong(txtHSCWH.Tag).ToString() +
                    ",HSCWHName='" + txtHSCWH.Text.ToString() + "'" +
                    ",HSupID=" + ClsPub.isLong(txtHSupID.Tag).ToString() +
                    ",HSupName='" + txtHSupID.Text.ToString() + "'" +
                    ",HCloudUserName='" + txtHCloudUserName.Text.ToString() + "'" +
                    ",HCloudUserPsd='" + txtHCloudUserPsd.Text.ToString() + "'" +
                    ",HUserType='" + cmbHUserType.Text.ToString() + "'" +
                    ",HUSEORGID=" + HOrgID.ToString() +
                    "where Czybm='" + Czybm + "'");
                //
                oCn.RunProc("delete from System_UserGroupInfo where UserId='" +Czybm+"'");
                for (int i = 0; i <= LbYes.Items.Count - 1; i++)
                {
                    oCn.RunProc("insert into  System_UserGroupInfo (GroupId,UserId) values (" + ClsPub.isLong(Get_Code(this.LbYes.Items[i].ToString())) + ",'" + Czybm + "')");
                }
                lblError.Text = "* Ð޸ijɹ¦£¡";
                tabControl1.SelectedIndex = 0;
            }
        }
        //µ¥¾ÝÍêÕûÐÔÅжÏ
        private bool Sub_AllowSave()
        {
            if (txtCzybm.Text.Trim() == "")
            {
                lblError.Text = "* ±àÂë²»ÄÜΪ¿Õ£¡";
                return false;
            }
            if (txtCzymc.Text.Trim() == "")
            {
                lblError.Text = "* Óû§Ãû²»ÄÜΪ¿Õ£¡";
                return false;
            }
            // ÑéÖ¤ÃÜÂë
            if (txtCzymm.Text.Trim() != "")
            {
                if (txtCzymm.Text.Trim() != txtCzyyz.Text.Trim())
                {
                    lblError.Text = "* ÃÜÂëÑéÖ¤´íÎó£¡";
                    return false;
                }
            }
            // Óû§±àÂëºÍÓû§Ãû ÊÇ·ñÖØ¸´
            if (InputMode == Pub_Class.ClsPub.Enum_InputMode.InputMode_AddNew)
            {
                DataSet oDs = new DataSet();
                DataSet oDS = new DataSet();
                oDs = oCn.RunProcReturn("select * from  Gy_Czygl where Czybm='" + txtCzybm.Text.ToString()+"'", "Gy_Czygl");
                oDS = oCn.RunProcReturn("select * from  Gy_Czygl where Czymc='" + txtCzymc.Text.ToString() + "'", "Gy_Czygl");
                if (oDs.Tables[0].Rows.Count != 0)
                {
                    lblError.Text = "* ±àÂëÖØ¸´£¡";
                    return false;
                }
                if (oDS.Tables[0].Rows.Count != 0)
                {
                    lblError.Text = "* Óû§ÃûÖØ¸´£¡";
                    return false;
                }
            }
            return true;
        }
        //²ð·Ö
        private string Get_Code(string sCode)
        {
            sCode = sCode.Trim();
            char c = Convert.ToChar("-");
            string[] s = sCode.Split(c);
            if (s.Length > 1)
            {
                return s[0].Trim();
            }
            else
            {
                return "0";
            }
        }
 
        //ÐÞ¸ÄÃÜÂë
        private void cmdPassWord_Click(object sender, EventArgs e)
        {
            Xt_Password oPassword = new Xt_Password(); 
            oPassword.Czybm = this.Czybm;
            oPassword.ShowDialog();
        }
 
        #region ¶ÔÓ¦»ù´¡×ÊÁÏÉèÖÃ
 
        //²éÕÒ½ÇÉ«
        public int i = 0;   //ÐеÄÏÂ±ê¿ØÖÆÆ÷ (*****¿ØÖÆ´ÓµÚ¼¸ÐпªÊ¼±éÀú*****)
        public bool notNull = false;    //µÝ¹é¿ØÖÆÆ÷ (*****¿ØÖÆÊÇ·ñ¿Éµ÷Óõݹé******)
        private void cmdHGroup_Click(object sender, EventArgs e)
        {
            string sFind = txtHGroup.Text.Trim();
            string sGroup = "";
            for (int a = i; a <= LbNo.Items.Count - 1; a++)
            {
                sGroup = this.LbNo.Items[a].ToString();
                if (sGroup.IndexOf(sFind) != -1)
                {
                    this.LbNo.SelectedIndex = a;
                    i = a + 1;  //ʹÏ´αéÀú´Ó¸ÃÐеÄÏÂÒ»ÐпªÊ¼²éÕÒ
                    notNull = true;
                    return;   //ÉèÖÃnotNullÎªÕæ,Ìø³ö
                }
            }
            if (notNull) //ʼÖÕδÕÒµ½Æ¥ÅäÏîÔò½øÈë
            {
                i = 0;  //ÖØÖôӵÚÒ»ÐбéÀú
                notNull = false;  //ÉèÖÃnotNullΪ¼Ù,Èç¹ûÔÙÒ»´Î´ÓµÚÒ»ÐбéÀúδÕÒµ½Æ¥ÅäÏîÔò²»»áÔÙ½øÈëIFµ÷Óõݹé
                cmdHGroup_Click(sender, e); //µÝ¹é
            }
            else
            {
                MessageBox.Show("δÕÒµ½£¡£¡");
            }
        }
 
        private void cmdHEmpID_Click(object sender, EventArgs e)
        {
            BLL.ClsBaseSelect_InterFace.SetTextByEmp(txtHEmpID);
        }
 
        private void txtHEmpID_TextChanged(object sender, EventArgs e)
        {
            BLL.ClsPub_BLL.Sub_ClearText(txtHEmpID);
        }
 
        private void cmdHK3UserID_Click(object sender, EventArgs e)
        {
            ClsIF_User_View oUser = new ClsIF_User_View();
            if (oUser.RefreshView())
            {
                txtHK3UserID.Tag = ClsPub.isLong(oUser.oModel.HItemID);
                txtHK3UserID.Text = ClsPub.isStrNull(oUser.oModel.HName);
            }
            else
            {
                txtHK3UserID.Text = "";
            }
        }
 
        private void txtHK3UserID_TextChanged(object sender, EventArgs e)
        {
            if (txtHK3UserID.Text.Trim() == "")
            {
                txtHK3UserID.Tag = "0";
            }
        }
 
        private void cmdHKeeperID_Click(object sender, EventArgs e)
        {
            BLL.ClsBaseSelect_InterFace.SetTextByEmp(txtHKeeperID);
        }
 
        private void txtHKeeperID_TextChanged(object sender, EventArgs e)
        {
            BLL.ClsPub_BLL.Sub_ClearText(txtHKeeperID);
        }
 
        private void cmdHSecManagerID_Click(object sender, EventArgs e)
        {
            BLL.ClsBaseSelect_InterFace.SetTextByEmp(txtHSecManagerID);
        }
 
        private void txtHSecManagerID_TextChanged(object sender, EventArgs e)
        {
            BLL.ClsPub_BLL.Sub_ClearText(txtHSecManagerID);
        }
 
        private void cmdHSellManID_Click(object sender, EventArgs e)
        {
            BLL.ClsBaseSelect_InterFace.SetTextByEmp(txtHSellManID);
        }
 
        private void txtHSellManID_TextChanged(object sender, EventArgs e)
        {
            BLL.ClsPub_BLL.Sub_ClearText(txtHSellManID);
        }
 
        private void cmdHDeptID_Click(object sender, EventArgs e)
        {
            DAL.ClsGy_ORGANIZATIONS_View oClsGy_ORGANIZATIONS_View = new DAL.ClsGy_ORGANIZATIONS_View();
            if (oClsGy_ORGANIZATIONS_View.GetInfoByName(cmbHOrgID.Text))
            {
                HOrgID = oClsGy_ORGANIZATIONS_View.omodel.HItemID;
            }
            if (HOrgID == -1)
            {
                MessageBox.Show("Ñ¡Ôñ×éÖ¯ÓдíÎó£¡");
                return;
            }
 
            string DeWhere = "";
            DeWhere = " and HUSEORGID = " + HOrgID;
            BLL.ClsBaseSelect_InterFace.SetTextByDept(txtHDeptID, DeWhere);
        }
 
        private void txtHDeptID_TextChanged(object sender, EventArgs e)
        {
            BLL.ClsPub_BLL.Sub_ClearText(txtHDeptID);
        }
 
        private void cmdHWhID_Click(object sender, EventArgs e)
        {
            DAL.ClsGy_ORGANIZATIONS_View oClsGy_ORGANIZATIONS_View = new DAL.ClsGy_ORGANIZATIONS_View();
            if (oClsGy_ORGANIZATIONS_View.GetInfoByName(cmbHOrgID.Text))
            {
                HOrgID = oClsGy_ORGANIZATIONS_View.omodel.HItemID;
            }
            if (HOrgID == -1)
            {
                MessageBox.Show("Ñ¡Ôñ×éÖ¯ÓдíÎó£¡");
                return;
            }
 
            string DeWhere = "";
            DeWhere = " and HUSEORGID = " + HOrgID;
            BLL.ClsBaseSelect_InterFace.SetTextByWarehouse(txtHWhID, DeWhere);
 
            if (txtHWhID.Tag.ToString() == txtHSCWH.Tag.ToString())
            {
                MessageBox.Show("¶ÔÓ¦²Ö¿â²»ÄÜÓëµ÷Èë²Ö¿âÏàͬ£¡");
                this.txtHWhID.Text = "";
                return;
            }
        }
 
        private void txtHWhID_TextChanged(object sender, EventArgs e)
        {
            BLL.ClsPub_BLL.Sub_ClearText(txtHWhID);
        }
 
        //µ÷Èë²Ö¿â
        private void cmdHSCWH_Click(object sender, EventArgs e)
        {
            DAL.ClsGy_ORGANIZATIONS_View oClsGy_ORGANIZATIONS_View = new DAL.ClsGy_ORGANIZATIONS_View();
            if (oClsGy_ORGANIZATIONS_View.GetInfoByName(cmbHOrgID.Text))
            {
                HOrgID = oClsGy_ORGANIZATIONS_View.omodel.HItemID;
            }
            if (HOrgID == -1)
            {
                MessageBox.Show("Ñ¡Ôñ×éÖ¯ÓдíÎó£¡");
                return;
            }
 
            string DeWhere = "";
            DeWhere = " and HUSEORGID = " + HOrgID;
            BLL.ClsBaseSelect_InterFace.SetTextByWarehouse(txtHSCWH, DeWhere);
 
            if (txtHSCWH.Tag.ToString() == txtHWhID.Tag.ToString())
            {
                MessageBox.Show("µ÷Èë²Ö¿â²»ÄÜÓë¶ÔÓ¦²Ö¿âÏàͬ£¡");
                this.txtHSCWH.Text = "";
                return;
            }
        }
 
        private void txtHSCWH_TextChanged(object sender, EventArgs e)
        {
            BLL.ClsPub_BLL.Sub_ClearText(txtHSCWH);
        }
 
        private void cmdHSupID_Click(object sender, EventArgs e)
        {
            DAL.ClsGy_ORGANIZATIONS_View oClsGy_ORGANIZATIONS_View = new DAL.ClsGy_ORGANIZATIONS_View();
            if (oClsGy_ORGANIZATIONS_View.GetInfoByName(cmbHOrgID.Text))
            {
                HOrgID = oClsGy_ORGANIZATIONS_View.omodel.HItemID;
            }
            if (HOrgID == -1)
            {
                MessageBox.Show("Ñ¡Ôñ×éÖ¯ÓдíÎó£¡");
                return;
            }
 
            string DeWhere = "";
            DeWhere = " and HUSEORGID = " + HOrgID;
            BLL.ClsBaseSelect_InterFace.SetTextBySupplier(txtHSupID, DeWhere);
        }
 
        private void txtHSupID_TextChanged(object sender, EventArgs e)
        {
            BLL.ClsPub_BLL.Sub_ClearText(txtHSupID);
        }
 
 
        #endregion
 
 
 
 
 
    }
}