雅琪诺MES智能条码管理系统
jhz
2022-06-30 0d3b2bd4edaa7385e4ff96370c877be237af054b
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
 
namespace SCM
{
    public partial class Xt_User : Form
    {
        public Xt_User()
        {
            InitializeComponent();
        }
 
        public string sDisplay;     //ÅжÏÑ¡ÖеÄÊÇÄĸöÍø¸ñ 
        public SCM.WMSWeb.WebService1 oWeb = new SCM.WMSWeb.WebService1();
        //´°Ìå¼ÓÔØ
        private void Xt_User_Load(object sender, EventArgs e)
        {
            oWeb.Url = ClsPub1.WEBSURL;
            sDisplay = "Óû§";
            initGrid();
            Display1();
            Display2();
        }
 
        //Íø¸ñ³õʼ»¯
        private void initGrid()
        {
            //Íø¸ñ--Óû§
            grdMain.SelectionMode = DataGridViewSelectionMode.FullRowSelect;        //Ñ¡ÖÐģʽ--ÐÐÑ¡ÖÐ
            grdMain.ColumnHeadersVisible = true;                                    //±êÌâÁÐÏÔʾ--ÊÇ
            grdMain.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;  //±êÌâÁгߴçģʽ--£¨×Ô¶¯µ÷Õû£¬¿Éµ÷Õû£©
            grdMain.RowTemplate.Height = 18;
            grdMain.RowTemplate.MinimumHeight = 18;
            grdMain.ColumnHeadersHeight = 35;          //±êÌâÐиß
            grdMain.RowHeadersVisible = false;              //±êÌâÐпɼû--·ñ
            grdMain.AllowUserToAddRows = false;             //ÊÇ·ñÔÊÐí×ÔÔö--·ñ
            grdMain.AllowUserToDeleteRows = false;          //ÊÇ·ñÔÊÐíɾ³ý--·ñ
            grdMain.ColumnCount = 0;                        //×ÜÁÐÊý--5
            grdMain.RowCount = 0;
            grdMain.AllowUserToResizeColumns = true;         //ÔÊÐíµ÷ÕûÁпí--ÊÇ
            grdMain.AllowUserToResizeRows = false;           //ÔÊÐíµ÷ÕûÐиß--·ñ
            grdMain.ReadOnly = true;                         //Ö»¶Á--ÊÇ
            grdMain.MultiSelect = false;                    //Ö»ÄÜÑ¡ÖÐÒ»ÐÐ
            grdMain.BackgroundColor = Color.White;
            grdMain.GridColor = Color.LightGray;
            grdMain.DefaultCellStyle.SelectionBackColor = Color.Black;
            grdMain.EnableHeadersVisualStyles = false;     //Íø¸ñ±êÌâ Ñùʽ
            //
            //Íø¸ñ--Óû§×é
            grdSub.SelectionMode = DataGridViewSelectionMode.FullRowSelect;        //Ñ¡ÖÐģʽ--ÐÐÑ¡ÖÐ
            grdSub.ColumnHeadersVisible = true;                                    //±êÌâÁÐÏÔʾ--ÊÇ
            grdSub.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;  //±êÌâÁгߴçģʽ--£¨×Ô¶¯µ÷Õû£¬¿Éµ÷Õû£©
            grdSub.RowTemplate.Height = 18;
            grdSub.RowTemplate.MinimumHeight = 18;
            grdSub.ColumnHeadersHeight = 35;          //±êÌâÐиß
            grdSub.RowHeadersVisible = false;              //±êÌâÐпɼû--·ñ
            grdSub.AllowUserToAddRows = false;             //ÊÇ·ñÔÊÐí×ÔÔö--·ñ
            grdSub.AllowUserToDeleteRows = false;          //ÊÇ·ñÔÊÐíɾ³ý--·ñ
            grdSub.ColumnCount = 0;                        //×ÜÁÐÊý--5
            grdSub.RowCount = 0;
            grdSub.AllowUserToResizeColumns = true;         //ÔÊÐíµ÷ÕûÁпí--ÊÇ
            grdSub.AllowUserToResizeRows = false;           //ÔÊÐíµ÷ÕûÐиß--·ñ
            grdSub.ReadOnly = true;                         //Ö»¶Á--ÊÇ
            grdSub.MultiSelect = false;                    //Ö»ÄÜÑ¡ÖÐÒ»ÐÐ
            grdSub.BackgroundColor = Color.White;
            grdSub.GridColor = Color.LightGray;
            grdSub.DefaultCellStyle.SelectionBackColor = Color.Black;
            grdSub.EnableHeadersVisualStyles = false;     //Íø¸ñ±êÌâ Ñùʽ
        }
 
