duheng
2024-06-22 0618fadff0d2e95716db801ef0c7a96ff9e1f20e
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
75
76
77
78
79
80
81
82
83
using DevExpress.XtraEditors;
using HStation.Dto;
using HStation.WinFrmUI;
using HStation.WinFrmUI.Xhs.Project;
using Mapster;
using System;
using Yw.Dto;
 
namespace HStation.WinFrmUI
{
    public partial class EditProjectDlg : DevExpress.XtraEditors.XtraForm
    {
        public EditProjectDlg()
        {
            InitializeComponent();
        }
 
        private UpdateXhsProjectInput _updatePrj = null;
 
        private UpdateXhsProjectItemInput _UpdateItem = null;
 
        public event Func<UpdateXhsProjectInput, UpdateXhsProjectItemInput, Task<bool>> ReloadEvent = null;
 
        public async void SetBindingData(long ID)
        {
            var model = await new BLL.XhsProject().GetByID(ID);
            _updatePrj = model.Adapt<XhsProjectDto, UpdateXhsProjectInput>();
            this.NameTextEdit.Text = _updatePrj.Name;
            this.TagNameText.Text = _updatePrj.TagName;
            this.CustomerNameTextEdit.Text = _updatePrj.CustomerName;
            this.DescriptionTextEdit.Text = _updatePrj.Description;
            this.AddressTextEdit.Text = _updatePrj.Address;
        }
 
        //验证
        private bool Valid()
        {
            this.dxErrorProvider1.ClearErrors();
            if (string.IsNullOrEmpty(this.NameTextEdit.Text.Trim()))
            {
                this.dxErrorProvider1.SetError(this.NameTextEdit, "必填项");
                return false;
            }
            return true;
        }
 
        //确定
        private async void btnOk_Click(object sender, EventArgs e)
        {
            if (!Valid())
                return;
            _updatePrj.Name = this.NameTextEdit.Text.Trim();
            _updatePrj.TagName = this.TagNameText.Text.Trim();
            _updatePrj.CustomerName = this.CustomerNameTextEdit.Text.Trim();
            _updatePrj.Description = this.DescriptionTextEdit.Text.Trim();
            _updatePrj.Address = this.AddressTextEdit.Text.Trim();
            var itemDto = await new BLL.XhsProjectItem().GetByPrjID(_updatePrj.ID);
            _UpdateItem = itemDto.Adapt<XhsProjectItemDto, UpdateXhsProjectItemInput>();
            _UpdateItem.Name = _updatePrj.Name;
            _UpdateItem.TagName = _updatePrj.TagName;
            _UpdateItem.UseStatus = _updatePrj.UseStatus;
            if (await this.ReloadEvent.Invoke(_updatePrj, _UpdateItem))
            {
                MessageBoxHelper.ShowSuccess("编辑成功!");
            }
            else
            {
                MessageBoxHelper.ShowError("编辑失败!");
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
 
        private void EditProjectDlg_Load(object sender, EventArgs e)
        {
            this.webView21.Source = new Uri(AppDomain.CurrentDomain.BaseDirectory + "data/web/html/map_select.html");
        }
 
        private void webView21_WebMessageReceived(object sender, Microsoft.Web.WebView2.Core.CoreWebView2WebMessageReceivedEventArgs e)
        {
        }
    }
}