ningshuxia
2023-02-07 d027501182b03a0c036af712a2b7f31d55144562
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.IO;
 
namespace IStation.WinFormUI.Project
{
    public partial class CreateProjectDlg : DevExpress.XtraEditors.XtraForm
    {
        public CreateProjectDlg()
        {
            InitializeComponent();
            this.IconOptions.Icon =  Properties.Resource.app;
            this.dataLayoutControl1.SetupLayoutControl();
        }
 
        /// <summary>
        /// 回调事件
        /// </summary>
        public event Action<long> ReloadDataEvent;
        private Model.Project _model = null;
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData()
        {
            _model = new Model.Project(); 
        }
 
        //验证
        private bool Valid()
        {
            this.dxErrorProvider1.ClearErrors();
            if (string.IsNullOrEmpty(this.NameTextEdit.Text.Trim()))
            {
                this.dxErrorProvider1.SetError(this.NameTextEdit,"必填项");
                return false;
            } 
            return true;
        }
 
         
        //确定
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (!Valid())
                return;
            _model.Name = this.NameTextEdit.Text.Trim(); 
            _model.TagName=this.TagNameTextEdit.Text.Trim();
            _model.Description = this.DescriptionMemoEdit.Text.Trim();
            _model.CreateTime=DateTime.Now;
            _model.UpdateTime = DateTime.Now;
            var projectId = new BLL.Project().Insert(_model);
            if (projectId<1)
            {
                XtraMessageBox.Show("项目创建失败!");
                return;
            }  
            this.ReloadDataEvent?.Invoke(projectId);
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
 
 
    }
}