yangyin
2024-08-20 98e49c0dd42840a094837f7acae532bc237a719a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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<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;
        }
 
        //确定
        private async void BtnOk_Click(object sender, EventArgs e)
        {
            if (!Valid())
                return;
            var model = new Vmo.Xhs.XhsProjectExtensions();
            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<Vmo.Xhs.XhsProjectSite>
            {
                new Vmo.Xhs.XhsProjectSite
                {
                    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();
        }
    }
}