using PBS.Vmo;
|
|
namespace PBS.WinFrmUI.Hydro
|
{
|
public partial class QuickModelingFacilityWizardPage : DevExpress.XtraEditors.XtraUserControl, IWizardPageAsync<QuickModelingViewModel>
|
{
|
public QuickModelingFacilityWizardPage()
|
{
|
InitializeComponent();
|
this.layoutControl1.SetupLayoutControl();
|
this.textEditSupplyMode.Properties.AddEnum<PBS.eSupplyMode>();
|
this.comboBoxWaterSupply.Properties.AddEnum<PBS.eWaterSupply>();
|
this.imageComboBoxConnectionType.Properties.AddEnum<PBS.eConnectionType>();
|
}
|
|
/// <summary>
|
/// 状态改变事件
|
/// </summary>
|
public event Action PageStateChangedEvent;
|
|
private QuickModelingViewModel _vm = null;//操作对象
|
private bool _isCompleted = false;//是否创建完成
|
|
|
|
/// <summary>
|
/// 初始化页面
|
/// </summary>
|
public void InitialPage(QuickModelingViewModel vm)
|
{
|
if (vm == null)
|
{
|
return;
|
}
|
_vm = vm;
|
_isCompleted = false;
|
|
if (!this.comboBoxPackages.Properties.Items.Any())
|
{
|
foreach (var item in _vm.AssetsPackageList)
|
{
|
this.comboBoxPackages.Properties.Items.Add(item.Name, item.ID, -1);
|
}
|
}
|
|
this.txtName.EditValue = _vm.Facility.Name;
|
this.txtFloor.EditValue = _vm.Facility.Floor;
|
this.txtHouseholds.EditValue = _vm.Facility.Households;
|
this.txtFloorHeight.EditValue = _vm.Facility.FloorHeight;
|
this.txtMaxWaterDemand.EditValue = _vm.Facility.MaxWaterDemand;
|
this.txtTerminalPressure.EditValue = _vm.Facility.TerminalPressure;
|
this.comboBoxWaterSupply.EditValue = _vm.Facility.WaterSupply;
|
this.txtConstantPressure.EditValue = _vm.Facility.ConstantPressure;
|
this.textEditSupplyMode.EditValue = _vm.Facility.SupplyMode;
|
this.comboBoxPackages.EditValue = _vm.Facility.PackageID;
|
this.imageComboBoxConnectionType.EditValue = _vm.Facility.ConnectionType;
|
this.textEditConnectionAddress.EditValue = _vm.Facility.ConnectionAddress;
|
|
_isCompleted = true;
|
this.PageStateChangedEvent?.Invoke();
|
}
|
|
|
//验证
|
public bool Verify()
|
{
|
return this.Invoke(() =>
|
{
|
bool isExist = true;
|
this.dxErrorProvider1.ClearErrors();
|
if (string.IsNullOrEmpty(this.txtName.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.txtName, "必填项");
|
isExist = false;
|
}
|
if (string.IsNullOrEmpty(this.txtFloor.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.txtFloor, "必填项");
|
isExist = false;
|
}
|
if (string.IsNullOrEmpty(this.txtFloorHeight.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.txtFloorHeight, "必填项");
|
isExist = false;
|
}
|
if (string.IsNullOrEmpty(this.txtHouseholds.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.txtHouseholds, "必填项");
|
isExist = false;
|
}
|
if (string.IsNullOrEmpty(this.txtConstantPressure.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.txtConstantPressure, "必填项");
|
isExist = false;
|
}
|
|
if (this.textEditSupplyMode.EditValue == null)
|
{
|
this.dxErrorProvider1.SetError(this.textEditSupplyMode, "必填项");
|
isExist = false;
|
}
|
if (this.comboBoxWaterSupply.Text == "请选择")
|
{
|
this.dxErrorProvider1.SetError(this.comboBoxWaterSupply, "必填项");
|
isExist = false;
|
}
|
if (string.IsNullOrEmpty(this.txtMaxWaterDemand.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.txtMaxWaterDemand, "必填项");
|
isExist = false;
|
}
|
if (string.IsNullOrEmpty(this.txtTerminalPressure.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.txtTerminalPressure, "必填项");
|
isExist = false;
|
}
|
return isExist;
|
});
|
}
|
|
//保存
|
private bool Save()
|
{
|
if (!Verify())
|
{
|
return false;
|
}
|
_vm.Facility.Name = this.txtName.Text.Trim();
|
_vm.Facility.Floor = Convert.ToInt32(this.txtFloor.EditValue);
|
_vm.Facility.FloorHeight = Convert.ToDouble(this.txtFloorHeight.EditValue);
|
_vm.Facility.Households = Convert.ToInt32(this.txtHouseholds.EditValue);
|
|
_vm.Facility.SupplyMode = (PBS.eSupplyMode)this.textEditSupplyMode.EditValue;
|
_vm.Facility.MaxWaterDemand = Convert.ToDouble(this.txtMaxWaterDemand.EditValue);
|
_vm.Facility.TerminalPressure = Convert.ToDouble(this.txtTerminalPressure.EditValue);
|
_vm.Facility.ConstantPressure = Convert.ToDouble(this.txtConstantPressure.EditValue);
|
if (this.comboBoxPackages.EditValue != null)
|
_vm.Facility.PackageID = (long)this.comboBoxPackages.EditValue;
|
|
_vm.Facility.WaterSupply = (PBS.eWaterSupply)this.comboBoxWaterSupply.EditValue;
|
_vm.Facility.ConnectionType = (PBS.eConnectionType)this.imageComboBoxConnectionType.EditValue;
|
_vm.Facility.ConnectionAddress = this.textEditConnectionAddress.Text;
|
_vm.Facility.UseStatus = Yw.Vmo.eUseStatus.Enable;
|
return true;
|
}
|
|
|
/// <summary>
|
/// 允许上一步
|
/// </summary>
|
public bool AllowPrev
|
{
|
get
|
{
|
if (!_isCompleted)
|
{
|
return false;
|
}
|
|
return true;
|
}
|
}
|
|
/// <summary>
|
/// 允许下一步
|
/// </summary>
|
public bool AllowNext
|
{
|
get
|
{
|
return true;
|
}
|
}
|
|
/// <summary>
|
/// 允许取消
|
/// </summary>
|
public bool AllowCancel
|
{
|
get
|
{
|
|
return false;
|
}
|
}
|
|
/// <summary>
|
/// 允许完成
|
/// </summary>
|
public bool AllowComplete
|
{
|
get
|
{
|
return false;
|
}
|
}
|
|
/// <summary>
|
/// 能否上一步
|
/// </summary>
|
/// <returns></returns>
|
public Task<bool> CanPrev()
|
{
|
return Task.Run(() => this.AllowPrev);
|
}
|
|
/// <summary>
|
/// 能否下一步
|
/// </summary>
|
public Task<bool> CanNext()
|
{
|
return Task.Run(() => Save());
|
}
|
|
/// <summary>
|
/// 能否取消
|
/// </summary>
|
public Task<bool> CanCancel()
|
{
|
return Task.Run(() => this.AllowCancel);
|
}
|
|
/// <summary>
|
/// 能否完成
|
/// </summary>
|
public Task<bool> CanComplete()
|
{
|
return Task.Run(() => this.AllowComplete);
|
}
|
|
|
}
|
}
|