duheng
2025-03-20 1ec65a7b983a7d519c3602d20a855ac1bac1825e
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
using PBS.Model;
 
namespace PBS.WinFrmUI
{
    public partial class BuildPlaceInfoCtrl : DevExpress.XtraEditors.XtraUserControl, IPlaceInfo
    {
        public BuildPlaceInfoCtrl()
        {
            InitializeComponent();
        }
 
 
        private PlaceBuildParasInfo _model = null;
 
 
 
        public void Set(string info)
        {
            _model = PlaceBuildParasInfo.ToModel(info);
            _model ??= new();
        }
 
        public bool Valid()
        {
 
            this.dxErrorProvider1.ClearErrors();
 
            return true;
        }
 
        public string Get()
        {
 
 
            return _model.ToJson();
        }
 
 
        
 
        public PlaceBuildParasInfo GetData()
        {
            if (!Valid())
            {
                return null;
            }
 
            var m = new PlaceBuildParasInfo(); 
            if (string.IsNullOrEmpty(txtAreaSquare.Text) || !decimal.TryParse(txtAreaSquare.Text, out decimal areaSquare))
            {
                m.AreaSquare = decimal.Zero;
            }
            else
            {
                m.AreaSquare = areaSquare;
            }
             
            m.CompletionTime = txtCompletionTime.Text;
             
            m.Developer = txtDeveloper.Text;
             
            if (string.IsNullOrEmpty(textGreeningRate.Text) || !decimal.TryParse(textGreeningRate.Text, out decimal greeningRate))
            {
                m.GreeningRate = decimal.Zero;
            }
            else
            {
                m.GreeningRate = greeningRate;
            }
             
            if (string.IsNullOrEmpty(txtPlotRatio.Text) || !decimal.TryParse(txtPlotRatio.Text, out decimal plotRatio))
            {
                m.PlotRatio = decimal.Zero;
            }
            else
            {
                m.PlotRatio = plotRatio;
            }
             
            m.PropertyType = 1;
             
            if (string.IsNullOrEmpty(txtProperTyYears.Text) || !int.TryParse(txtProperTyYears.Text, out int properTyYears))
            {
                m.ProperTyYears = 0;
            }
            else
            {
                m.ProperTyYears = properTyYears;
            }
             
            if (string.IsNullOrEmpty(txtTotalHouseHolds.Text) || !int.TryParse(txtTotalHouseHolds.Text, out int totalHouseHolds))
            {
                m.TotalHouseHolds = 0;
            }
            else
            {
                m.TotalHouseHolds = totalHouseHolds;
            }
            return m;
        }
 
        public void SetData(PlaceBuildParasInfo model)
        {
            if (model == null) return;
            txtAreaSquare.Text = model.AreaSquare.ToString();
            txtCompletionTime.Text = model.CompletionTime.ToString();
            txtDeveloper.Text = model.Developer.ToString();
            textGreeningRate.Text = model.GreeningRate.ToString();
            txtPlotRatio.Text = model.PlotRatio.ToString();
            txtProperTyYears.Text = model.ProperTyYears.ToString();
            txtTotalHouseHolds.Text = model.TotalHouseHolds.ToString();
        }
 
    }
}