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(); } /// /// 回调事件 /// public event Action ReloadDataEvent; private Model.Project _model = null; /// /// 绑定数据 /// 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(); } } }