| | |
| | | using PBS.Model; |
| | | |
| | | namespace PBS.WinFrmUI |
| | | namespace PBS.WinFrmUI |
| | | { |
| | | public partial class BuildPlaceInfoCtrl : DevExpress.XtraEditors.XtraUserControl, IPlaceInfo |
| | | { |
| | |
| | | } |
| | | |
| | | |
| | | private PlaceBuildParasInfo _model = null; |
| | | |
| | | |
| | | private PlaceBuildParasInfoVmo _model = null; |
| | | |
| | | public void Set(string info) |
| | | { |
| | | _model = PlaceBuildParasInfo.ToModel(info); |
| | | _model = PlaceBuildParasInfoVmo.ToModel(info); |
| | | _model ??= new(); |
| | | |
| | | this.txtAreaSquare.EditValue = _model.AreaSquare; |
| | | this.txtCompletionTime.EditValue = _model.CompletionTime; |
| | | this.txtDeveloper.EditValue = _model.Developer; |
| | | this.textGreeningRate.EditValue = _model.GreeningRate; |
| | | this.txtPlotRatio.EditValue = _model.PlotRatio; |
| | | this.txtProperTyYears.EditValue = _model.ProperTyYears; |
| | | this.txtTotalHouseHolds.EditValue = _model.TotalHouseHolds; |
| | | this.cbPropertyType.EditValue = _model.PropertyType; |
| | | } |
| | | |
| | | public bool Valid() |
| | | { |
| | | |
| | | this.dxErrorProvider1.ClearErrors(); |
| | | |
| | | public bool Verify() |
| | | { |
| | | this.dxErrorProvider1.ClearErrors(); |
| | | return true; |
| | | } |
| | | |
| | | public string Get() |
| | | { |
| | | if (!Verify()) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | _model.CompletionTime = txtCompletionTime.Text; |
| | | _model.Developer = txtDeveloper.Text; |
| | | _model.PropertyType = cbPropertyType.SelectedIndex; |
| | | |
| | | if (string.IsNullOrEmpty(this.txtAreaSquare.Text) || !double.TryParse(this.txtAreaSquare.Text, out double areaSquare)) |
| | | { |
| | | _model.AreaSquare = null; |
| | | } |
| | | else |
| | | { |
| | | _model.AreaSquare = areaSquare; |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(this.textGreeningRate.Text) || !double.TryParse(this.textGreeningRate.Text, out double greeningRate)) |
| | | { |
| | | _model.GreeningRate = null; |
| | | } |
| | | else |
| | | { |
| | | _model.GreeningRate = greeningRate; |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(this.txtPlotRatio.Text) || !double.TryParse(this.txtPlotRatio.Text, out double plotRatio)) |
| | | { |
| | | _model.PlotRatio = null; |
| | | } |
| | | else |
| | | { |
| | | _model.PlotRatio = plotRatio; |
| | | } |
| | | |
| | | |
| | | if (string.IsNullOrEmpty(this.txtProperTyYears.Text) || !int.TryParse(this.txtProperTyYears.Text, out int properTyYears)) |
| | | { |
| | | _model.ProperTyYears = 0; |
| | | } |
| | | else |
| | | { |
| | | _model.ProperTyYears = properTyYears; |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(this.txtTotalHouseHolds.Text) || !int.TryParse(this.txtTotalHouseHolds.Text, out int totalHouseHolds)) |
| | | { |
| | | _model.TotalHouseHolds = 0; |
| | | } |
| | | else |
| | | { |
| | | _model.TotalHouseHolds = totalHouseHolds; |
| | | } |
| | | |
| | | 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(); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |