using DevExpress.XtraDiagram.Bars;
|
using DevExpress.XtraEditors.Controls;
|
using HStation.WinFrmUI.Basic;
|
using Yw.Basic;
|
|
namespace HStation.WinFrmUI
|
{
|
public partial class AddPumpPropDlg : DevExpress.XtraEditors.XtraForm
|
{
|
public AddPumpPropDlg()
|
{
|
InitializeComponent();
|
}
|
|
public event Func<Yw.Vmo.SysPropVmo, string, string, Task<bool>> ReloadDataEvent; //属性类, 组名,属性值
|
|
private Yw.Vmo.SysPropVmo _AddPropDto { get; set; }
|
private Yw.BLL.SysPropMapping _bll = null;
|
|
private long _catalogId;
|
|
/// <summary>
|
/// 初始化数据
|
/// </summary>
|
public async void SetBindingData(long CatalogID)
|
{
|
_catalogId = CatalogID;
|
var catalogVmo = await new Yw.BLL.SysCatalog().GetByID(CatalogID);
|
if (catalogVmo == null)
|
return;
|
var propGroup = new Yw.BLL.SysPropGroup();
|
var alllist = await propGroup.GetByTypeID(catalogVmo.TypeID);
|
foreach (var item in alllist)
|
{
|
var imageItem = new ImageComboBoxItem(item.Name, item.ID);
|
this.imageComboBoxEditPropGroup.Properties.Items.Add(imageItem);
|
}
|
_AddPropDto = new Yw.Vmo.SysPropVmo();
|
_AddPropDto.TypeID = catalogVmo.TypeID;
|
}
|
|
private bool Valid()
|
{
|
bool isContinue = true;
|
this.dxErrorProvider1.ClearErrors();
|
if (imageComboBoxEditPropGroup.EditValue == null)
|
{
|
this.dxErrorProvider1.SetError(imageComboBoxEditPropGroup, "必填项!");
|
isContinue = false;
|
}
|
if (textEditName.EditValue == null)
|
{
|
this.dxErrorProvider1.SetError(textEditName, "必填项!");
|
isContinue = false;
|
}
|
return isContinue;
|
}
|
|
private async void BtnOk_Click(object sender, EventArgs e)
|
{
|
if (!Valid())
|
return;
|
_AddPropDto.GroupID = Convert.ToInt64(this.imageComboBoxEditPropGroup.EditValue);
|
_AddPropDto.Name = textEditName.Text.Trim();
|
_AddPropDto.Description = TextEditDescription.Text.Trim();
|
_AddPropDto.Code = TextEditCode.Text.Trim();
|
_AddPropDto.UnitName = TextEditUnitName.Text.Trim();
|
_AddPropDto.IsNull = CheckEditIsNull.Checked;
|
if (TextEditFormat.SelectedIndex == 0)
|
{
|
_AddPropDto.Format = (Yw.Basic.ePropFormat)ePropFormat.Integer;
|
}
|
else if (TextEditFormat.SelectedIndex == 1)
|
{
|
_AddPropDto.Format = (Yw.Basic.ePropFormat)ePropFormat.Bigint;
|
}
|
else if (TextEditFormat.SelectedIndex == 2)
|
{
|
_AddPropDto.Format = (Yw.Basic.ePropFormat)ePropFormat.Numeric;
|
}
|
else if (TextEditFormat.SelectedIndex == 3)
|
{
|
_AddPropDto.Format = (Yw.Basic.ePropFormat)ePropFormat.Text;
|
}
|
else if (TextEditFormat.SelectedIndex == 4)
|
{
|
_AddPropDto.Format = (Yw.Basic.ePropFormat)ePropFormat.MultiText;
|
}
|
else if (TextEditFormat.SelectedIndex == 5)
|
{
|
_AddPropDto.Format = (Yw.Basic.ePropFormat)ePropFormat.Time;
|
}
|
else
|
{
|
_AddPropDto.Format = (Yw.Basic.ePropFormat)ePropFormat.Boolen;
|
}
|
var selected = (ImageComboBoxItem)this.imageComboBoxEditPropGroup.SelectedItem;
|
if (await this.ReloadDataEvent.Invoke(_AddPropDto, selected.Description, TextEditValue.Text))
|
{
|
MessageBoxHelper.ShowSuccess("添加成功!");
|
}
|
else
|
{
|
MessageBoxHelper.ShowError("添加失败!");
|
}
|
this.DialogResult = DialogResult.OK;
|
this.Close();
|
}
|
}
|
}
|