懒羊羊
2023-12-28 e46d3baaf3e8d7d85f4bafec3aad75e52b078408
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using YX.BLL;
using YX.Common.DoNetCode;
using YX.Entity;
namespace YX
{
    public partial class FrmAppendPropertyEdit : Form
    {
        SystemAppendProperty_Bll append_bll = new SystemAppendProperty_Bll();
        FrmAppendProperty _frmappend;
        OperationType type;
        string Property_ID;
        public FrmAppendPropertyEdit(FrmAppendProperty frmappend)
        {
            InitializeComponent();
            GetComboxList();
            this.Text = "动态属性维护-添加";
            _frmappend = frmappend;
            type = OperationType.Add;
         
         
        }
        public FrmAppendPropertyEdit(FrmAppendProperty frmappend , ref DataGridViewRow dvr)
        {
            InitializeComponent();
            GetComboxList();
            this.Text = "动态属性维护-修改";
            _frmappend = frmappend;
            type = OperationType.Edit;
            Property_ID = dvr.Cells["Property_ID"].Value==null?"" : dvr.Cells["Property_ID"].Value.ToString();
            txt_Property_Function.Text = dvr.Cells["Property_Function"].Value==null?"" : dvr.Cells["Property_Function"].Value.ToString();
            txt_Property_ID.Text = dvr.Cells["Property_Control_ID"].Value==null?"" : dvr.Cells["Property_Control_ID"].Value.ToString();
            txt_Property_Name.Text = dvr.Cells["Property_Name"].Value==null?"": dvr.Cells["Property_Name"].Value.ToString();
            txt_Property_width.Text = dvr.Cells["Property_Control_Length"].Value==null?"" : dvr.Cells["Property_Control_Length"].Value.ToString();
            txt_SortCode.Text = dvr.Cells["SortCode"].Value==null?"":dvr.Cells["SortCode"].Value.ToString();
            rich_dataSource.Text = dvr.Cells["Property_Control_DataSource"].Value==null? "":dvr.Cells["Property_Control_DataSource"].Value.ToString();
            com_controlType.Text = dvr.Cells["Property_Control_Style"].Value==null?"":dvr.Cells["Property_Control_Style"].Value.ToString();
        }
        private void FrmAppendPropertyEdit_Load(object sender, EventArgs e)
        {
          //com_controlType.DataSource=  GetComboxList();
          //com_controlType.ValueMember = "value";
          //com_controlType.DisplayMember = "name";
         // com_controlType.SelectedIndex = 0;
        }
        private void GetComboxList()
        {
            var ControlTypeList = append_bll.AppendProperty_List("控件类型");
            DataTable dt = new DataTable();
            dt.Columns.Add("name");
            dt.Columns.Add("value");
        
            foreach (var item in ControlTypeList)
            {
                DataRow dr = dt.NewRow();
                dr[0] = item.Property_Name;
                dr[1] = item.Property_Control_ID;
                dt.Rows.Add(dr);
               // com_controlType.Items.Add(new { Property_Control_ID = item.Property_Control_ID, Property_Name = item.Property_Name });
            }
            com_controlType.DataSource = dt;
            com_controlType.ValueMember = "value";
            com_controlType.DisplayMember = "name";
        }
        private bool CheckInputData()
        {
            bool result = true;
            if (string.IsNullOrEmpty(txt_Property_Function.Text))
            {
                MessageBox.Show("请输入业务分类!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txt_Property_Function.Focus();
                result = false;
            }else
            if (string.IsNullOrEmpty(txt_Property_Name.Text))
            {
                MessageBox.Show("请输入控件属性名称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txt_Property_Name.Focus();
                result = false;
            }
            else
            if (string.IsNullOrEmpty(txt_Property_ID.Text))
            {
                MessageBox.Show("请输入控件ID!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txt_Property_ID.Focus();
                result = false;
            }else
       
            if (string.IsNullOrEmpty(txt_Property_width.Text))
            {
                MessageBox.Show("请输入控件宽度名称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txt_Property_width.Focus();
                result = false;
            }else
            if (!string.IsNullOrEmpty(txt_Property_width.Text) && !ValidateUtil.IsNumber(txt_Property_width.Text))
            {
                MessageBox.Show("控件宽度必须是数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txt_Property_width.Focus();
                result = false;
            }else
            if (!string.IsNullOrEmpty(txt_SortCode.Text) && !ValidateUtil.IsNumber(txt_SortCode.Text))
            {
                MessageBox.Show("排序必须为数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txt_SortCode.Focus();
                result = false;
            }
            return result;
        }
        private void btn_save_Click(object sender, EventArgs e)
        {
            try
            {
                if(CheckInputData())
                {
                    Base_AppendProperty append = new Base_AppendProperty();
                    if (!string.IsNullOrEmpty(Property_ID))
                    {
                        append.ModifyDate = DateTime.Now;
                        append.ModifyUserId = FrmLogin.LoginUserID;
                        append.ModifyUserName = FrmLogin.loginUserName;
                        append.Property_ID = Property_ID;
                    }
                    else
                    {
                        append.CreateDate = DateTime.Now;
                        append.CreateUserId = FrmLogin.LoginUserID;
                        append.CreateUserName = FrmLogin.loginUserName;
                        append.Property_ID = Guid.NewGuid().ToString();
                    }
                    append.Property_Control_DataSource = rich_dataSource.Text;
                    append.Property_Control_ID = txt_Property_ID.Text;
                    append.Property_Function = txt_Property_Function.Text;
                    append.Property_Name = txt_Property_Name.Text;
                    append.DeleteMark = 1;
                    append.Property_Control_Length = Convert.ToInt32(txt_Property_width.Text);
                    append.Property_Control_Style = com_controlType.SelectedValue.ToString();
                    append.SortCode = Convert.ToInt32(txt_SortCode.Text);
 
                    int isOk = 0;
                    if (type == OperationType.Add)
                    {
                        isOk = append_bll.AddAppendProperty(append);
                    }
                    else
                    {
                        isOk = append_bll.UpdateAppendProertty(append);
                    }
 
                    if (isOk > 0)
                    {
                        MessageBox.Show("保存成功!");
 
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("保存失败!");
                    }
                }
              
            }
            catch (Exception ex)
            {
 
                System_Bll.WriteLogToDB(new Entity.Base_Log
                {
                    CreateUserID = FrmLogin.LoginUserID,
                    CreateUserName = FrmLogin.loginUserName,
                    LocalIP = FrmLogin.LocalIP,
                    LogMessage = ex.Message,
                    Type = "系统错误",
                    ClassName = typeof(FrmAppendPropertyEdit).ToString()
                });
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }         
           
        }
 
        private void btn_concel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}