duheng
2024-12-04 ca1ccd0dd9f2d6936368f07d14a2b29b309fd151
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
namespace HStation.WinFrmUI.Assets
{
    public partial class AddAssetsBluntheadSeriesDlg : DevExpress.XtraEditors.XtraForm
    {
        public AddAssetsBluntheadSeriesDlg()
        {
            InitializeComponent();
            this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
            this.Load += AddAssetsBluntheadSeriesDlg_Load;
        }
 
        public event Func<Vmo.AssetsBluntheadSeriesVmo, object, Task<bool>> ReloadDataEvent = null;
 
        private List<AssetsBluntheadSeriesViewModel> _assetsBluntheadSeriesViews;
 
        //初始化
        private async void AddAssetsBluntheadSeriesDlg_Load(object sender, EventArgs e)
        {
            _assetsBluntheadSeriesViews = new List<AssetsBluntheadSeriesViewModel>();
            var allList = await new BLL.AssetsBluntheadSeries().GetAll();
            if (allList != null)
            {
                foreach (var item in allList)
                {
                    _assetsBluntheadSeriesViews.Add(new AssetsBluntheadSeriesViewModel(item));
                }
            }
            treeListLookUpEdit1TreeList.DataSource = _assetsBluntheadSeriesViews;
        }
 
        //数据验证
        private bool Valid()
        {
            this.dxErrorProvider1.ClearErrors();
            if (string.IsNullOrEmpty(NameTextEdit.Text.Trim()))
            {
                this.dxErrorProvider1.SetError(this.NameTextEdit, "必填项");
                return false;
            }
            return true;
        }
 
        //完成
        private async void BtnOk_ClickAsync(object sender, EventArgs e)
        {
            if (!Valid())
                return;
            var model = new Vmo.AssetsBluntheadSeriesVmo();
            model.Name = NameTextEdit.Text;
            model.TagName = TagNameTextEdit.Text;
            model.Description = DescriptionTextEdit.Text;
            if (await this.ReloadDataEvent.Invoke(model, this.textEditParentList.EditValue))
            {
                TipFormHelper.ShowSucceed("添加成功!");
            }
            else
            {
                TipFormHelper.ShowError("添加失败!");
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
    }
}