using Yw.Basic; namespace HStation.WinFrmUI.Basic { public partial class EditSysPropDlg : DevExpress.XtraEditors.XtraForm { public EditSysPropDlg() { InitializeComponent(); this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon; } public event Func> ReloadDataEvent = null; private Yw.Vmo.SysPropVmo _UpdatePropDto { get; set; } public async void SetBindingData(long PropID) { var model = await new Yw.BLL.SysProp().GetByID(PropID); _UpdatePropDto = model; this.TextEditName.Text = _UpdatePropDto.Name; this.TextEditDefaultValue.Text = _UpdatePropDto.DefaultValue; this.TextEditDescription.Text = _UpdatePropDto.Description; this.TextEditUnitName.Text = _UpdatePropDto.UnitName; this.TextEditCode.Text = _UpdatePropDto.Code; this.CheckEditIsNull.Checked = _UpdatePropDto.IsNull; if (_UpdatePropDto.Format == Yw.Basic.ePropFormat.Bigint) { this.TextComoBoxFormat.SelectedIndex = 1; } else if (_UpdatePropDto.Format == Yw.Basic.ePropFormat.Integer) { this.TextComoBoxFormat.SelectedIndex = 0; } else if (_UpdatePropDto.Format == Yw.Basic.ePropFormat.MultiText) { this.TextComoBoxFormat.SelectedIndex = 4; } else if (_UpdatePropDto.Format == Yw.Basic.ePropFormat.Time) { this.TextComoBoxFormat.SelectedIndex = 5; } else if (_UpdatePropDto.Format == Yw.Basic.ePropFormat.Numeric) { this.TextComoBoxFormat.SelectedIndex = 2; } else if (_UpdatePropDto.Format == Yw.Basic.ePropFormat.Text) { this.TextComoBoxFormat.SelectedIndex = 3; } else { this.TextComoBoxFormat.SelectedIndex = 6; } } //数据验证 private bool Valid() { this.dxErrorProvider1.ClearErrors(); if (string.IsNullOrEmpty(TextEditName.Text.Trim())) { this.dxErrorProvider1.SetError(this.TextEditName, "必填项"); return false; } if (string.IsNullOrEmpty(TextEditCode.Text.Trim())) { this.dxErrorProvider1.SetError(this.TextEditCode, "必填项"); return false; } if (string.IsNullOrEmpty(TextComoBoxFormat.Text.Trim())) { this.dxErrorProvider1.SetError(this.TextComoBoxFormat, "必填项"); return false; } return true; } //完成 private async void BtnOk_ClickAsync(object sender, EventArgs e) { _UpdatePropDto.Name = TextEditName.Text.Trim(); _UpdatePropDto.Description = TextEditDescription.Text.Trim(); _UpdatePropDto.Code = TextEditCode.Text.Trim(); _UpdatePropDto.DefaultValue = TextEditDefaultValue.Text.Trim(); _UpdatePropDto.UnitName = TextEditUnitName.Text.Trim(); if (TextComoBoxFormat.SelectedIndex == 0) { _UpdatePropDto.Format = (Yw.Basic.ePropFormat)ePropFormat.Integer; } else if (TextComoBoxFormat.SelectedIndex == 1) { _UpdatePropDto.Format = (Yw.Basic.ePropFormat)ePropFormat.Bigint; } else if (TextComoBoxFormat.SelectedIndex == 2) { _UpdatePropDto.Format = (Yw.Basic.ePropFormat)ePropFormat.Numeric; } else if (TextComoBoxFormat.SelectedIndex == 3) { _UpdatePropDto.Format = (Yw.Basic.ePropFormat)ePropFormat.Text; } else if (TextComoBoxFormat.SelectedIndex == 4) { _UpdatePropDto.Format = (Yw.Basic.ePropFormat)ePropFormat.MultiText; } else if (TextComoBoxFormat.SelectedIndex == 5) { _UpdatePropDto.Format = (Yw.Basic.ePropFormat)ePropFormat.Time; } else { _UpdatePropDto.Format = (Yw.Basic.ePropFormat)ePropFormat.Boolen; } _UpdatePropDto.IsNull = CheckEditIsNull.Checked; if (await this.ReloadDataEvent.Invoke(_UpdatePropDto)) { MessageBoxHelper.ShowSuccess("修改成功!"); } else { MessageBoxHelper.ShowError("修改失败!"); } this.DialogResult = DialogResult.OK; this.Close(); } } }