| | |
| | | using DevExpress.XtraEditors; |
| | | using HStation.Dto; |
| | | using HStation.Dto; |
| | | using HStation.WinFrmUI; |
| | | using System; |
| | | using HStation.WinFrmUI.Basic; |
| | | using Microsoft.AspNetCore.Identity; |
| | | using Newtonsoft.Json; |
| | | using System.IO.Compression; |
| | | using Yw; |
| | | |
| | | namespace ISupply.WinFrmUI |
| | | { |
| | |
| | | InitializeComponent(); |
| | | } |
| | | |
| | | public event Func<AddXhsProjectInput, Task<bool>> ReloadEvent; |
| | | |
| | | private AddXhsProjectInput _AddXhsProjectInput = null; |
| | | |
| | | //验证 |
| | | public event Func<AddXhsProjectInput, AddXhsProjectItemInput, AddXhsProjectItemModelInput, AddXhsProjectItemModelMapInput, Task<bool>> ReloadEvent; |
| | | |
| | | //初始化 |
| | | private void AddProjectDlg_Load(object sender, EventArgs e) |
| | | { |
| | | _AddXhsProjectInput = new AddXhsProjectInput(); |
| | | this.webView21.Source = new Uri(AppDomain.CurrentDomain.BaseDirectory + "data/web/html/map_select.html"); |
| | | this.navigationFrame.SelectedPage = navigationPageMapSelect; |
| | | layoutControlItemBack.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
| | | } |
| | | |
| | | private void webView21_WebMessageReceived(object sender, Microsoft.Web.WebView2.Core.CoreWebView2WebMessageReceivedEventArgs e) |
| | | { |
| | | var j = JsonConvert.DeserializeObject<FixationReceivedViewModel>(e.WebMessageAsJson); |
| | | switch (j.Oper) |
| | | { |
| | | case "getLocation": |
| | | var o = JsonConvert.DeserializeObject<AmapLocationViewModel>(j.Json); |
| | | if (o == null) |
| | | break; |
| | | this.textEditAddress.Text = o.address; |
| | | _AddXhsProjectInput.MapPosition = o.location.lng + "," + o.location.lat; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | //下一步 |
| | | private void btnNextStep_Click(object sender, EventArgs e) |
| | | { |
| | | var currentindex = this.navigationFrame.SelectedPageIndex; |
| | | switch (currentindex) |
| | | { |
| | | case 0: |
| | | |
| | | this.navigationFrame.SelectedPage = navigationPageForm; |
| | | stepProgressBar1.SelectedItemIndex = 1; |
| | | layoutControlItemAddress.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
| | | this.btnNextStep.Text = "完成"; |
| | | break; |
| | | |
| | | case 1: |
| | | Finish(); |
| | | break; |
| | | } |
| | | layoutControlItemBack.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; |
| | | } |
| | | |
| | | //上一步 |
| | | private void BtnBack_Click(object sender, EventArgs e) |
| | | { |
| | | var currentindex = this.navigationFrame.SelectedPageIndex; |
| | | switch (currentindex) |
| | | { |
| | | case 0: |
| | | if (!Valid()) |
| | | return; |
| | | break; |
| | | |
| | | case 1: |
| | | this.navigationFrame.SelectedPage = navigationPageMapSelect; |
| | | stepProgressBar1.SelectedItemIndex = 0; |
| | | layoutControlItemBack.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
| | | layoutControlItemAddress.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; |
| | | this.btnNextStep.Text = "下一步>"; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | //数据验证 |
| | | private bool Valid() |
| | | { |
| | | this.dxErrorProvider1.ClearErrors(); |
| | | if (string.IsNullOrEmpty(this.NameTextEdit.Text.Trim())) |
| | | if (string.IsNullOrEmpty(textEditAddress.Text.Trim())) |
| | | { |
| | | this.dxErrorProvider1.SetError(this.NameTextEdit, "必填项"); |
| | | this.dxErrorProvider1.SetError(this.textEditAddress, "必填项"); |
| | | return false; |
| | | } |
| | | |
| | | var tagName = this.ModleTextEdit.Text.Trim(); |
| | | if (string.IsNullOrEmpty(tagName)) |
| | | { |
| | | this.dxErrorProvider1.SetError(this.ModleTextEdit, "重复"); |
| | | return false; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | //确定 |
| | | private async void btnOk_Click(object sender, EventArgs e) |
| | | private async void Finish() |
| | | { |
| | | if (!Valid()) |
| | | if (!this.projectUserControl1.Valid()) |
| | | return; |
| | | _AddXhsProjectInput = new AddXhsProjectInput(); |
| | | _AddXhsProjectInput.Name = this.NameTextEdit.Text.Trim(); |
| | | _AddXhsProjectInput.CustomerName = this.CustomerNameTextEdit.Text.Trim(); |
| | | _AddXhsProjectInput.CreateTime = DateTime.Now; |
| | | _AddXhsProjectInput.GID = new Guid().ToString(); |
| | | _AddXhsProjectInput.Description = this.DescriptionTextEdit.Text.Trim(); |
| | | if (await this.ReloadEvent.Invoke(_AddXhsProjectInput)) |
| | | var proresult = this.projectUserControl1.GetData(_AddXhsProjectInput); |
| | | proresult.Address = this.textEditAddress.Text.Trim(); |
| | | var Item = new AddXhsProjectItemInput(); |
| | | Item.Name = proresult.Name; |
| | | Item.Version = proresult.Version; |
| | | Item.TagName = proresult.TagName; |
| | | Item.CreateTime = proresult.CreateTime; |
| | | Item.Description = proresult.Description; |
| | | Item.CreateUserID = proresult.CreateUserID; |
| | | Item.Version = proresult.Version; |
| | | var Model = new AddXhsProjectItemModelInput(); |
| | | Model.Name = proresult.Name; |
| | | Model.Version = proresult.Version; |
| | | Model.TagName = proresult.TagName; |
| | | Model.Description = proresult.Description; |
| | | var Mapinput = new AddXhsProjectItemModelMapInput(); |
| | | Mapinput.UploadUserID = proresult.CreateUserID; |
| | | Mapinput.UploadTime = DateTime.Now; |
| | | if (await this.ReloadEvent.Invoke(proresult, Item, Model, Mapinput)) |
| | | { |
| | | MessageBoxHelper.ShowSuccess("添加成功!"); |
| | | } |
| | |
| | | } |
| | | this.DialogResult = DialogResult.OK; |
| | | this.Close(); |
| | | } |
| | | |
| | | //初始化 |
| | | private void AddProjectDlg_Load(object sender, EventArgs e) |
| | | { |
| | | } |
| | | |
| | | private void webView21_WebMessageReceived(object sender, Microsoft.Web.WebView2.Core.CoreWebView2WebMessageReceivedEventArgs e) |
| | | { |
| | | } |
| | | } |
| | | } |