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
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_ModlueEdit : Form
    {
        public string sCondition; //¹ýÂËÌõ¼þ
        TreeNode CurNode = new TreeNode(); 
        public frm_ModlueEdit()
        {
            InitializeComponent();
        }
         
 
        //¼ÓÔØÊ÷ÐÎ
        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)  //huan
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            if (sNode != null)
            {
                try
                {
                    string BillName2 = "OA_UserModule";
                    long sName = Convert.ToInt64(sNode.Name.Substring(1, sNode.Name.Length - 1));
                    sNode.Nodes.Clear();
                    DataSet Ds = oCn.RunProcReturn("select FileName,ModuleID,FileCode,isgroup from OA_UserModule where parentid='" + sName + "' and username='" + DBUtility.ClsPub.CurUserName + "'  order by ModuleID", "OA_UserModule", ref ClsPub.sExeReturnInfo);
                    for (int i = 0; i < Ds.Tables[0].Rows.Count; i++)
                    { 
                        TreeNode oNode = sNode.Nodes.Add("T" + Ds.Tables[0].Rows[i]["ModuleID"].ToString(), Ds.Tables[0].Rows[i]["FileName"].ToString(), 0, 1);
                    }
                    sNode.Expand();
                }
                catch (Exception e)
                {
                    MessageBox.Show("¼ÓÔØ×ÓÏîĿʧ°Ü£¡" + e.Message, "Ìáʾ");
                }
            }
 
        }
        private void cmdOk2_Click(object sender, EventArgs e)
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            if (CurNode.Text == "")
            {
                MessageBox.Show("δѡÖÐÕýÈ·µÄÏî");
               
            }
            else
            {
                string parentid = CurNode.Name.Substring(1);
                if (DBUtility.ClsPub.isStrNull(txtFilePath.Text) == "")
                {
                    MessageBox.Show("Èí¼þ·¾¶²»ÄÜΪ¿Õ£¡", "Ìáʾ");
                    return;
                }
                if (DBUtility.ClsPub.isStrNull(txtFileName2.Text) == "")
                {
                    MessageBox.Show("Èí¼þÃû³Æ²»ÄÜΪ¿Õ£¡", "Ìáʾ");
                    return;
                }
                oCn.RunProc("Insert into OA_UserModule " +
                           " (FileName,parentid,UserName,FileCode,isgroup,prjname) " +
                           " Values('" + txtFileName2.Text.Trim() + "','" + parentid + "','" + Pub_Class.ClsPub.CurUserName + "','" + txtFilePath.Text.Trim() + "'," + 0 + ",'" + "" + "')", ref DBUtility.ClsPub.sExeReturnInfo);
 
                LoadTree(TreeView, imageList1, this.Text);
                MessageBox.Show("ÐÂÔö³É¹¦");
            }
        }
 
        private void cmdFilePath_Click(object sender, EventArgs e)
        {
            OpenFileDialog fileDialog = new OpenFileDialog();
            fileDialog.Multiselect = true;
            fileDialog.Title = "ÇëÑ¡ÔñÎļþ";
            fileDialog.Filter = "ËùÓÐÎļþ(*.*)|*.*";
            if (fileDialog.ShowDialog() == DialogResult.OK)
            {
                txtFilePath.Text = fileDialog.FileName;
            }
        }
 
        private void cmdCanCel2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
 
        private void jz_Click(object sender, EventArgs e)
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            if (DBUtility.ClsPub.isStrNull(txtName.Text) == "")
            {
                MessageBox.Show("Ìí¼Ó×éÃû²»ÄÜΪ¿Õ£¡", "Ìáʾ");
                return;
               
            }
            else
            {
                if (CurNode.Name == "")
                {
 
                    MessageBox.Show("δѡÖÐÕýÈ·µÄÏî");
                }
                else
                {
                   
                    string parentid = CurNode.Name.Substring(1);
                    DialogResult dr = MessageBox.Show("È·¶¨ÒªÔÚ¡¾" + CurNode.Text + "¡¿ÏÂÌí¼ÓÒ»¸öÃûΪ¡¾" + txtName.Text + "¡¿µÄÐÂ×éÂð£¿", "Ìáʾ", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    if (dr == DialogResult.Yes)
                    {
                        oCn.RunProc("Insert into OA_UserModule " +
                          " (FileName,parentid,UserName,FileCode,isgroup,prjname) " +
                          " Values('" + txtName.Text.Trim() + "','" + parentid + "','" + Pub_Class.ClsPub.CurUserName + "','" + "" + "'," + 0 + ",'" + "" + "')", ref DBUtility.ClsPub.sExeReturnInfo);
 
                        LoadTree(TreeView, imageList1, this.Text);
                        MessageBox.Show("ÐÂÔö³É¹¦");
                    }
                    else
                    {
                    }
                   
                }
            }
        }
 
        private void frm_ModlueEdit_Load(object sender, EventArgs e)
        {
            txtEmp.Text = Pub_Class.ClsPub.CurUserName;
            LoadTree(TreeView, imageList1, this.Text);
        }
 
        private void TreeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            CurNode = e.Node;
            if (CurNode != null)
            {
                if (CurNode.Nodes.Count == 0)
                    LoadAllNodes(CurNode);
                //ÕÒµ½Ñ¡Öнáµã
            }
        }
 
        private void sz_Click(object sender, EventArgs e)
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            if (CurNode != null)
            {
                if (CurNode.Name == "T0")
                {
 
                    MessageBox.Show("´Ë½Úµã²»¿Éɾ³ý£¡");
                }
                else
                {
                    DialogResult dr = MessageBox.Show("È·¶¨ÒªÉ¾³ý´ËĿ¼Âð£¿", "Ìáʾ", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    if (dr == DialogResult.Yes)
                    {
                        string parentid = CurNode.Name.Substring(1);
                        oCn.RunProc("DELETE FROM OA_UserModule WHERE ModuleID =" + parentid + " ", ref DBUtility.ClsPub.sExeReturnInfo);
                        LoadTree(TreeView, imageList1, this.Text);
                        MessageBox.Show("×é" + "¡¾" + CurNode.Text + "¡¿" + "ÒÑɾ³ý");
                    }
                    else
                    {
                    }
                }
            }
            else
            {
                MessageBox.Show("δѡÖÐÕýÈ·µÄÏî");
            }
        }
 
        private void tc_Click(object sender, EventArgs e)
        {
            this.Close();
        }
 
       
 
        
    }
}