当前位置: 首页>>代码示例>>C#>>正文


C# Report.SelectCause方法代码示例

本文整理汇总了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;
		}
开发者ID:T1Easyware,项目名称:Soheil,代码行数:92,代码来源:FilterBoxVmCollection.cs


注:本文中的Report.SelectCause方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。