public BindableCollection <ReceiptModel> GiveCollection(DataTable cs) { List <ReceiptModel> output = new List <ReceiptModel>(); SeasonModel sm = new SeasonModel(); CustomerModel cm = new CustomerModel(); CurrencyModel cr = new CurrencyModel(); FactureModel fm = new FactureModel(); foreach (DataRow row in cs.Rows) { cm = cm.Get(System.Convert.ToInt32(row[2].ToString())); ReceiptModel ctm = new ReceiptModel { Id = System.Convert.ToInt32(row[0].ToString()), Number = System.Convert.ToInt32(row[1].ToString()), Customer = cm.Id, CustomerName = cm.Name, }; if (row[3].ToString() != null && row[3].ToString() != string.Empty) { sm = sm.Get(System.Convert.ToInt32(row[3].ToString())); ctm.Season = sm.Id; ctm.SeasonYear = sm.Year; } if (row[4].ToString() != null && row[4].ToString() != string.Empty) { ctm.Details = row[4].ToString(); } if (row[5].ToString() != null && row[5].ToString() != string.Empty) { ctm.Amount = System.Convert.ToDecimal(row[5].ToString()); if (row[6].ToString() != null && row[6].ToString() != string.Empty) { cr = cr.Get(System.Convert.ToInt32(row[6].ToString())); ctm.Currency = cr.Id; ctm.CurrencySymbol = cr.Symbol; } } if (row[7].ToString() != null && row[7].ToString() != string.Empty) { ctm.Delivery = System.Convert.ToDateTime(row[7].ToString()); } if (row[8].ToString() != null && row[8].ToString() != string.Empty) { fm = fm.Get(System.Convert.ToInt32(row[8].ToString())); ctm.Facture = fm.Id; } if (row[9].ToString() != null && row[9].ToString() != string.Empty) { ctm.Cheque = row[9].ToString(); } output.Add(ctm); } return(new BindableCollection <ReceiptModel>(output)); }
public BindableCollection <FactureModel> GiveCollection(DataTable cs) { List <FactureModel> output = new List <FactureModel>(); SeasonModel sm = new SeasonModel(); CustomerModel cm = new CustomerModel(); foreach (DataRow row in cs.Rows) { cm = cm.Get(System.Convert.ToInt32(row[4].ToString())); FactureModel ctm = new FactureModel { Id = System.Convert.ToInt32(row[0].ToString()), Number = System.Convert.ToInt32(row[1].ToString()), Customer = cm.Id, CustomerName = cm.Name, Cleared = System.Convert.ToBoolean(row[6].ToString()), }; if (row[3] != null && row[3].ToString() != "") { sm = sm.Get(System.Convert.ToInt32(row[3].ToString())); ctm.Season = sm.Id; ctm.SeasonYear = sm.Year; } if (row[2].ToString() != null && row[2].ToString() != string.Empty) { ctm.Name = row[2].ToString(); } ctm.NameNumber = ctm.Name + " - " + ctm.Number; if (row[5].ToString() != null && row[5].ToString() != string.Empty) { ctm.Delivery = System.Convert.ToDateTime(row[5].ToString()); } try { CurrencyModel c = new CurrencyModel(); BindableCollection <CurrencyModel> currencies = c.GiveCollection(c.All()); if (currencies.Count > 0) { ctm.Amount = (float)ctm.TotalAmount(currencies[0].Id); Currency = currencies[0].Id; FullAmount = Amount + " " + currencies[0].Symbol; } } catch (Exception e) { } output.Add(ctm); } return(new BindableCollection <FactureModel>(output)); }