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();
|
}
|
|
|
}
|
}
|