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> ReloadEvent = null; public async void SetBindingData(long ID) { var model = await new BLL.XhsProject().GetByID(ID); _updatePrj = model.Adapt(); 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(); _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) { } } }