lixiaojun
2024-09-23 81819f13e1e3a49bf8456051ec0f0b51e3f10821
WinFrmUI/HStation.WinFrmUI.Xhs.Core/02-project/04-dlg/EditProjectDlg.cs
@@ -1,4 +1,4 @@
using HStation.BLL;
using HStation.Vmo;
namespace HStation.WinFrmUI.Xhs
{
@@ -7,30 +7,73 @@
        public EditProjectDlg()
        {
            InitializeComponent();
            this.Load += AddProjectDlg_Load;
        }
        public event Func<Vmo.Xhs.XhsProjectExtensions, Task<bool>> ReloadDataEvent;
        private async void AddProjectDlg_Load(object sender, EventArgs e)
        {
            this.mapSetSimpleMarkerContainer1.LoadCompletedEvent += MapSetSimpleMarkerContainer1_LoadCompletedEvent;
            this.mapSetSimpleMarkerContainer1.SetMarkerEvent += MapSetSimpleMarkerContainer1_SetMarkerEvent;
            await this.mapSetSimpleMarkerContainer1.InitialContainer();
        }
        private Vmo.Xhs.XhsProjectExtensions _projectExtensions;
        public event Func<XhsProjectExtensionsVmo, Yw.Vmo.MapInfoVmo, Task<bool>> ReloadDataEvent;
        private XhsProjectExtensionsVmo _xhsProjectExtensions;
        private Yw.Model.Map.Marker _maker = null; //地图点信息
        private Yw.Vmo.MapInfoVmo _mapinfo = null; //地图信息
        public async void SetBindingData(long ID)
        {
            var bll = new XhsProjectExtensions();
            var bll = new BLL.XhsProjectExtensions();
            var select = await bll.GetByID(ID);
            if (select == null)
                return;
            _projectExtensions = select;
            this.TextAdress.Text = _projectExtensions.Address;
            this.TextCustomerName.Text = _projectExtensions.TagName;
            this.TextDescription.Text = _projectExtensions.Description;
            this.TextProjectName.Text = _projectExtensions.Name;
            this.TextTagName.Text = _projectExtensions.TagName;
            if (select == null) return;
            _xhsProjectExtensions = select;
            this.TextProjectName.Text = _xhsProjectExtensions.Name;
            this.TextCustomerName.Text = _xhsProjectExtensions.Customer;
            this.TextDescription.Text = _xhsProjectExtensions.Description;
            this.TextTagName.Text = _xhsProjectExtensions.TagName;
            var mapinfo = await new Yw.BLL.MapInfo().Get(HStation.Xhs.DataType.XhsProject, ID, Yw.Map.Kind.Gaodei, Yw.Map.Purpose.Location);
            if (mapinfo != null)
            {
                _mapinfo = mapinfo;
                this.TextAddress.Text = Yw.Model.Map.Marker.ToModel(_mapinfo.Position).Address;
            }
        }
        //数据验证
        private bool Valid()
        {
            this.dxErrorProvider1.ClearErrors();
            if (string.IsNullOrEmpty(TextProjectName.Text.Trim()))
            {
                this.dxErrorProvider1.SetError(this.TextProjectName, "必填项");
                return false;
            }
            if (string.IsNullOrEmpty(TextCustomerName.Text.Trim()))
            {
                this.dxErrorProvider1.SetError(this.TextCustomerName, "必填项");
                return false;
            }
            return true;
        }
        //地图加载完成
        private async void MapSetSimpleMarkerContainer1_LoadCompletedEvent()
        {
            if (_mapinfo != null)
            {
                await this.mapSetSimpleMarkerContainer1.LoadMarker(Yw.Model.Map.Marker.ToModel(_mapinfo.Position));
            }
        }
        //设置位置
        private void MapSetSimpleMarkerContainer1_SetMarkerEvent(Yw.Model.Map.Marker obj)
        {
            _maker = obj;
            this.TextAddress.EditValue = obj.Address;
        }
        //确定
@@ -38,26 +81,30 @@
        {
            if (!Valid())
                return;
            _projectExtensions.Address = this.TextAdress.Text.Trim();
            _projectExtensions.Customer = this.TextCustomerName.Text.Trim();
            _projectExtensions.Description = this.TextDescription.Text.Trim();
            _projectExtensions.Name = this.TextProjectName.Text.Trim();
            _projectExtensions.TagName = this.TextTagName.Text.Trim();
            _projectExtensions.SiteList = new List<Vmo.Xhs.XhsProjectSite>
            _xhsProjectExtensions.Address = this.TextAddress.Text.Trim();
            _xhsProjectExtensions.Customer = this.TextCustomerName.Text.Trim();
            _xhsProjectExtensions.Description = this.TextDescription.Text.Trim();
            _xhsProjectExtensions.Name = this.TextProjectName.Text.Trim();
            _xhsProjectExtensions.TagName = this.TextTagName.Text.Trim();
            _xhsProjectExtensions.SiteList = new List<XhsProjectSiteVmo>
            {
                new Vmo.Xhs.XhsProjectSite
                new XhsProjectSiteVmo
                {
                    Name=this.TextProjectName.Text,
                    Description=this.TextDescription.Text,
                }
            };
            if (await this.ReloadDataEvent.Invoke(_projectExtensions))
            if (_maker != null)
            {
                MessageBoxHelper.ShowSuccess("修改成功!");
                _mapinfo.Position = _maker.ToJson();
            }
            if (await this.ReloadDataEvent.Invoke(_xhsProjectExtensions, _mapinfo))
            {
                TipFormHelper.ShowSucceed("修改成功!");
            }
            else
            {
                MessageBoxHelper.ShowError("修改失败!");
                TipFormHelper.ShowError("修改失败!");
            }
            this.DialogResult = DialogResult.OK;
            this.Close();