public CustomParamValueSubTreeView() { ShowTotalRow = false; ShowNodeImage = false; KeyPropertyName = new CustomParamValue().GetPrimaryKeyPropertyName(); ParentIdPropertyName = CustomParamValue.CPVParentPropertyName.ToUpper(); //DefaultSortingField = CustomParamValue.CustomParamCodePropertyName.ToUpper(); InitializeComponent(); AutoExpandAllNodes = true; Menu = new MenuViewModel(GetType().GetFullNameWithoutVersion()) { NotUseGlobalLayoutSettings = true }; NewCommand = new DelegateCustomCommand(OnNew, CanNew); EditCommand = new DelegateCustomCommand(OnEdit, CanEdit); DeleteCommand = new DelegateCustomCommand(OnDelete, CanDelete); InitializeBaseCommandsMenu(); LayoutRoot.DataContext = this; customTreeListControl.MaxHeight = CalcMaxHeight(); customTreeListControl.RestoredLayoutFromXml += CustomTreeListControlOnRestoredLayoutFromXml; PropertyChanged += OnPropertyChanged; }
public static Type GetValueType(CustomParamValue cpv) { if (cpv == null) { return(null); } var cp = cpv.Cp; if (cp == null) { return(null); } if (cp.ValueType == null) { if (string.IsNullOrEmpty(cp.ObjectlookupCode_R)) { cp.ValueType = IoC.Instance.Resolve <ISysObjectManager>().GetTypeBySysObjectId((int)cp.CustomParamDataType); } else //Если лукап определяем тип ValueMember { var lookupInfo = LookupHelper.GetLookupInfo(cp.ObjectlookupCode_R); var itemType = LookupHelper.GetItemSourceType(lookupInfo); var td = TypeDescriptor.GetProperties(itemType); var vmt = td.Find(lookupInfo.ValueMember, true); if (vmt != null) { cp.ValueType = vmt.PropertyType; } } } return(cp.ValueType); }
public static string GetFormattedValue(CustomParamValue cpv) { if (cpv == null) { return(null); } var cp = cpv.Cp; if (cp == null) { return(null); } var value = cpv.CPVValue; if (!string.IsNullOrEmpty(cp.ObjectlookupCode_R)) { return(LookupHelper.GetDispalyMemberValue(cp.ObjectlookupCode_R, value)); } var fieldType = GetValueType(cpv); if (fieldType == null) { return(value); } var type = fieldType.GetNonNullableType(); var existsFormat = !string.IsNullOrEmpty(cp.CustomParamFormat); if (type == typeof(DateTime)) { var dtvalue = new StringToDateTimeConverter().Convert(value, null, GetDateTimeFormat(), Thread.CurrentThread.CurrentCulture) as DateTime?; if (dtvalue.HasValue) { return(existsFormat ? dtvalue.Value.ToString(cp.CustomParamFormat) : dtvalue.Value.ToShortDateString()); } return(null); } if (type.IsPrimitive || type == typeof(decimal)) { var nvalue = new StringToNumericConverter().Convert(value, null, fieldType, Thread.CurrentThread.CurrentCulture); if (nvalue != null) { return(existsFormat ? string.Format("{0}:" + cp.CustomParamFormat, nvalue) : nvalue.ToString()); } return(null); } return(value); }
private void CollectItems(CustomParamValue cpv, CustomParam[] cps, List <CustomParamValue> items) { var childs = cps.Where(i => i.CustomParamParent.EqIgnoreCase(cpv.CustomParamCode)).ToArray(); if (childs.Length > 0) { foreach (var cp in childs) { // есть ли уже этот элемент в коллекции var existChild = items.FirstOrDefault( i => i.CPVParent == cpv.CPVID && i.CustomParamCode == cp.GetKey <string>()); if (existChild == null) { existChild = CreateItem(cp, cpv.CPVID); items.Add(existChild); } existChild.Cp = cp; // пусть соберет своих деток CollectItems(existChild, cps, items); } } }
public static T[] GetChildsCpvByParentCpv <T>(IEnumerable <CustomParamValue> cpvs, CustomParamValue parentcpv, bool addToResultParentcpv) where T : CustomParamValue { if (parentcpv == null || cpvs == null) { return(new T[0]); } var result = new List <T>(); foreach (var p in cpvs.Where(p => p.CPVParent == parentcpv.CPVID)) { result.Add((T)p); var childs = GetChildsCpvByParentCpv <T>(cpvs, p, false); if (childs.Length > 0) { result.AddRange(childs); } } // Чтобы Parent был в конце списка if (addToResultParentcpv) { result.Add((T)parentcpv); } return(result.ToArray()); }
private bool ProccesCvps(ICollection <IWBPosInput> itemsToProcess, CustomParamValue canAskCpvConfirm, IWBPosInput item, DateTime expDate, CustomParamValue defaultValueCpv, string cpvType, Func <IWBPosInput, DateTime, string, MessageBoxResult> procBlQlf) { var exceptionMessage = string.Empty; var extMessage = string.Empty; var manageFlage = string.Empty; var defCpvVal = defaultValueCpv == null ? string.Empty : defaultValueCpv.CPVValue; switch (cpvType) { case "BLOCK": exceptionMessage = "Должно быть указано не менее одного параметра: 'Блокировка' или 'Разрешить выбор на DCL' в менеджере приемки. Пожалуйста, свяжитесь со службой поддержки"; extMessage = "Пользователь отказался вводить блокировку"; manageFlage = "EXPDATEACCEPTWITHBLOCKING_OK"; break; case "QLF": exceptionMessage = "Должно быть указано не менее одного параметра: 'Квалификация' или 'Разрешить выбор на DCL' в менеджере приемки. Пожалуйста, свяжитесь со службой поддержки"; extMessage = "Пользователь отказался вводить квалификацию"; manageFlage = "EXPDATEACCEPTWITHQUALIFI_OK"; break; } var funcRes = MessageBoxResult.No; if (canAskCpvConfirm != null && canAskCpvConfirm.CPVValue == "1") { funcRes = procBlQlf(item, expDate, defCpvVal); } else if (defaultValueCpv != null && (canAskCpvConfirm == null || (canAskCpvConfirm.CPVValue == "0"))) { switch (cpvType) { case "BLOCK": item.IWBPosBlocking = string.IsNullOrEmpty(item.IWBPosBlocking) ? defaultValueCpv.CPVValue : item.IWBPosBlocking; break; case "QLF": item.QLFCODE_R = string.IsNullOrEmpty(item.QLFCODE_R) || item.QLFCODE_R == "QLFNORMAL" ? defaultValueCpv.CPVValue ?? "QLFNORMAL" : item.QLFCODE_R; break; } funcRes = MessageBoxResult.Yes; } else if (defaultValueCpv == null && (canAskCpvConfirm == null || canAskCpvConfirm.CPVValue == "0")) { throw new OperationException( exceptionMessage); } switch (funcRes) { case MessageBoxResult.Yes: item.ManageFlag += (!string.IsNullOrEmpty(item.ManageFlag) ? "," : string.Empty) + manageFlage; break; case MessageBoxResult.No: SkipItem(item, ExpDateMessage(expDate, item) + extMessage); itemsToProcess.Remove(item); break; default: SkipItem(item, ExpDateMessage(expDate, item) + extMessage + " Прерываем выполнение"); return(false); } return(true); }