lixiaojun
2024-09-11 ec0d0b6f8e3ac7791c736ae8aad69c4a1587cad9
WinFrmUI/HStation.WinFrmUI.Xhs.Core/02-project/04-dlg/AddProjectDlg.cs
@@ -1,16 +1,49 @@
namespace HStation.WinFrmUI.Xhs
using HStation.Vmo;
namespace HStation.WinFrmUI.Xhs
{
    public partial class AddProjectDlg : DevExpress.XtraEditors.XtraForm
    {
        public AddProjectDlg()
        {
            InitializeComponent();
            this.Load += AddProjectDlg_Load;
        }
        private async void AddProjectDlg_Load(object sender, EventArgs e)
        {
            this.mapSetSimpleMarkerContainer1.SetMarkerEvent += MapSetSimpleMarkerContainer1_SetMarkerEvent;
            await this.mapSetSimpleMarkerContainer1.InitialContainer();
        }
        public event Func<XhsProjectExtensionsVmo, Yw.Vmo.Map.MapInfo, Task<bool>> ReloadDataEvent;
        private Yw.Model.Map.Marker _maker = null; //地图点信息
        private Yw.Vmo.Map.MapInfo _mapinfo = null; //地图信息
        //数据验证
        private bool Valid()
        {
            return false;
            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 void MapSetSimpleMarkerContainer1_SetMarkerEvent(Yw.Model.Map.Marker obj)
        {
            _maker = obj;
            this.TextAddress.EditValue = obj.Address;
        }
        //确定
@@ -18,20 +51,39 @@
        {
            if (!Valid())
                return;
            var bll = new BLL.XhsProjectExtensions();
            var all = await bll.GetAll();
            await bll.Insert(new Vmo.Xhs.XhsProjectExtensions
            var model = new XhsProjectExtensionsVmo();
            model.Address = this.TextAddress.Text.Trim();
            model.Customer = this.TextCustomerName.Text.Trim();
            model.Description = this.TextDescription.Text.Trim();
            model.Name = this.TextProjectName.Text.Trim();
            model.TagName = this.TextTagName.Text.Trim();
            model.SiteList = new List<XhsProjectSiteVmo>
            {
                Address = "详细地址",
                SiteList = new List<Vmo.Xhs.XhsProjectSite>()
                new XhsProjectSiteVmo
                {
                     new Vmo.Xhs.XhsProjectSite
                     {
                         Name ="测试名称",
                         Description ="测试说明"
                     }
                    Name=this.TextProjectName.Text,
                    Description=this.TextDescription.Text,
                }
            });
            };
            if (_maker != null)
            {
                _mapinfo = new Yw.Vmo.Map.MapInfo();
                _mapinfo.ObjectType = HStation.Xhs.DataType.XhsProject;
                _mapinfo.Purpose = Yw.Map.Purpose.Location;
                _mapinfo.Kind = Yw.Map.Kind.Gaodei;
                _mapinfo.Shape = Yw.Map.Shape.Marker;
                _mapinfo.Position = _maker.ToJson();
            }
            if (await this.ReloadDataEvent.Invoke(model, _mapinfo))
            {
                TipFormHelper.ShowSucceed("添加成功!");
            }
            else
            {
                TipFormHelper.ShowError("添加失败!");
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
    }
}