        //²éÕÒÊý¾Ý----Óû§
        private void Display1()
        {
            try
            {
                //SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
                DataSet oDs = new DataSet();
                oDs = oWeb.getDataSetBySQL("select * from  h_v_Gy_Czygl order by Óû§", "h_v_Gy_Czygl", ref DBUtility.ClsPub.sExeReturnInfo);
                if (oDs == null)
                {
                    MessageBox.Show("ÏÔʾʧ°Ü£¡Ô­Òò£º" + DBUtility.ClsPub.sExeReturnInfo);
                    return;
                }
                //
                grdMain.DataSource = oDs.Tables[0].DefaultView;
                //¼ÓÔØÁпí
                for (int i = 0; i < grdMain.ColumnCount; i++)
                {
                    grdMain.Columns[i].Width = 100;
                    if (grdMain.Columns[i].HeaderText.Substring(0, 1).ToLower() == "h")
                    {
                        grdMain.Columns[i].Visible = false;
                    }
                    else
                    {
                        grdMain.Columns[i].Visible = true;
                    }
                }
                //DBUtility.ClsPub.GetGridView(this.grdMain, this.Name + "1", DBUtility.ClsPub.AppPath);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Ìáʾ");
                return;
            }
        }
 
        //²éÕÒÊý¾Ý--Óû§×é
        private void Display2()
        {
            try
            {
                //SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
                DataSet oDs = new DataSet();
                oDs = oWeb.getDataSetBySQL("select * from h_v_System_UserGroup order by ½ÇÉ«", "h_v_System_UserGroup", ref DBUtility.ClsPub.sExeReturnInfo);
                if (oDs == null)
                {
                    MessageBox.Show("ÏÔʾʧ°Ü£¡Ô­Òò£º" + DBUtility.ClsPub.sExeReturnInfo);
                    return;
                }
                //
                grdSub.DataSource = oDs.Tables[0].DefaultView;
                //¼ÓÔØÁпí
                for (int i = 0; i < grdSub.ColumnCount; i++)
                {
                    grdSub.Columns[i].Width = 100;
                    if (grdSub.Columns[i].HeaderText.Substring(0, 1).ToLower() == "h")
                    {
                        grdSub.Columns[i].Visible = false;
                    }
                    else
                    {
                        grdSub.Columns[i].Visible = true;
                    }
                }
                //DBUtility.ClsPub.GetGridView(this.grdSub, this.Name + "2", DBUtility.ClsPub.AppPath);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Ìáʾ");
                return;
            }
        }
        //Ë¢ÐÂ
        private void shuax_Click(object sender, EventArgs e)
        {
            Display1();
            Display2();
        }
        //Í˳ö
        private void tc_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        //ÐÂÔöÓû§
        private void xz_Click(object sender, EventArgs e)
        {
            Xt_UserNew oNew = new Xt_UserNew();
            oNew.InputMode = Pub_Class.ClsPub.Enum_InputMode.InputMode_AddNew; 
            oNew.ShowDialog();
        }
        //ÐÂÔöÓû§×é
        private void xzz_Click(object sender, EventArgs e)
        {
            Xt_UserGroup oGroup = new Xt_UserGroup();
            oGroup.InputMode = Pub_Class.ClsPub.Enum_InputMode.InputMode_AddNew; 
            oGroup.ShowDialog();
        }
        //ÐÞ¸ÄÓû§
        private void grdMain_DoubleClick(object sender, EventArgs e)
        {
            if (grdMain.CurrentRow != null)
            {
                Xt_UserNew oNew = new Xt_UserNew();
                oNew.InputMode = Pub_Class.ClsPub.Enum_InputMode.InputMode_Modify;
                oNew.Czybm = grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("HCzybm")].Value.ToString(); 
                oNew.ShowDialog();
            }
        }
        //ÐÞ¸ÄÓû§×é
        private void grdSub_DoubleClick(object sender, EventArgs e)
        {
            if (grdSub.CurrentRow != null)
            {
                Xt_UserGroup oGroup = new Xt_UserGroup();
                oGroup.InputMode = Pub_Class.ClsPub.Enum_InputMode.InputMode_Modify;
                oGroup.HGroupID = DBUtility.ClsPub.isLong(grdSub.Rows[grdSub.CurrentRow.Index].Cells[Fun_GetCol("HGroupID")].Value.ToString());
 
                oGroup.ShowDialog();
            }
        }
        //µÃµ½¶ÔÓ¦ÁÐ
        private Int32 Fun_GetCol(string sCol)//Lock
        {
            for (int c = 0; c < grdMain.ColumnCount; c++)
            {
                if (DBUtility.ClsPub.isStrNull(grdMain.Columns[c].HeaderText).ToUpper().Trim() == sCol.Trim().ToUpper())
                {
                    return c;
                }
            }
            return 0;
        }
 
        //µÃµ½¶ÔÓ¦ÁÐ
        private Int32 Fun_GetCol_Sub(string sCol)//Lock
        {
            for (int c = 0; c < grdSub.ColumnCount; c++)
            {
                if (DBUtility.ClsPub.isStrNull(grdSub.Columns[c].HeaderText).ToUpper().Trim() == sCol.Trim().ToUpper())
                {
                    return c;
                }
            }
            return 0;
        }
 
        private void bclk_Click(object sender, EventArgs e)
        {
            //±£´æÁпí
            //DBUtility.ClsPub.SaveGridView(grdMain, this.Name + "1", DBUtility.ClsPub.AppPath);
            ////±£´æÁпí
            //DBUtility.ClsPub.SaveGridView(grdSub, this.Name + "2", DBUtility.ClsPub.AppPath);
        }
 
        private void mrlk_Click(object sender, EventArgs e)
        {
            DBUtility.ClsPub.DefaultGridView(grdMain);
            //²ÎÊý½âÊÍ  ¿ªÊ¼ÁР£¬½áÊøÁУ¬ÊÇ·ñÒÔ×î´óÁпíΪ׼£¬×îСÁпí
            DBUtility.ClsPub.SaveGridView(grdMain, this.Name + "1", DBUtility.ClsPub.AppPath);
            //
            DBUtility.ClsPub.DefaultGridView(grdSub);
            //²ÎÊý½âÊÍ  ¿ªÊ¼ÁР£¬½áÊøÁУ¬ÊÇ·ñÒÔ×î´óÁпíΪ׼£¬×îСÁпí
            DBUtility.ClsPub.SaveGridView(grdSub, this.Name + "2", DBUtility.ClsPub.AppPath);
        }
 
