Exemplo n.º 1
0
        public static string GetNewProductCode(ObservableCollection <UnitPriceItemModel> items, string customer, bool isCombined)
        {
            UnitPriceItemModel last = items.Where(x => x.CustomerCode == customer && x.IsCombined == isCombined).OrderByDescending(x => x.Code).FirstOrDefault();
            int newId = 0;

            if (last != null)
            {
                newId = Convert.ToInt32(last.Code.Substring(4)) + 1;
            }
            return(string.Format("{0}{1}{2:D4}", customer, isCombined ? "1" : "0", newId));
        }
Exemplo n.º 2
0
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            string units = (string)values[0];
            ObservableCollection <UnitPriceItemModel> items = (ObservableCollection <UnitPriceItemModel>)values[1];

            string rlt = string.Empty;

            if (!string.IsNullOrEmpty(units))
            {
                string[] names = units.Split(",".ToCharArray());
                foreach (var code in names)
                {
                    UnitPriceItemModel item = items.FirstOrDefault(x => x.Code == code);
                    if (item != null)
                    {
                        rlt += item.Name + ",";
                    }
                }
            }
            return(rlt);
        }