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();
|
}
|
|
}
|
}
|