yangle
2023-03-03 c2a9a460e38c7c196fe98a94e29e6330eac3626f
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;
using Pub_Class;
 
namespace OAM
{
    public partial class frm_txl1 : Form
    {
        public int FitemID;
        public string Fnumber;
        public string Fname;
        public string Tel;
        public string InnerTel;
        public string Mobile;
        public string Email;
        public string Virtual;
        public string FRemark;
        private int HItemIDCol = 0;
        private int HNumberCol = 0; 
        TreeNode CurNode = new TreeNode();
        public node_add1 onode_add1 = new node_add1();
        public frm_add1 ofrm_add1 = new frm_add1();
        public DBUtility.ClsPub.Enum_InputMode InputMode;  //¼Èë״̬±êÖ¾(0-·Ç¼Èë״̬ 1-Ôö¼Ó 2-ÐÞ¸Ä)
        public frm_txl1()
        {
            InitializeComponent();
        }
        //ÏÔʾÁбí
        private void Display() // »ÃÐÄ
        {
            SQLHelper.ClsCN SubCn = new SQLHelper.ClsCN();
            DataSet DSet;
            string sSql = "";
            string sWhere = "";
            //sSql = "Select * from h_v_EmployeeConList order by Í¨Ñ¶Â¼´úÂë";
            string oDeptid = CurNode.Name.Replace("T", "");
            if (oDeptid == "") 
            {
                oDeptid = "Deptid";
            }
            if (CurNode.Text == "ͨѶ¼")
            {
                sSql = "Select * from h_v_EmployeeConList where 1=1 order by Í¨Ñ¶Â¼´úÂë";
                DSet = SubCn.RunProcReturn(sSql, "h_v_EmployeeConList", ref DBUtility.ClsPub.sExeReturnInfo);
                //
                if (DSet == null)
                {
                    MessageBox.Show("ÏÔʾʧ°Ü£¡Ô­Òò£º" + DBUtility.ClsPub.sExeReturnInfo);
                    return;
                }
                grdMain.DataSource = DSet.Tables[0].DefaultView;
                DBUtility.Gy_BaseFun.DisplayGrid(grdMain, this.Name);
                return;
            }
            sSql = "Select * from h_v_EmployeeConList where Deptid=" +oDeptid + " order by Í¨Ñ¶Â¼´úÂë";
            
            //Ö´ÐÐSQL
            DSet = SubCn.RunProcReturn(sSql,"h_v_EmployeeConList", ref DBUtility.ClsPub.sExeReturnInfo);
            //
            if (DSet == null)
            {
                MessageBox.Show("ÏÔʾʧ°Ü£¡Ô­Òò£º" + DBUtility.ClsPub.sExeReturnInfo);
                return;
            }
            grdMain.DataSource = DSet.Tables[0].DefaultView;
            DBUtility.Gy_BaseFun.DisplayGrid(grdMain, this.Name);
            //
 
            
        }
        private void Gy_Department_Load(object sender, EventArgs e)
        {
            LoadTree(TreeView, imageList1, this.Text);
            RefreshTool();
        }
 
 
        //public static void initGrid(DataGridView grdMain)
        //{
        //    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.BackgroundColor = Color.White;
        //    grdMain.GridColor = Color.LightGray;
        //    grdMain.DefaultCellStyle.SelectionBackColor = Color.Black;
        //    grdMain.EnableHeadersVisualStyles = false;     //Íø¸ñ±êÌâ Ñùʽ
        //    grdMain.ColumnHeadersDefaultCellStyle.BackColor = Color.LightGray;
        //}
        //Ë¢ÐÂTOOLBAR
        private void RefreshTool()//Lock
        {
           
        }
        //¼ÓÔØÊ÷ÐÎ
        public static void LoadTree(TreeView tv, ImageList imageList1, string Text)//Lock
        {
            try
            {
                tv.Nodes.Clear();
                tv.ImageList = imageList1;
                TreeNode sNode = tv.Nodes.Add("T0", Text, 0, 1);
                LoadAllNodes(sNode);
            }
            catch (Exception e)
            {
                MessageBox.Show("¼ÓÔØÊ÷ÐÍʧ°Ü£¡" + e.Message, "Ìáʾ");
            }
        }
        public static void LoadAllNodes(TreeNode sNode)  //Lock
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            if (sNode != null)
            {
                try
                {
                    //long sName = Convert.ToInt64(sNode.Name.Substring(1, sNode.Name.Length - 1));
                    sNode.Nodes.Clear();
                    //ofrm_add1.oDeptid = CurNode.Name.Replace("T", "");
                    DataSet Ds = oCn.RunProcReturn("select fitemid,Fnumber,Fname from  deptlist order by Fnumber", "deptlist", ref ClsPub.sExeReturnInfo);
                    for (int i = 0; i < Ds.Tables[0].Rows.Count; i++)
                    {
                        // Ds.Tables[0].Rows[i]["FileName"].ToString() + "-" + Ds.Tables[0].Rows[i]["HName"].ToString(),
                        //if()
                        TreeNode oNode = sNode.Nodes.Add("T" + Ds.Tables[0].Rows[i]["fitemid"].ToString(), Ds.Tables[0].Rows[i]["Fnumber"].ToString() + "-" + Ds.Tables[0].Rows[i]["Fname"].ToString(), 1, 1);
                    }
                    sNode.Expand();
                }
                catch (Exception e)
                {
                    MessageBox.Show("¼ÓÔØ×ÓÏîĿʧ°Ü£¡" + e.Message, "Ìáʾ");
                }
            }
 
        }
        private void TreeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            CurNode = e.Node;
            if (CurNode != null)
            {
                Display();
                //if (CurNode.Nodes.Count == 0)
                //    LoadAllNodes(CurNode);
                ////ÕÒµ½Ñ¡Öнáµã
            }
        }
        private void jz_Click(object sender, EventArgs e)
        {
            onode_add1.up_flag = true;
            onode_add1.ShowDialog();
 
            LoadTree(TreeView, imageList1, this.Text);
        }
        
        private void gz_Click(object sender, EventArgs e)
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            try
            {
                if (CurNode==null)
                {
                    return;
                }
               string sid = CurNode.Name.Replace("T", "");
                //²éѯ±í
                DataSet Ds;
                Ds = oCn.RunProcReturn("Select * from deptlist where fitemid='" + sid + "'", "deptlist");
                if (Ds.Tables[0].Rows.Count == 0)
                {
                    return;
                }
                //¸³Öµ
                node_add1 onode_add1 = new node_add1();
                onode_add1.fitemid = Ds.Tables[0].Rows[0]["fitemid"].ToString().Trim();
                onode_add1.Fnumber = Ds.Tables[0].Rows[0]["Fnumber"].ToString().Trim();
                onode_add1.Fname = Ds.Tables[0].Rows[0]["Fname"].ToString().Trim(); 
                onode_add1.ShowDialog();
 
                LoadTree(TreeView, imageList1, this.Text);
                return;
            }
            catch (Exception e1)
            {
                return;
            }
            
        }
        //ÐÞ¸Ä
        private void Modify()
        {
            if (DBUtility.Gy_BaseFun.AllowRow(grdMain))
            {
                InputMode = DBUtility.ClsPub.Enum_InputMode.InputMode_Modify;
                RefreshTool();
                Init();
            }
        }
        private void sz_Click(object sender, EventArgs e)
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            if (CurNode != null)
            {
                if (CurNode.Name == "T0")
                {
 
                    MessageBox.Show("´Ë½Úµã²»¿Éɾ³ý£¡");
                }
                else
                {
                    
                }
            }
        }
 
        private void cmdLoadTree_Click(object sender, EventArgs e)
        {
            Display();
            Gy_Department_Load(sender, e);
            LoadTree(TreeView, imageList1, this.Text);
        }
 
        private void xz_Click(object sender, EventArgs e)
        {
            if (CurNode.Text  == "")
            {
                MessageBox.Show("ÇëÑ¡ÔñÐèÒªÐÂÔöÖ°Ô±µÄ²¿ÃÅ");
                return;
            }
            else
            {
                if (CurNode.Text == "ͨѶ¼") 
                {
 
                    MessageBox.Show("´Ë½Úµã²»¿ÉÐÂÔöÖ°Ô±±í");
                    return;
                }
                else
                {
 
 
                    ofrm_add1.id = CurNode.Name.Replace("T", "");
                    ofrm_add1.oDeptid = CurNode.Name.Replace("T", "");
                    ofrm_add1.zt = true;
                    ofrm_add1.ShowDialog();
                    Display();
                }
            }
        }
 
        private void grdMain_DoubleClick(object sender, EventArgs e)
        {
            if (grdMain.CurrentRow == null)
            {
                return;
            }
            else
            {
                int col= Fun_GetCol("FitemID");
 
                ofrm_add1.id = grdMain.Rows[grdMain.CurrentRow.Index].Cells[col].Value.ToString();
                ofrm_add1.zt = false;
                ofrm_add1.ShowDialog();
 
                LoadTree(TreeView, imageList1, this.Text);
                Display();
            }
        }
 
 
        private Int32 Fun_GetCol(string sCol)
        {
            return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdMain);
        }
        //ÐÂÔöʱÇå¿ÕÐÅÏ¢
        private void Sub_Clear()  //Lock
        {
 
            //txtFnumber.Text = "";
            //txtFname.Text = "";
            //txtTel.Text = "";
            //txtInnerTel.Text = "";
            //txtMobile.Text = "";
            //txtEmail.Text = "";
            //txtVirtual.Text = "";
            //txtFRemark.Text = "";
        }
 
        //³õʼ»¯½çÃæ
        private bool Init()
        {
            long sItemID;
            if (InputMode == DBUtility.ClsPub.Enum_InputMode.InputMode_AddNew)
            {
                Sub_Clear();
                RefreshTool();
                return true;
            }
            else
            {
                //µÃµ½HITEMID
                sItemID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[HItemIDCol].Value);
                //¼ì²éÊÇ·ñ´æÔÚ
                //if (oDeptHlp.GetInfoByID(sItemID))
                //{
                //    ShowData(sItemID);
                //    //txtHNumber.Focus();
                //    return true;
                //}
                //else
                //{
                //    MessageBox.Show("ÄúÑ¡ÔñµÄÏîÄ¿ÒѾ­²»´æÔÚ£¡" + DBUtility.ClsPub.sExeReturnInfo, "Ìáʾ");
                //    return false;
                //}
                return false;
            }
        }
 
        private void frm_txl1_Load(object sender, EventArgs e)
        {
            Display();
            Gy_Department_Load(sender, e);
            LoadTree(TreeView, imageList1, this.Text);
        }
 
        private void xg_Click(object sender, EventArgs e)
        {
            if (grdMain.CurrentRow == null)
            {
                return;
            }
            else
            {
               
                int col = Fun_GetCol("FitemID");
 
                ofrm_add1.id = grdMain.Rows[grdMain.CurrentRow.Index].Cells[col].Value.ToString();
                ofrm_add1.zt = false;
                ofrm_add1.ShowDialog();
                Display();
            }
        }
 
        private void sc_Click(object sender, EventArgs e)
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            if (grdMain.CurrentRow == null)
            {
                return;
            }
            else
            {
               DialogResult dr = MessageBox.Show("È·¶¨ÒªÉ¾³ý´ËÖ°Ô±ÐÅÏ¢Âð£¿", "Ìáʾ", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
               if (dr == DialogResult.Yes)
               {
                   int col = Fun_GetCol("FitemID");
                   string id = grdMain.Rows[grdMain.CurrentRow.Index].Cells[col].Value.ToString();
                   oCn.RunProc("DELETE FROM EmployeeCon WHERE FitemID =" + id + " ", ref DBUtility.ClsPub.sExeReturnInfo);
                   LoadTree(TreeView, imageList1, this.Text);
                   Display();
                   MessageBox.Show("Ö°Ô±ÐÅÏ¢ÒÑɾ³ý");
               }
            }
        }
 
        private void tc_Click(object sender, EventArgs e)
        {
            DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name);
            this.Close();
        }
 
      
    }
}