using PBS.Vmo; namespace PBS.WinFrmUI { public partial class BuildWizardForm : DevExpress.XtraEditors.XtraUserControl { public BuildWizardForm() { InitializeComponent(); this.Load += BuildWizardForm_Load; } private void BuildWizardForm_Load(object sender, EventArgs e) { this.cbPropertyType.Properties.AddEnum(typeof(ePropertyType)); } //基础验证 public bool Valid() { bool isExist = true; this.dxErrorProvider1.ClearErrors(); return isExist; } public PlaceBuildParasInfoVmo GetData() { if (!Valid()) { return null; } var model = new PlaceBuildParasInfoVmo(); // 处理 AreaSquare if (string.IsNullOrEmpty(txtAreaSquare.Text) || !double.TryParse(txtAreaSquare.Text, out double areaSquare)) { model.AreaSquare = null; } else { model.AreaSquare = areaSquare; } // 处理 CompletionTime model.CompletionTime = txtCompletionTime.Text; // 处理 Developer model.Developer = txtDeveloper.Text; // 处理 GreeningRate if (string.IsNullOrEmpty(textGreeningRate.Text) || !double.TryParse(textGreeningRate.Text, out double greeningRate)) { model.GreeningRate = null; } else { model.GreeningRate = greeningRate; } // 处理 PlotRatio if (string.IsNullOrEmpty(txtPlotRatio.Text) || !double.TryParse(txtPlotRatio.Text, out double plotRatio)) { model.PlotRatio = null; } else { model.PlotRatio = plotRatio; } // 处理 ProperTyYears if (string.IsNullOrEmpty(txtProperTyYears.Text) || !int.TryParse(txtProperTyYears.Text, out int properTyYears)) { model.ProperTyYears = 0; } else { model.ProperTyYears = properTyYears; } // 处理 TotalHouseHolds if (string.IsNullOrEmpty(txtTotalHouseHolds.Text) || !int.TryParse(txtTotalHouseHolds.Text, out int totalHouseHolds)) { model.TotalHouseHolds = 0; } else { model.TotalHouseHolds = totalHouseHolds; } if (this.cbPropertyType.EditValue != null) { model.PropertyType = (ePropertyType)this.cbPropertyType.EditValue; } return model; } public void SetData(PlaceBuildParasInfoVmo 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(); this.cbPropertyType.EditValue = model.PropertyType; } } }