namespace HStation.WinFrmUI.Basic
|
{
|
public partial class SetSysPropForCatalogDlg : Form
|
{
|
public SetSysPropForCatalogDlg()
|
{
|
InitializeComponent();
|
this.gridView1.Columns["GroupName"].Group();
|
}
|
|
private List<SysPropMappingViewModel> _allBindingList = new List<SysPropMappingViewModel>();
|
|
private Yw.BLL.SysPropMapping _bll = null;
|
|
private long _CatlogID;
|
|
public async void SetBindingData(long ID)
|
{
|
_CatlogID = ID;
|
_bll = new Yw.BLL.SysPropMapping();
|
var PropTreeList = await _bll.GetHaveListByCatalogID(ID);
|
foreach (var item in PropTreeList)
|
{
|
if (item.PropList.Count > 0)
|
{
|
foreach (var child in item.PropList)
|
{
|
var model = new SysPropMappingViewModel();
|
model.GroupName = item.Name;
|
model.ID = child.ID;
|
model.Name = child.Name;
|
model.IsHave = child.Have;
|
model.IsNull = child.IsNull;
|
model.DefaultValue = child.DefaultValue;
|
model.UnitName = child.UnitName;
|
model.Inherit = child.Inherit;
|
// model.ChoiceIds = child.ChoiceList;
|
_allBindingList.Add(model);
|
}
|
}
|
}
|
this.sysCatalogPropViewModelBindingSource.DataSource = _allBindingList;
|
this.gridView1.ExpandAllGroups();
|
}
|
|
// 完成
|
private async void BtnOk_Click(object sender, EventArgs e)
|
{
|
var list = new List<Yw.Vmo.SysPropMappingSetterVmo>();
|
foreach (var item in _allBindingList)
|
{
|
if (item.IsHave)
|
{
|
list.Add(new Yw.Vmo.SysPropMappingSetterVmo
|
{
|
PropID = item.ID,
|
UnitName = item.UnitName,
|
IsNull = item.IsNull,
|
DefaultValue = item.DefaultValue,
|
ChoiceIds = item.ChoiceIds,
|
});
|
}
|
}
|
if (await _bll.SetByCatalogID(_CatlogID, list))
|
{
|
MessageBoxHelper.ShowSuccess("修改成功!");
|
}
|
else
|
{
|
MessageBoxHelper.ShowError("修改失败"!);
|
return;
|
}
|
this.Close();
|
}
|
|
private void gridView1_ShowingEditor(object sender, System.ComponentModel.CancelEventArgs e)
|
{
|
var vm = this.gridView1.GetCurrentViewModel(_allBindingList);
|
if (vm != null)
|
{
|
if (vm.Inherit)
|
{
|
e.Cancel = true;
|
}
|
}
|
}
|
|
private void gridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
|
{
|
var gridView = sender as DevExpress.XtraGrid.Views.Grid.GridView;
|
if (gridView != null)
|
{
|
foreach (var item in _allBindingList)
|
{
|
int index = _allBindingList.IndexOf(item);
|
if (gridView.GetRowHandle(index) == e.RowHandle)
|
{
|
if (item.Inherit)
|
{
|
e.Appearance.BackColor = Color.Gray;
|
}
|
break;
|
}
|
}
|
}
|
}
|
}
|
}
|