| | |
| | | namespace Yw.WinFrmUI |
| | | using DevExpress.XtraEditors; |
| | | using DevExpress.XtraTabbedMdi; |
| | | |
| | | namespace Yw.WinFrmUI |
| | | { |
| | | public partial class AddHydroSceneDlg : DevExpress.XtraEditors.XtraForm |
| | | { |
| | |
| | | /// <summary> |
| | | /// 重载数据事件 |
| | | /// </summary> |
| | | public event Action<long> ReloadDataEvent; |
| | | public event Action<Yw.Vmo.HydroSceneVmo> ReloadDataEvent; |
| | | |
| | | private Lazy<Yw.BLL.SysFlagStd> _bllFlag = new(() => new Yw.BLL.SysFlagStd());//标签bll |
| | | private Lazy<Yw.BLL.HydroScene> _bllScene = new(() => new Yw.BLL.HydroScene());//场景bll |
| | | private Yw.Vmo.HydroSceneVmo _vmo = null; |
| | | |
| | | /// <summary> |
| | | /// 绑定数据 |
| | | /// </summary> |
| | | public async void SetBindingData() |
| | | public async Task SetBindingData() |
| | | { |
| | | var allFlagList = await _bllFlag.Value.GetFlagListBySysType(Yw.Hydro.DataType.HydroScene); |
| | | this.setFlagsEditCtrl1.SetBindingData(allFlagList, null); |
| | | _vmo = new HydroSceneVmo(); |
| | | |
| | | var allFlagList = await BLLFactory<Yw.BLL.SysFlag>.Instance.GetBySysType(Yw.Hydro.DataType.HydroScene); |
| | | var allFlagNameList = allFlagList?.Select(x => x.Name).Distinct().ToList(); |
| | | this.setFlagsEditCtrl1.SetBindingData(allFlagNameList, null); |
| | | } |
| | | |
| | | //验证 |
| | |
| | | this.dxErrorProvider1.SetError(this.txtCode, "必填项"); |
| | | return false; |
| | | } |
| | | if (await _bllScene.Value.IsExistCode(code)) |
| | | if (await BLLFactory<Yw.BLL.HydroScene>.Instance.IsExistCode(code)) |
| | | { |
| | | this.dxErrorProvider1.SetError(this.txtCode, "编码已存在"); |
| | | return false; |
| | |
| | | var tagName = this.txtTagName.Text.Trim(); |
| | | if (!string.IsNullOrEmpty(tagName)) |
| | | { |
| | | if (await _bllScene.Value.IsExistTagName(tagName)) |
| | | if (await BLLFactory<Yw.BLL.HydroScene>.Instance.IsExistTagName(tagName)) |
| | | { |
| | | this.dxErrorProvider1.SetError(this.txtTagName, "标志已存在"); |
| | | return false; |
| | |
| | | { |
| | | return; |
| | | } |
| | | var model = new Yw.Dto.AddHydroSceneInput(); |
| | | model.Name = this.txtName.Text.Trim(); |
| | | model.Code = this.txtCode.Text.Trim(); |
| | | model.Flags = this.setFlagsEditCtrl1.SelectedFlagList; |
| | | model.TagName = this.txtTagName.Text.Trim(); |
| | | model.Description = this.txtDescription.Text.Trim(); |
| | | _vmo.Name = this.txtName.Text.Trim(); |
| | | _vmo.Code = this.txtCode.Text.Trim(); |
| | | _vmo.Flags = this.setFlagsEditCtrl1.SelectedFlagList; |
| | | _vmo.TagName = this.txtTagName.Text.Trim(); |
| | | _vmo.Description = this.txtDescription.Text.Trim(); |
| | | |
| | | var id = await _bllScene.Value.Insert(model); |
| | | var id = await BLLFactory<Yw.BLL.HydroScene>.Instance.Insert(_vmo); |
| | | if (id < 1) |
| | | { |
| | | MessageBoxHelper.ShowWarning("添加失败!"); |
| | | XtraMessageBox.Show("添加失败!"); |
| | | return; |
| | | } |
| | | var vmo = await BLLFactory<Yw.BLL.HydroScene>.Instance.GetByID(id); |
| | | this.ReloadDataEvent?.Invoke(vmo); |
| | | |
| | | this.ReloadDataEvent?.Invoke(id); |
| | | TipFormHelper.ShowSucceed("添加成功"); |
| | | this.DialogResult = DialogResult.OK; |
| | | this.Close(); |
| | | |