| | |
| | | public AddProjectDlg() |
| | | { |
| | | 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.SetMarkerEvent += MapSetSimpleMarkerContainer1_SetMarkerEvent; |
| | | await this.mapSetSimpleMarkerContainer1.InitialContainer(); |
| | | } |
| | | |
| | | public event Func<Vmo.Xhs.XhsProjectExtensions, Yw.Vmo.Map.MapInfo, Task<bool>> ReloadDataEvent; |
| | | |
| | | private Yw.Model.Map.Marker _maker = null; //地图点信息 |
| | | |
| | | private Yw.Vmo.Map.MapInfo _mapinfo = null; //地图信息 |
| | | |
| | | //数据验证 |
| | | 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 void MapSetSimpleMarkerContainer1_SetMarkerEvent(Yw.Model.Map.Marker obj) |
| | | { |
| | | _maker = obj; |
| | | this.TextAddress.EditValue = obj.Address; |
| | | } |
| | | |
| | | //确定 |
| | |
| | | if (!Valid()) |
| | | return; |
| | | var model = new Vmo.Xhs.XhsProjectExtensions(); |
| | | model.Address = this.TextAdress.Text.Trim(); |
| | | model.Address = this.TextAddress.Text.Trim(); |
| | | model.Customer = this.TextCustomerName.Text.Trim(); |
| | | model.Description = this.TextDescription.Text.Trim(); |
| | | model.Name = this.TextProjectName.Text.Trim(); |
| | |
| | | Description=this.TextDescription.Text, |
| | | } |
| | | }; |
| | | if (await this.ReloadDataEvent.Invoke(model)) |
| | | if (_maker != null) |
| | | { |
| | | MessageBoxHelper.ShowSuccess("添加成功!"); |
| | | _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 |
| | | { |
| | | MessageBoxHelper.ShowError("添加失败!"); |
| | | TipFormHelper.ShowError("添加失败!"); |
| | | } |
| | | this.DialogResult = DialogResult.OK; |
| | | this.Close(); |