duheng
2025-03-31 be65218617cab71a90a9a05cf488fbb6e206b5c5
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
using DevExpress.DataProcessing.InMemoryDataProcessor;
using DevExpress.Utils.Extensions;
using System.Windows.Media.Animation;
using Yw;
using Yw.WinFrmUI;
 
namespace PBS.WinFrmUI
{
    public partial class AddPlaceDlg : DevExpress.XtraEditors.XtraForm
    {
        public AddPlaceDlg()
        {
            InitializeComponent();
            this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
            this.generalOkAndCancelCtrl1.OkEvent += GeneralOkAndCancelCtrl1_OkEvent; ;
        }
 
        private Vmo.PlaceVmo _placeVmo;
 
        private ePlaceType _sign;
 
        private BuildWizardForm _buildWizard;
        private HospitalWizardForm _hospitalWizard;
        private SchoolWizardForm _schoolWizard;
        private ShopWizardForm _shopWizard;
 
        private Yw.Vmo.MapInfoVmo _mapInfo;
 
        public event Func<Vmo.PlaceVmo, Yw.Vmo.MapInfoVmo, Task<bool>> ReloadDataEvent;
 
        public async void SetBindingData(ePlaceType placeType)
        {
            _mapInfo = new Yw.Vmo.MapInfoVmo();
            _placeVmo = new Vmo.PlaceVmo();
            _placeVmo.PlaceType = placeType;
            _sign = placeType;
            switch (placeType)
            {
                case ePlaceType.Build:
                    _buildWizard = new BuildWizardForm();
                    _buildWizard.Dock = DockStyle.Fill;
                    this.panelControl1.Controls.Add(_buildWizard);
                    break;
 
                case ePlaceType.Hospital:
                    _hospitalWizard = new HospitalWizardForm();
                    _hospitalWizard.Dock = DockStyle.Fill;
                    this.panelControl1.Controls.Add(_hospitalWizard);
                    break;
 
                case ePlaceType.Shop:
                    _shopWizard = new ShopWizardForm();
                    _shopWizard.Dock = DockStyle.Fill;
                    this.panelControl1.Controls.Add(_shopWizard);
                    break;
 
                case ePlaceType.School:
                    _schoolWizard = new SchoolWizardForm();
                    _schoolWizard.Dock = DockStyle.Fill;
                    this.panelControl1.Controls.Add(_schoolWizard);
                    break;
            }
            var list = await new Yw.BLL.Division().GetAll();
            this.treeListLookUpEdit1TreeList.DataSource = list;
            var map = new Yw.WinFrmUI.MapSetSimpleMarkerContainer();
            map.Dock = DockStyle.Fill;
            map.SetMarkerEvent += Map_SetMarkerEvent;
            await map.InitialContainer();
            this.sidePanel1.AddControl(map);
            var allFlagsList = await BLLFactory<Yw.BLL.SysFlag>.Instance.GetBySysType(DataType.PBSPlace);
            this.setFlagsEditCtrl1.SetBindingData(allFlagsList?.Select(x => x.Name).Distinct().ToList(), null);
        }
 
        //更改点后
        private void Map_SetMarkerEvent(Yw.Model.Map.Marker obj)
        {
            _mapInfo.Position = obj.ToJson();
        }
 
        private bool Valid()
        {
            bool isExist = true;
            this.dxErrorProvider1.ClearErrors();
            if (string.IsNullOrEmpty(this.txtEditName.Text.Trim()))
            {
                this.dxErrorProvider1.SetError(this.txtEditName, "必填项");
                isExist = false;
            }
            return isExist;
        }
 
        /// <summary>
        /// 确定
        /// </summary>
        private async void GeneralOkAndCancelCtrl1_OkEvent()
        {
            if (!Valid())
                return;
            switch (_sign)
            {
                case ePlaceType.Build:
                    _placeVmo.PlaceInfo = Yw.JsonHelper.Object2Json(_buildWizard.GetData());
                    break;
 
                case ePlaceType.Shop:
                    _placeVmo.PlaceInfo = Yw.JsonHelper.Object2Json(_shopWizard.GetData());
                    break;
 
                case ePlaceType.Hospital:
                    _placeVmo.PlaceInfo = Yw.JsonHelper.Object2Json(_hospitalWizard.GetData());
                    break;
 
                case ePlaceType.School:
                    _placeVmo.PlaceInfo = Yw.JsonHelper.Object2Json(_schoolWizard.GetData());
                    break;
            }
            _placeVmo.Name = txtEditName.Text.Trim();
            _placeVmo.Address = textEditAddress.Text.Trim();
            _placeVmo.UseStatus = Yw.Vmo.eUseStatus.Enable;
            _placeVmo.Description = memoEditDescription.Text.Trim();
            _placeVmo.Flags = this.setFlagsEditCtrl1.SelectedFlagList;
            _placeVmo.TagName = this.txtTagName.Text.Trim();
            _mapInfo.ObjectType = PBS.DataType.PBSPlace;
            _mapInfo.ObjectName = _placeVmo.Name;
            _mapInfo.Purpose = Yw.Map.Purpose.Location;
            _mapInfo.Kind = Yw.Map.Kind.Gaodei;
            _mapInfo.Shape = Yw.Map.Shape.Marker;
            if (this.txtEditRegion.EditValue != null)
            {
                _placeVmo.RegionID = Convert.ToInt64(this.txtEditRegion.EditValue);
            }
            if (await ReloadDataEvent.Invoke(_placeVmo, _mapInfo))
            {
                TipFormHelper.ShowSucceed("新增成功!");
            }
            else
            {
                TipFormHelper.ShowError("新增失败!");
            }
            this.Close();
        }
    }
}