yantian yue
2023-12-28 74222333166387c1e0508f8ccaf8347b861649a5
提交 | 用户 | 时间
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.Common.DoNetCode;
11 using YX.Entity;
12 namespace YX
13 {
14     public partial class FrmAppendPropertyEdit : Form
15     {
16         SystemAppendProperty_Bll append_bll = new SystemAppendProperty_Bll();
17         FrmAppendProperty _frmappend;
18         OperationType type;
19         string Property_ID;
20         public FrmAppendPropertyEdit(FrmAppendProperty frmappend)
21         {
22             InitializeComponent();
23             GetComboxList();
24             this.Text = "动态属性维护-添加";
25             _frmappend = frmappend;
26             type = OperationType.Add;
27          
28          
29         }
30         public FrmAppendPropertyEdit(FrmAppendProperty frmappend , ref DataGridViewRow dvr)
31         {
32             InitializeComponent();
33             GetComboxList();
34             this.Text = "动态属性维护-修改";
35             _frmappend = frmappend;
36             type = OperationType.Edit;
37             Property_ID = dvr.Cells["Property_ID"].Value==null?"" : dvr.Cells["Property_ID"].Value.ToString();
38             txt_Property_Function.Text = dvr.Cells["Property_Function"].Value==null?"" : dvr.Cells["Property_Function"].Value.ToString();
39             txt_Property_ID.Text = dvr.Cells["Property_Control_ID"].Value==null?"" : dvr.Cells["Property_Control_ID"].Value.ToString();
40             txt_Property_Name.Text = dvr.Cells["Property_Name"].Value==null?"": dvr.Cells["Property_Name"].Value.ToString();
41             txt_Property_width.Text = dvr.Cells["Property_Control_Length"].Value==null?"" : dvr.Cells["Property_Control_Length"].Value.ToString();
42             txt_SortCode.Text = dvr.Cells["SortCode"].Value==null?"":dvr.Cells["SortCode"].Value.ToString();
43             rich_dataSource.Text = dvr.Cells["Property_Control_DataSource"].Value==null? "":dvr.Cells["Property_Control_DataSource"].Value.ToString();
44             com_controlType.Text = dvr.Cells["Property_Control_Style"].Value==null?"":dvr.Cells["Property_Control_Style"].Value.ToString();
45         }
46         private void FrmAppendPropertyEdit_Load(object sender, EventArgs e)
47         {
48           //com_controlType.DataSource=  GetComboxList();
49           //com_controlType.ValueMember = "value";
50           //com_controlType.DisplayMember = "name";
51          // com_controlType.SelectedIndex = 0;
52         }
53         private void GetComboxList()
54         {
55             var ControlTypeList = append_bll.AppendProperty_List("控件类型");
56             DataTable dt = new DataTable();
57             dt.Columns.Add("name");
58             dt.Columns.Add("value");
59         
60             foreach (var item in ControlTypeList)
61             {
62                 DataRow dr = dt.NewRow();
63                 dr[0] = item.Property_Name;
64                 dr[1] = item.Property_Control_ID;
65                 dt.Rows.Add(dr);
66                // com_controlType.Items.Add(new { Property_Control_ID = item.Property_Control_ID, Property_Name = item.Property_Name });
67             }
68             com_controlType.DataSource = dt;
69             com_controlType.ValueMember = "value";
70             com_controlType.DisplayMember = "name";
71         }
72         private bool CheckInputData()
73         {
74             bool result = true;
75             if (string.IsNullOrEmpty(txt_Property_Function.Text))
76             {
77                 MessageBox.Show("请输入业务分类!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
78                 txt_Property_Function.Focus();
79                 result = false;
80             }else
81             if (string.IsNullOrEmpty(txt_Property_Name.Text))
82             {
83                 MessageBox.Show("请输入控件属性名称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
84                 txt_Property_Name.Focus();
85                 result = false;
86             }
87             else
88             if (string.IsNullOrEmpty(txt_Property_ID.Text))
89             {
90                 MessageBox.Show("请输入控件ID!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
91                 txt_Property_ID.Focus();
92                 result = false;
93             }else
94        
95             if (string.IsNullOrEmpty(txt_Property_width.Text))
96             {
97                 MessageBox.Show("请输入控件宽度名称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
98                 txt_Property_width.Focus();
99                 result = false;
100             }else
101             if (!string.IsNullOrEmpty(txt_Property_width.Text) && !ValidateUtil.IsNumber(txt_Property_width.Text))
102             {
103                 MessageBox.Show("控件宽度必须是数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
104                 txt_Property_width.Focus();
105                 result = false;
106             }else
107             if (!string.IsNullOrEmpty(txt_SortCode.Text) && !ValidateUtil.IsNumber(txt_SortCode.Text))
108             {
109                 MessageBox.Show("排序必须为数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
110                 txt_SortCode.Focus();
111                 result = false;
112             }
113             return result;
114         }
115         private void btn_save_Click(object sender, EventArgs e)
116         {
117             try
118             {
119                 if(CheckInputData())
120                 {
121                     Base_AppendProperty append = new Base_AppendProperty();
122                     if (!string.IsNullOrEmpty(Property_ID))
123                     {
124                         append.ModifyDate = DateTime.Now;
125                         append.ModifyUserId = FrmLogin.LoginUserID;
126                         append.ModifyUserName = FrmLogin.loginUserName;
127                         append.Property_ID = Property_ID;
128                     }
129                     else
130                     {
131                         append.CreateDate = DateTime.Now;
132                         append.CreateUserId = FrmLogin.LoginUserID;
133                         append.CreateUserName = FrmLogin.loginUserName;
134                         append.Property_ID = Guid.NewGuid().ToString();
135                     }
136                     append.Property_Control_DataSource = rich_dataSource.Text;
137                     append.Property_Control_ID = txt_Property_ID.Text;
138                     append.Property_Function = txt_Property_Function.Text;
139                     append.Property_Name = txt_Property_Name.Text;
140                     append.DeleteMark = 1;
141                     append.Property_Control_Length = Convert.ToInt32(txt_Property_width.Text);
142                     append.Property_Control_Style = com_controlType.SelectedValue.ToString();
143                     append.SortCode = Convert.ToInt32(txt_SortCode.Text);
144
145                     int isOk = 0;
146                     if (type == OperationType.Add)
147                     {
148                         isOk = append_bll.AddAppendProperty(append);
149                     }
150                     else
151                     {
152                         isOk = append_bll.UpdateAppendProertty(append);
153                     }
154
155                     if (isOk > 0)
156                     {
157                         MessageBox.Show("保存成功!");
158
159                         this.Close();
160                     }
161                     else
162                     {
163                         MessageBox.Show("保存失败!");
164                     }
165                 }
166               
167             }
168             catch (Exception ex)
169             {
170
171                 System_Bll.WriteLogToDB(new Entity.Base_Log
172                 {
173                     CreateUserID = FrmLogin.LoginUserID,
174                     CreateUserName = FrmLogin.loginUserName,
175                     LocalIP = FrmLogin.LocalIP,
176                     LogMessage = ex.Message,
177                     Type = "系统错误",
178                     ClassName = typeof(FrmAppendPropertyEdit).ToString()
179                 });
180                 MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
181             }         
182            
183         }
184
185         private void btn_concel_Click(object sender, EventArgs e)
186         {
187             this.Close();
188         }
189     }
190 }