duheng
2025-03-28 d5a2d7e66f9c8046bd88b8269e61aac5a2a265e2
WinFrmUI/PBS.WinFrmUI/01-place/00-core/BuildWizardForm.cs
@@ -1,4 +1,4 @@
using PBS.Model;
using PBS.Vmo;
namespace PBS.WinFrmUI
{
@@ -7,6 +7,12 @@
        public BuildWizardForm()
        {
            InitializeComponent();
            this.Load += BuildWizardForm_Load;
        }
        private void BuildWizardForm_Load(object sender, EventArgs e)
        {
            this.cbPropertyType.Properties.AddEnum(typeof(ePropertyType));
        }
        //基础验证
@@ -17,106 +23,86 @@
            return isExist;
        }
        public PlaceBuildParasInfo GetData()
        public PlaceBuildParasInfoVmo GetData()
        {
            if (!Valid())
            {
                return null;
            }
            /*var m = new PlaceBuildParasInfo()
            {
                //  Address = txtAddress.Text,
                //   Area = (long?)this.cbArea.EditValue,
                //    City = (long?)this.cbCity.EditValue,
                //    Dist = (long?)this.cbDist.EditValue,
                AreaSquare = string.IsNullOrEmpty(txtAreaSquare.Text) ? null : double.Parse(txtAreaSquare.Text),
                CompletionTime = txtCompletionTime.Text,
                Developer = txtDeveloper.Text,
                GreeningRate = string.IsNullOrEmpty(this.textGreeningRate.Text) ? null : double.Parse(textGreeningRate.Text),
                //  Name = txtName.Text,
                PlotRatio = string.IsNullOrEmpty(txtPlotRatio.Text) ? null : double.Parse(txtPlotRatio.Text),
                PropertyType = 1,
                ProperTyYears = string.IsNullOrEmpty(txtProperTyYears.Text) ? 0 : int.Parse(txtProperTyYears.Text),
                TotalHouseHolds = string.IsNullOrEmpty(txtTotalHouseHolds.Text) ? 0 : int.Parse(txtTotalHouseHolds.Text)
            };*/
            var m = new PlaceBuildParasInfo();
            var model = new PlaceBuildParasInfoVmo();
            // 处理 AreaSquare
            if (string.IsNullOrEmpty(txtAreaSquare.Text) || !double.TryParse(txtAreaSquare.Text, out double areaSquare))
            {
                m.AreaSquare = null;
                model.AreaSquare = null;
            }
            else
            {
                m.AreaSquare = areaSquare;
                model.AreaSquare = areaSquare;
            }
            // 处理 CompletionTime
            m.CompletionTime = txtCompletionTime.Text;
            model.CompletionTime = txtCompletionTime.Text;
            // 处理 Developer
            m.Developer = txtDeveloper.Text;
            model.Developer = txtDeveloper.Text;
            // 处理 GreeningRate
            if (string.IsNullOrEmpty(textGreeningRate.Text) || !double.TryParse(textGreeningRate.Text, out double greeningRate))
            {
                m.GreeningRate = null;
                model.GreeningRate = null;
            }
            else
            {
                m.GreeningRate = greeningRate;
                model.GreeningRate = greeningRate;
            }
            // 处理 PlotRatio
            if (string.IsNullOrEmpty(txtPlotRatio.Text) || !double.TryParse(txtPlotRatio.Text, out double plotRatio))
            {
                m.PlotRatio = null;
                model.PlotRatio = null;
            }
            else
            {
                m.PlotRatio = plotRatio;
                model.PlotRatio = plotRatio;
            }
            // 处理 PropertyType
            m.PropertyType = 1;
            // 处理 ProperTyYears
            if (string.IsNullOrEmpty(txtProperTyYears.Text) || !int.TryParse(txtProperTyYears.Text, out int properTyYears))
            {
                m.ProperTyYears = 0;
                model.ProperTyYears = 0;
            }
            else
            {
                m.ProperTyYears = properTyYears;
                model.ProperTyYears = properTyYears;
            }
            // 处理 TotalHouseHolds
            if (string.IsNullOrEmpty(txtTotalHouseHolds.Text) || !int.TryParse(txtTotalHouseHolds.Text, out int totalHouseHolds))
            {
                m.TotalHouseHolds = 0;
                model.TotalHouseHolds = 0;
            }
            else
            {
                m.TotalHouseHolds = totalHouseHolds;
                model.TotalHouseHolds = totalHouseHolds;
            }
            return m;
            if (this.cbPropertyType.EditValue != null)
            {
                model.PropertyType = (ePropertyType)this.cbPropertyType.EditValue;
            }
            return model;
        }
        public void SetData(PlaceBuildParasInfo model)
        public void SetData(PlaceBuildParasInfoVmo model)
        {
            if (model == null) return;
            //   txtAddress.Text = model.Address;
            txtAreaSquare.Text = model.AreaSquare.ToString();
            txtCompletionTime.Text = model.CompletionTime.ToString();
            txtDeveloper.Text = model.Developer.ToString();
            textGreeningRate.Text = model.GreeningRate.ToString();
            //    txtName.Text = model.Name.ToString();
            txtPlotRatio.Text = model.PlotRatio.ToString();
            txtProperTyYears.Text = model.ProperTyYears.ToString();
            txtTotalHouseHolds.Text = model.TotalHouseHolds.ToString();
            //        cbArea.EditValue = model.Area;
            //       cbCity.EditValue = model.City;
            //      cbDist.EditValue = model.Dist;
            this.cbPropertyType.EditValue = model.PropertyType;
        }
    }
}