public static decimal addCurrency(ticketwindow.Class.ClassSync.Currency c, int count) { count_Currency cc_ = new count_Currency(); cc_.count = count; cc_.currency = c; int indx = cc.FindIndex(l => l.currency.CustomerId == cc_.currency.CustomerId); if (indx == -1) { cc.Add(cc_); } else { cc[indx].count += count; } int h = 0; while (h < count) { h++; List_Currency.Add(c); } return(List_Currency.Sum(l => l.Currency_money)); }
public static List <count_Currency> transform(decimal d, ClassSync.TypesPayDB typePay) { List <count_Currency> r = new List <count_Currency>(); List <ClassSync.Currency> lc = ClassSync.Currency.List_Currency.Where(l => l.TypesPayId == typePay.Id).ToList(); lc.Sort((x, y) => decimal.Compare(-x.Currency_money, -y.Currency_money)); List <ClassSync.Currency> lb = new List <ClassSync.Currency> (); foreach (ClassSync.Currency c in lc) { while (d >= 0) { d = d - c.Currency_money; if (d >= 0) { count_Currency countCurrency = new count_Currency(); countCurrency.count = 1; countCurrency.currency = c; r.Add(countCurrency); } else { d = d + c.Currency_money; break; } } } return(r); }