        private void qx_Click(object sender, EventArgs e)
        {
            Xt_Authorization oAuth = new Xt_Authorization(); 
            oAuth.sDisplay = this.sDisplay;
            if (sDisplay == "Óû§")
            {
                oAuth.czybm = grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("HCzybm")].Value.ToString();
                oAuth.lblUser.Text = grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("Óû§")].Value.ToString() + "--ȨÏÞÉèÖÃ";
            }
            else
            {
                oAuth.HGroupID = DBUtility.ClsPub.isLong(grdSub.Rows[grdSub.CurrentCell.RowIndex].Cells[Fun_GetCol_Sub("HGroupID")].Value);
                oAuth.lblUser.Text = grdSub.Rows[grdSub.CurrentCell.RowIndex].Cells[Fun_GetCol_Sub("½ÇÉ«")].Value.ToString() + "--ȨÏÞÉèÖÃ";
            }
            //дÈëÈÕÖ¾
            //DBUtility.ClsPub.Add_Log(DBUtility.ClsPub.CurUserName, "ɾ³ýÓû§:" + oAuth.lblUser.Text, DBUtility.ClsPub.CurUserName);
            oAuth.ShowDialog();
        }
 
        private void grdMain_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            sDisplay = "Óû§";
        }
 
        private void grdSub_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            sDisplay = "½ÇÉ«";
        }
 
        private void sc_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("È·¶¨ÒªÉ¾³ýµ±Ç°Óû§£¿" + grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("Óû§")].Value.ToString(), "Ìáʾ", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
            {
                return;
            }
            if (MessageBox.Show("ÔÙ´ÎÈ·¶¨ÒªÉ¾³ýµ±Ç°Óû§£¿" + grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("Óû§")].Value.ToString(), "Ìáʾ", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
            {
                return;
            }
            DeleteBill();
            Display1();
            Display2();
        }
 
        private void DeleteBill()
        {
            //SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            if (sDisplay == "Óû§")
            {
                try
                {
                    //oCn.BeginTran();
                    oWeb.getRunProc("delete from  Gy_Czygl where Czybm='" + grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("HCzybm")].Value.ToString() + "'", ref DBUtility.ClsPub.sExeReturnInfo);
                    oWeb.getRunProc("delete from  System_UserGroupInfo where UserId='" + grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("HCzybm")].Value.ToString() + "'", ref DBUtility.ClsPub.sExeReturnInfo);
                    //DBUtility.ClsPub.Add_Log(DBUtility.ClsPub.CurUserName, "ɾ³ýÓû§:" + grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("HCzybm")].Value.ToString(), DBUtility.ClsPub.CurUserName);
                    //oCn.Commit();
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "Ìáʾ");
                    //oCn.RollBack();
                    return;
                }
            }
            else
            {
                try
                {
                    //oCn.BeginTran();
                    oWeb.getRunProc("delete from   System_UserGroup where GroupId=" + grdSub.Rows[grdSub.CurrentCell.RowIndex].Cells[Fun_GetCol("HGroupID")].Value.ToString(), ref DBUtility.ClsPub.sExeReturnInfo);
                    oWeb.getRunProc("delete from  System_UserGroupInfo where GroupId=" + grdSub.Rows[grdSub.CurrentCell.RowIndex].Cells[Fun_GetCol("HGroupID")].Value.ToString(), ref DBUtility.ClsPub.sExeReturnInfo);
                    //oCn.Commit();
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "Ìáʾ");
                    //oCn.RollBack();
                    return;
                }
            }
            MessageBox.Show(sDisplay + "ɾ³ý³É¹¦£¡", "Ìáʾ");
        }
        private void sx_Click(object sender, EventArgs e)
        {
             
        }
 
        private void grdMain_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
 
        }
 
        public int i = 0;   //ÐеÄÏÂ±ê¿ØÖÆÆ÷ (*****¿ØÖÆ´ÓµÚ¼¸ÐпªÊ¼±éÀú*****)
        public bool notNull = false;    //µÝ¹é¿ØÖÆÆ÷ (*****¿ØÖÆÊÇ·ñ¿Éµ÷Óõݹé******)
        private void cmdHUser_Click(object sender, EventArgs e)
        {
            string sFind = txtHUser.Text.Trim();
            string sUser = "";
            foreach (DataGridViewRow dr in grdMain.SelectedRows) //È¡ÏûÐеÄÑ¡ÖÐ
            {
                dr.Selected = false;
            }
            for (int a = i; a <= grdMain.RowCount - 1; a++)
            {
                sUser = DBUtility.ClsPub.isStrNull(this.grdMain.Rows[a].Cells[Fun_GetCol("Óû§")].Value);
                if (sUser.IndexOf(sFind) != -1)
                {
                    grdMain.Rows[a].Selected = true;  //Èç¹ûÆ¥ÅäÔòÑ¡ÖиÃÐÐ
                    grdMain.FirstDisplayedScrollingRowIndex = a;  //¹ö¶¯Ìõ»¬×Ô¸ÃÐÐ
                    i = a + 1;  //ʹÏ´αéÀú´Ó¸ÃÐеÄÏÂÒ»ÐпªÊ¼²éÕÒ
                    notNull = true;
                    return;   //ÉèÖÃnotNullÎªÕæ,Ìø³ö
                }
            }
            if (notNull) //ʼÖÕδÕÒµ½Æ¥ÅäÏîÔò½øÈë
            {
                i = 0;  //ÖØÖôӵÚÒ»ÐбéÀú
                notNull = false;  //ÉèÖÃnotNullΪ¼Ù,Èç¹ûÔÙÒ»´Î´ÓµÚÒ»ÐбéÀúδÕÒµ½Æ¥ÅäÏîÔò²»»áÔÙ½øÈëIFµ÷Óõݹé
                cmdHUser_Click(sender, e); //µÝ¹é
            }
            else
            {
                MessageBox.Show("δÕÒµ½£¡£¡");
            }
        }
 
        private void sjqx_Click(object sender, EventArgs e)
        {
            //Xt_UserDataRight oRight = new Xt_UserDataRight(); 
            //if (sDisplay == "Óû§")
            //{
            //    oRight.sUserName = grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("Óû§")].Value.ToString() + "";
            //}
            //else
            //{
            //    //oAuth.HGroupID = DBUtility.ClsPub.isLong(grdSub.Rows[grdSub.CurrentCell.RowIndex].Cells[Fun_GetCol_Sub("HGroupID")].Value);
            //    //oAuth.lblUser.Text = grdSub.Rows[grdSub.CurrentCell.RowIndex].Cells[Fun_GetCol_Sub("½ÇÉ«")].Value.ToString() + "--ȨÏÞÉèÖÃ";
            //}
            ////дÈëÈÕÖ¾
            ////DBUtility.ClsPub.Add_Log(DBUtility.ClsPub.CurUserName, "ɾ³ýÓû§:" + oAuth.lblUser.Text, DBUtility.ClsPub.CurUserName);
            //oRight.ShowDialog();
        }
 
       
 
    }
}