| | |
| | | using DevExpress.XtraEditors.Controls; |
| | | using PBS.Model; |
| | | using System.Data; |
| | | using PBS.Vmo; |
| | | |
| | | namespace PBS.WinFrmUI |
| | | { |
| | |
| | | public BuildWizardForm() |
| | | { |
| | | InitializeComponent(); |
| | | this.Load += BuildWizardForm_Load; |
| | | } |
| | | |
| | | private void BuildWizardForm_Load(object sender, EventArgs e) |
| | | { |
| | | this.cbPropertyType.Properties.AddEnum(typeof(ePropertyType)); |
| | | } |
| | | |
| | | //基础验证 |
| | |
| | | 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) ? decimal.Zero : decimal.Parse(txtAreaSquare.Text), |
| | | CompletionTime = txtCompletionTime.Text, |
| | | Developer = txtDeveloper.Text, |
| | | GreeningRate = string.IsNullOrEmpty(this.textGreeningRate.Text) ? decimal.Zero : decimal.Parse(textGreeningRate.Text), |
| | | // Name = txtName.Text, |
| | | PlotRatio = string.IsNullOrEmpty(txtPlotRatio.Text) ? decimal.Zero : decimal.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) || !decimal.TryParse(txtAreaSquare.Text, out decimal areaSquare)) |
| | | if (string.IsNullOrEmpty(txtAreaSquare.Text) || !double.TryParse(txtAreaSquare.Text, out double areaSquare)) |
| | | { |
| | | m.AreaSquare = decimal.Zero; |
| | | 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) || !decimal.TryParse(textGreeningRate.Text, out decimal greeningRate)) |
| | | if (string.IsNullOrEmpty(textGreeningRate.Text) || !double.TryParse(textGreeningRate.Text, out double greeningRate)) |
| | | { |
| | | m.GreeningRate = decimal.Zero; |
| | | model.GreeningRate = null; |
| | | } |
| | | else |
| | | { |
| | | m.GreeningRate = greeningRate; |
| | | model.GreeningRate = greeningRate; |
| | | } |
| | | |
| | | // 处理 PlotRatio |
| | | if (string.IsNullOrEmpty(txtPlotRatio.Text) || !decimal.TryParse(txtPlotRatio.Text, out decimal plotRatio)) |
| | | if (string.IsNullOrEmpty(txtPlotRatio.Text) || !double.TryParse(txtPlotRatio.Text, out double plotRatio)) |
| | | { |
| | | m.PlotRatio = decimal.Zero; |
| | | 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; |
| | | } |
| | | |
| | | private void BuildWizardForm_Load(object sender, EventArgs e) |
| | | { |
| | | /* var allProvince = new BLL.Region().GetAll().Where(x => x.Type == eRegionType.Province).ToList(); |
| | | foreach (var item in allProvince) |
| | | { |
| | | var imageItem = new ImageComboBoxItem(item.Name, item.ID); |
| | | cbArea.Properties.Items.Add(imageItem); |
| | | //城市添加省份只是为了临时用,后期会更改 |
| | | cbCity.Properties.Items.Add(imageItem); |
| | | } |
| | | ValueChangeEvent(); //为了编辑页面的时候可以选中所选项*/ |
| | | } |
| | | |
| | | private void cbArea_SelectedIndexChanged(object sender, EventArgs e) |
| | | { |
| | | ValueChangeEvent(); |
| | | } |
| | | |
| | | private void ValueChangeEvent() |
| | | { |
| | | /* if (cbArea.EditValue != null) |
| | | { |
| | | var AllDist = new BLL.Region().GetChildrenByID((long)cbArea.EditValue); |
| | | foreach (var item in AllDist) |
| | | { |
| | | var imageItem = new ImageComboBoxItem(item.Name, item.ID); |
| | | cbDist.Properties.Items.Add(imageItem); |
| | | } |
| | | }*/ |
| | | this.cbPropertyType.EditValue = model.PropertyType; |
| | | } |
| | | } |
| | | } |