提交 | 用户 | 时间
|
e46d3b
|
1 |
using System; |
懒 |
2 |
using System.Collections.Generic; |
|
3 |
using System.ComponentModel; |
|
4 |
using System.Data; |
|
5 |
using System.Drawing; |
|
6 |
using System.Linq; |
|
7 |
using System.Text; |
|
8 |
using System.Windows.Forms; |
|
9 |
using YX.BLL; |
|
10 |
using YX.Entity; |
|
11 |
|
|
12 |
namespace YX |
|
13 |
{ |
|
14 |
public partial class FrmMenuEdit : Form |
|
15 |
{ |
|
16 |
YX.BLL.SystemMenu_Bll bll = new BLL.SystemMenu_Bll(); |
|
17 |
|
|
18 |
FrmMenu _frmMenu; |
|
19 |
OperationType type; |
|
20 |
string MenuID = ""; |
|
21 |
public FrmMenuEdit(FrmMenu frmMenu) |
|
22 |
{ |
|
23 |
|
|
24 |
type = OperationType.Add; |
|
25 |
this._frmMenu = frmMenu; |
|
26 |
InitializeComponent(); |
|
27 |
this.Text = "菜单信息-添加"; |
|
28 |
this.txt_parent.Text = _frmMenu.treeView1.SelectedNode.Text; |
|
29 |
} |
|
30 |
public FrmMenuEdit(FrmMenu frmMenu, ref DataGridViewRow dvr) |
|
31 |
{ |
|
32 |
try |
|
33 |
{ |
|
34 |
|
|
35 |
type = OperationType.Edit; |
|
36 |
this._frmMenu = frmMenu; |
|
37 |
InitializeComponent(); |
|
38 |
this.Text = "菜单信息-编辑"; |
|
39 |
// this.com_Parent.Text=dvr.Cells["节点位置"].Value==null?"": dvr.Cells["节点位置"].Value.ToString(); |
|
40 |
this.txt_parent.Text = _frmMenu.treeView1.SelectedNode.Text; |
|
41 |
this.txt_MenuName.Text = dvr.Cells["Menu_Name"].Value == null ? "" : dvr.Cells["Menu_Name"].Value.ToString(); |
|
42 |
txt_MenuTag.Text = dvr.Cells["Menu_Tag"].Value == null ? "" : dvr.Cells["Menu_Tag"].Value.ToString(); |
|
43 |
txt_Sort.Text = dvr.Cells["SortCode"].Value == null ? "0" : dvr.Cells["SortCode"].Value.ToString(); |
|
44 |
pic_menu.Image = new FrmListImages(this).imageList1.Images[dvr.Cells["Menu_Img"].Value==null? 0 : int.Parse(dvr.Cells["Menu_Img"].Value.ToString())]; |
|
45 |
pic_menu.Tag = dvr.Cells["Menu_Img"].Value==null ? 0 : int.Parse(dvr.Cells["Menu_Img"].Value.ToString()); |
|
46 |
MenuID = dvr.Cells["Menu_Id"].Value == null ? "" : dvr.Cells["Menu_Id"].Value.ToString(); |
|
47 |
} |
|
48 |
catch (Exception ex) |
|
49 |
{ |
|
50 |
System_Bll.WriteLogToDB(new Entity.Base_Log |
|
51 |
{ |
|
52 |
CreateUserID = FrmLogin.LoginUserID, |
|
53 |
CreateUserName = FrmLogin.loginUserName, |
|
54 |
LocalIP = FrmLogin.LocalIP, |
|
55 |
LogMessage = ex.Message, |
|
56 |
Type = "系统错误!", |
|
57 |
ClassName = typeof(FrmMenuEdit).ToString() |
|
58 |
}); |
|
59 |
MessageBox.Show(ex.Message); |
|
60 |
} |
|
61 |
} |
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
private void FrmMenuEdit_Load(object sender, EventArgs e) |
|
66 |
{ |
|
67 |
|
|
68 |
//var ParentID= _frmMenu.treeView1.SelectedNode==null?"": _frmMenu.treeView1.SelectedNode.Tag; |
|
69 |
//com_Parent.DataSource = bll.GetSysMenusParent(FrmLogin.LoginUserID); |
|
70 |
//com_Parent.DisplayMember = "Menu_Name"; |
|
71 |
//com_Parent.ValueMember = "Menu_Id"; |
|
72 |
//com_Parent.SelectedValue = ParentID; |
|
73 |
} |
|
74 |
|
|
75 |
private void btn_save_Click(object sender, EventArgs e) |
|
76 |
{ |
|
77 |
try |
|
78 |
{ |
|
79 |
|
|
80 |
if (type == OperationType.Add) |
|
81 |
{ |
|
82 |
Base_SysMenu info = new Base_SysMenu |
|
83 |
{ |
|
84 |
CreateDate = DateTime.Now, |
|
85 |
CreateUserId = FrmLogin.LoginUserID, |
|
86 |
CreateUserName = FrmLogin.loginUserName, |
|
87 |
Menu_Img = int.Parse(pic_menu.Tag.ToString()), |
|
88 |
Menu_Name = txt_MenuName.Text, |
|
89 |
Menu_Tag = txt_MenuTag.Text, |
|
90 |
ParentId = _frmMenu.treeView1.SelectedNode.Tag.ToString(), |
|
91 |
SortCode = int.Parse(txt_Sort.Text), |
|
92 |
Menu_Id = Guid.NewGuid().ToString() |
|
93 |
|
|
94 |
}; |
|
95 |
int result= bll.AddSysMenu(info); |
|
96 |
if (result == 1) |
|
97 |
{ |
|
98 |
MessageBox.Show("添加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); |
|
99 |
_frmMenu.dataGridView1.DataSource = bll.GetSysMenuChilds(_frmMenu.treeView1.SelectedNode.Tag.ToString(),FrmLogin.LoginUserID); |
|
100 |
this.Close(); |
|
101 |
} |
|
102 |
else |
|
103 |
{ |
|
104 |
MessageBox.Show("添加失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); |
|
105 |
} |
|
106 |
} |
|
107 |
else |
|
108 |
{ |
|
109 |
Base_SysMenu info = new Base_SysMenu |
|
110 |
{ |
|
111 |
|
|
112 |
Menu_Img = int.Parse(pic_menu.Tag.ToString()), |
|
113 |
Menu_Name = txt_MenuName.Text, |
|
114 |
Menu_Tag = txt_MenuTag.Text, |
|
115 |
ParentId = _frmMenu.treeView1.SelectedNode.Tag.ToString(), |
|
116 |
SortCode = int.Parse(txt_Sort.Text), |
|
117 |
ModifyUserName = FrmLogin.loginUserName, |
|
118 |
ModifyDate = DateTime.Now, |
|
119 |
ModifyUserId = FrmLogin.LoginUserID, |
|
120 |
Menu_Id = MenuID |
|
121 |
|
|
122 |
|
|
123 |
}; |
|
124 |
int result= bll.UpdateSysMenu(info); |
|
125 |
if (result == 1) |
|
126 |
{ |
|
127 |
MessageBox.Show("修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); |
|
128 |
_frmMenu.dataGridView1.DataSource = bll.GetSysMenuChilds(_frmMenu.treeView1.SelectedNode.Tag.ToString(),FrmLogin.LoginUserID); |
|
129 |
this.Close(); |
|
130 |
} |
|
131 |
else |
|
132 |
{ |
|
133 |
MessageBox.Show("修改失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); |
|
134 |
} |
|
135 |
} |
|
136 |
} |
|
137 |
catch (Exception ex) |
|
138 |
{ |
|
139 |
System_Bll.WriteLogToDB(new Entity.Base_Log |
|
140 |
{ |
|
141 |
CreateUserID = FrmLogin.LoginUserID, |
|
142 |
CreateUserName = FrmLogin.loginUserName, |
|
143 |
LocalIP = FrmLogin.LocalIP, |
|
144 |
LogMessage = ex.Message, |
|
145 |
Type = "系统错误!", |
|
146 |
ClassName = typeof(FrmMenuEdit).ToString() |
|
147 |
}); |
|
148 |
MessageBox.Show(ex.Message); |
|
149 |
} |
|
150 |
|
|
151 |
} |
|
152 |
|
|
153 |
private void pic_menu_Click(object sender, EventArgs e) |
|
154 |
{ |
|
155 |
FrmListImages image = new FrmListImages(this); |
|
156 |
image.ShowDialog(); |
|
157 |
} |
|
158 |
|
|
159 |
private void btn_concel_Click(object sender, EventArgs e) |
|
160 |
{ |
|
161 |
this.Close(); |
|
162 |
} |
|
163 |
} |
|
164 |
} |