本文整理汇总了C#中Report.SelectCause方法的典型用法代码示例。如果您正苦于以下问题:C# Report.SelectCause方法的具体用法?C# Report.SelectCause怎么用?C# Report.SelectCause使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Report
的用法示例。
在下文中一共展示了Report.SelectCause方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateForStoppageReport
/// <summary>
/// Creates an instance of FilterBoxVmCollection to be used as a collection of stoppage reports (cause)
/// </summary>
/// <param name="parent">Instance of <see cref="StoppageReportVm"/> that has this collection</param>
/// <param name="selectedIds">default cause Ids (must be like: {level1Id, level2Id, level3Id})</param>
/// <returns></returns>
public static FilterBoxVmCollection CreateForStoppageReport(Report.StoppageReportVm parent, int[] selectedIds)
{
var vm = new FilterBoxVmCollection();
//find causes and create FilterBoxVm instances for each level
var causeDs = new DataServices.CauseDataService();
var causeL1Models = causeDs.GetRoot().Children.Where(x => x.Status == (byte)Common.Status.Active).ToArray();
var causeL3Box = FilterBoxVm.CreateForCause(null);
var causeL2Box = FilterBoxVm.CreateForCause(causeL3Box);
var causeL1Box = FilterBoxVm.CreateForCause(causeL2Box, causeL1Models);
//set the event handlers
causeL3Box.FilterableItemSelected += (s, old, v) =>
{
string code = string.Empty;
if (causeL1Box.SelectedItem != null)
{
code = ((CauseVm)causeL1Box.SelectedItem.ViewModel).Code;
if (causeL2Box.SelectedItem != null)
{
code += ((CauseVm)causeL2Box.SelectedItem.ViewModel).Code;
if (v != null)
code += ((CauseVm)v.ViewModel).Code;
}
}
parent.SelectedCode = code;
parent.SelectCause(v.Id);
};
causeL2Box.FilterableItemSelected += (s, old, v) =>
{
string code = string.Empty;
if (causeL1Box.SelectedItem != null)
{
code = ((CauseVm)causeL1Box.SelectedItem.ViewModel).Code;
if (v != null)
code += ((CauseVm)v.ViewModel).Code;
}
parent.SelectedCode = code;
causeL3Box.FilteredList.Clear();
if (v == null) return;
foreach (var item in ((CauseVm)v.ViewModel).ChildrenModels.Where(x => x.Status == (byte)Common.Status.Active))
{
causeL3Box.FilteredList.Add(FilterableItemVm.CreateForCause(causeL3Box, item));
}
};
causeL1Box.FilterableItemSelected += (s, old, v) =>
{
if (v != null)
parent.SelectedCode = ((CauseVm)v.ViewModel).Code;
causeL2Box.FilteredList.Clear();
if (v == null) return;
foreach (var item in ((CauseVm)v.ViewModel).ChildrenModels.Where(x => x.Status == (byte)Common.Status.Active))
{
causeL2Box.FilteredList.Add(FilterableItemVm.CreateForCause(causeL2Box, item));
}
};
//add filterboxes to the collection
vm.FilterBoxes.Add(causeL1Box);
vm.FilterBoxes.Add(causeL2Box);
vm.FilterBoxes.Add(causeL3Box);
//select the default cause
try
{
if (selectedIds != null)
{
causeL1Box.SelectedItem = causeL1Box.FilteredList.FirstOrDefault(x => x.Id == selectedIds[0]);
causeL2Box.SelectedItem = causeL2Box.FilteredList.FirstOrDefault(x => x.Id == selectedIds[1]);
causeL3Box.SelectedItem = causeL3Box.FilteredList.FirstOrDefault(x => x.Id == selectedIds[2]);
}
else
{
causeL1Box.SelectedItem = causeL1Box.FilteredList.FirstOrDefault();
causeL2Box.SelectedItem = causeL2Box.FilteredList.FirstOrDefault();
causeL3Box.SelectedItem = causeL3Box.FilteredList.FirstOrDefault();
}
}
catch { }
vm.AddCommand = new Commands.Command(o => { });
return vm;
}