| | |
| | | /// <summary> |
| | | /// 回调事件 |
| | | /// </summary> |
| | | // public event Func<Model.WaterUtensil, bool> ReloadDataEvent; |
| | | public event Func<Vmo.WE.UtensilVmo, Task<bool>> ReloadDataEvent; |
| | | |
| | | /// <summary> |
| | | /// 验证识别码是否存在事件 |
| | | /// </summary> |
| | | public event Func<string, long, bool> VerifyTagNameExistEvent; |
| | | public event Func<string, long, Task<bool>> VerifyTagNameExistEvent; |
| | | |
| | | //private Model.WaterUtensil _model = null; |
| | | private Vmo.WE.UtensilVmo _model = null; |
| | | |
| | | /// <summary> |
| | | /// 绑定 |
| | | /// </summary> |
| | | /* public void SetBindingData(Model.WaterUtensil model) |
| | | public void SetBindingData(Vmo.WE.UtensilVmo model) |
| | | { |
| | | _model = new Model.WaterUtensil(model); |
| | | _model = model; |
| | | this.NameTextEdit.EditValue = _model.Name; |
| | | this.TagNameTextEdit.EditValue = _model.TagName; |
| | | this.DescriptionTextEdit.EditValue = _model.Description; |
| | | this.selectFlagsPopupCtrl1.SetBindingData(_model.Flags); |
| | | }*/ |
| | | this.textEditRatedFlow.EditValue = _model.RatedFlow; |
| | | this.textEditMinRatedFlow.EditValue = _model.MinRatedFlow; |
| | | } |
| | | |
| | | //验证 |
| | | private bool Valid() |
| | | private async Task<bool> Valid() |
| | | { |
| | | /* this.dxErrorProvider1.ClearErrors(); |
| | | this.dxErrorProvider1.ClearErrors(); |
| | | if (string.IsNullOrEmpty(this.NameTextEdit.Text.Trim())) |
| | | { |
| | | this.dxErrorProvider1.SetError(this.NameTextEdit, "必填项"); |
| | | return false; |
| | | } |
| | | |
| | | var tagName = this.TagNameTextEdit.Text.Trim(); |
| | | if (!string.IsNullOrEmpty(tagName)) |
| | | { |
| | |
| | | { |
| | | if (VerifyTagNameExistEvent != null) |
| | | { |
| | | if (VerifyTagNameExistEvent(tagName, _model.ID)) |
| | | if (await VerifyTagNameExistEvent(tagName, _model.ID)) |
| | | { |
| | | this.dxErrorProvider1.SetError(this.TagNameTextEdit, "重复"); |
| | | return false; |
| | |
| | | } |
| | | } |
| | | |
| | | return true;*/ |
| | | return true; |
| | | } |
| | | |
| | | //确定 |
| | | private void btnOk_Click(object sender, EventArgs e) |
| | | private async void btnOk_Click(object sender, EventArgs e) |
| | | { |
| | | /* if (_model == null) |
| | | if (_model == null) |
| | | return; |
| | | if (!Valid()) |
| | | if (!await Valid()) |
| | | return; |
| | | _model.Name = this.NameTextEdit.Text.Trim(); |
| | | _model.Description = this.DescriptionTextEdit.Text.Trim(); |
| | | _model.TagName = this.TagNameTextEdit.Text.Trim(); |
| | | _model.Flags = this.selectFlagsPopupCtrl1.SelectedFlags; |
| | | |
| | | if (double.TryParse(this.textEditMinRatedFlow.Text, out double minRatedFlow)) |
| | | { |
| | | _model.MinRatedFlow = minRatedFlow; |
| | | } |
| | | if (double.TryParse(this.textEditRatedFlow.Text, out double ratedFlow)) |
| | | { |
| | | _model.RatedFlow = ratedFlow; |
| | | } |
| | | if (this.ReloadDataEvent == null) |
| | | return; |
| | | if (!this.ReloadDataEvent(_model)) |
| | | if (!await this.ReloadDataEvent(_model)) |
| | | { |
| | | MessageBoxHelper.ShowError("更新失败!"); |
| | | return; |
| | | } |
| | | MessageBoxHelper.ShowSuccess("更新成功!"); |
| | | this.DialogResult = System.Windows.Forms.DialogResult.OK; |
| | | this.Close();*/ |
| | | this.Close(); |
| | | } |
| | | } |
| | | } |