ningshuxia
2025-04-03 4917fb959e2befec07a693e72d7010c09494ec7c
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
using DevExpress.XtraEditors;
using System;
using System.Windows.Forms;
 
namespace IStation.WinFrmUI.Basic
{
    public partial class AddProjectDlg : XtraForm
    {
        public AddProjectDlg()
        {
            InitializeComponent();
            IconOptions.Icon = WinFrmUI.Properties.Resources.App;
            dataLayoutControl1.SetupLayoutControl();
        }
 
        /// <summary>
        /// 回调事件
        /// </summary>
        public event Action<Model.Project> ReloadDataEvent;
        private Model.Project _model = null;
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData()
        {
            _model = new Model.Project();
        }
 
        //验证
        private bool Valid()
        {
            dxErrorProvider1.ClearErrors();
            if (string.IsNullOrEmpty(NameTextEdit.Text.Trim()))
            {
                dxErrorProvider1.SetError(NameTextEdit, "必填项");
                return false;
            }
            return true;
        }
 
 
        //确定
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (!Valid())
                return;
            _model.Name = NameTextEdit.Text.Trim();
            _model.Version = IStation.Project.Version;
            _model.TagName = TagNameTextEdit.Text.Trim();
            _model.Description = DescriptionMemoEdit.Text.Trim();
            _model.CreateTime = DateTime.Now;
            _model.Version = IStation.Project.Version;
            _model.ID = new BLL.Project().Insert(_model);
            if (_model.ID < 1)
            {
                XtraMessageBox.Show("项目创建失败!");
                return;
            }
            ReloadDataEvent?.Invoke(_model);
            DialogResult = DialogResult.OK;
            Close();
        }
 
 
    }
}