提交 | 用户 | 时间
|
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 WeifenLuo.WinFormsUI.Docking; |
|
11 |
using YX.Entity; |
|
12 |
|
|
13 |
|
|
14 |
namespace YX |
|
15 |
{ |
|
16 |
public partial class FrmAppendProperty : WindowParent |
|
17 |
{ |
|
18 |
SystemAppendProperty_Bll append_bll = new SystemAppendProperty_Bll(); |
|
19 |
SystemMenu_Bll menu_bll = new SystemMenu_Bll(); |
|
20 |
// SystemAppendProperty_Dal append_dal = new SystemAppendProperty_Dal(); |
|
21 |
public FrmAppendProperty(string ParentId) |
|
22 |
{ |
|
23 |
InitializeComponent(); |
|
24 |
SetButton(ParentId,this.toolStrip1); |
|
25 |
} |
|
26 |
|
|
27 |
private void FrmAppendProperty_Load(object sender, EventArgs e) |
|
28 |
{ |
|
29 |
BindTreeView(); |
|
30 |
|
|
31 |
this.dataGridView1.RowsDefaultCellStyle.BackColor = Color.White; |
|
32 |
this.dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.BlanchedAlmond; |
|
33 |
//设置不自动显示数据库中未绑定的列 |
|
34 |
this.dataGridView1.AutoGenerateColumns = false; |
|
35 |
} |
|
36 |
private void BindTreeView() |
|
37 |
{ |
|
38 |
try |
|
39 |
{ |
|
40 |
this.treeView1.Nodes.Clear(); |
|
41 |
this.treeView1.ImageList = imageList1; |
|
42 |
var list = append_bll.GetAppendPropertys(); |
|
43 |
|
|
44 |
foreach (var item in list) |
|
45 |
{ |
|
46 |
TreeNode tn = new TreeNode(); |
|
47 |
tn.Text = item; |
|
48 |
tn.Tag = item; |
|
49 |
tn.ImageIndex = 0; |
|
50 |
treeView1.Nodes.Add(tn); |
|
51 |
} |
|
52 |
treeView1.ExpandAll(); |
|
53 |
} |
|
54 |
catch (Exception ex) |
|
55 |
{ |
|
56 |
System_Bll.WriteLogToDB( new Entity.Base_Log{ |
|
57 |
CreateUserID = FrmLogin.LoginUserID, |
|
58 |
CreateUserName = FrmLogin.loginUserName, |
|
59 |
LocalIP = FrmLogin.LocalIP, |
|
60 |
LogMessage =ex.Message, |
|
61 |
Type = "系统错误", |
|
62 |
ClassName = typeof(FrmAppendProperty).ToString() |
|
63 |
}); |
|
64 |
MessageBox.Show(ex.Message,"提示",MessageBoxButtons.OK,MessageBoxIcon.Error); |
|
65 |
} |
|
66 |
} |
|
67 |
|
|
68 |
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) |
|
69 |
{ |
|
70 |
if (!string .IsNullOrEmpty(this.treeView1.SelectedNode.Text)) |
|
71 |
{ |
|
72 |
this.dataGridView1.DataSource = append_bll.AppendProperty_List(treeView1.SelectedNode.Tag.ToString()); |
|
73 |
} |
|
74 |
} |
|
75 |
/// <summary> |
|
76 |
/// 显示行号 |
|
77 |
/// </summary> |
|
78 |
/// <param name="sender"></param> |
|
79 |
/// <param name="e"></param> |
|
80 |
private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) |
|
81 |
{ |
|
82 |
Rectangle rectangle = new Rectangle(e.RowBounds.Location.X, |
|
83 |
e.RowBounds.Location.Y, |
|
84 |
dataGridView1.RowHeadersWidth - 4, |
|
85 |
e.RowBounds.Height); |
|
86 |
|
|
87 |
TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), |
|
88 |
dataGridView1.RowHeadersDefaultCellStyle.Font, |
|
89 |
rectangle, |
|
90 |
dataGridView1.RowHeadersDefaultCellStyle.ForeColor, |
|
91 |
TextFormatFlags.VerticalCenter | TextFormatFlags.Right); |
|
92 |
} |
|
93 |
private void btn_add_Click(object sender, EventArgs e) |
|
94 |
{ |
|
95 |
FrmAppendPropertyEdit edit = new FrmAppendPropertyEdit(this); |
|
96 |
edit.ShowDialog(); |
|
97 |
} |
|
98 |
|
|
99 |
private void btn_edit_Click(object sender, EventArgs e) |
|
100 |
{ |
|
101 |
if (dataGridView1.DataSource == null) |
|
102 |
{ |
|
103 |
MessageBox.Show("请选择要编辑的行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); |
|
104 |
} |
|
105 |
else |
|
106 |
{ |
|
107 |
DataGridViewRow dr = dataGridView1.SelectedRows[0]; |
|
108 |
|
|
109 |
if (dr != null) |
|
110 |
{ |
|
111 |
FrmAppendPropertyEdit edit = new FrmAppendPropertyEdit(this,ref dr); |
|
112 |
edit.ShowDialog(); |
|
113 |
} |
|
114 |
} |
|
115 |
|
|
116 |
} |
|
117 |
|
|
118 |
private void btn_delete_Click(object sender, EventArgs e) |
|
119 |
{ |
|
120 |
try |
|
121 |
{ |
|
122 |
DataGridViewRow dr = dataGridView1.SelectedRows[0]; |
|
123 |
if (dr != null) |
|
124 |
{ |
|
125 |
int result = append_bll.DeleteAppendProettty(dr.Cells["编号"].Value.ToString()); |
|
126 |
if (result == 1) |
|
127 |
{ |
|
128 |
MessageBox.Show("删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); |
|
129 |
BindTreeView(); |
|
130 |
// this.dataGridView1.DataSource = append_dal.AppendProperty_List(treeView1.SelectedNode.Tag.ToString()); |
|
131 |
} |
|
132 |
else |
|
133 |
{ |
|
134 |
MessageBox.Show("删除失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); |
|
135 |
} |
|
136 |
} |
|
137 |
} |
|
138 |
catch (Exception ex) |
|
139 |
{ |
|
140 |
System_Bll.WriteLogToDB(new Entity.Base_Log |
|
141 |
{ |
|
142 |
CreateUserID = FrmLogin.LoginUserID, |
|
143 |
CreateUserName = FrmLogin.loginUserName, |
|
144 |
LocalIP = FrmLogin.LocalIP, |
|
145 |
LogMessage = ex.Message, |
|
146 |
Type = "系统错误", |
|
147 |
ClassName = typeof(FrmAppendProperty).ToString() |
|
148 |
}); |
|
149 |
MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); |
|
150 |
|
|
151 |
} |
|
152 |
} |
|
153 |
|
|
154 |
private void btn_refresh_Click(object sender, EventArgs e) |
|
155 |
{ |
|
156 |
|
|
157 |
if (!string.IsNullOrEmpty(this.treeView1.SelectedNode.Text)) |
|
158 |
{ |
|
159 |
this.dataGridView1.DataSource = append_bll.AppendProperty_List(treeView1.SelectedNode.Tag.ToString()); |
|
160 |
} |
|
161 |
} |
|
162 |
} |
|
163 |
} |