public void ClearFacture() { FactureModel fm = new FactureModel(); fm = fm.Get((int)Facture); fm.ClearUnclear(true); }
public BindableCollection <FactureModel> GetMyUnClearedFacturesWithOldCleared(int id) { BindableCollection <FactureModel> factures = new BindableCollection <FactureModel>(); if (this.Id == 0) { return(null); } else { FactureModel fm = new FactureModel(); string[] value = new string[2] { "number", Id.ToString() }; List <KeyValuePair <string, string[]> > Data = new List <KeyValuePair <string, string[]> > { new KeyValuePair <string, string[]>("customer_id", value) }; value = new string[2] { "number", "0" }; Data.Add(new KeyValuePair <string, string[]>("cleared", value)); List <KeyValuePair <string, string[]> > Union = new List <KeyValuePair <string, string[]> >(); value = new string[2] { "number", id.ToString() }; Union.Add(new KeyValuePair <string, string[]>("id", value)); DataTable full_table = fm.FindByParameters(Data, Union); factures = fm.GiveCollection(full_table); } return(factures); }
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)); }
/** * Get All factures for this customers if season is null * Get All factures for this customers that have a season if season is -1 * Get All factures in specific season for this customers if season.Id is not 0 * Get All factures that don't belong to a seson for this customers if season.Id is 0 */ public BindableCollection <FactureModel> GetMyFactures(int?season = null) { BindableCollection <FactureModel> factures = new BindableCollection <FactureModel>(); if (this.Id == 0) { return(null); } else { FactureModel fm = new FactureModel(); string[] value = new string[2] { "number", Id.ToString() }; List <KeyValuePair <string, string[]> > Data = new List <KeyValuePair <string, string[]> > { new KeyValuePair <string, string[]>("customer_id", value) }; if (season != null) { switch (season) { case 0: value = new string[2] { "number", "NULL" }; break; case -1: value = new string[2] { "number", "NOT-NULL" }; break; default: value = new string[2] { "number", season.ToString() }; break; } Data.Add(new KeyValuePair <string, string[]>("season_id", value)); } factures = fm.GiveCollection(fm.FindByParameters(Data)); } return(factures); }
/** * Get Un-Clearerd factures for this customers if season is null * Get Un-Clearerd factures in specific season for this customers if season.Id is not 0 * Get Un-Clearerd factures that don't belong to a seson for this customers if season.Id is 0 */ public BindableCollection <FactureModel> GetMyUnClearedFactures(int?season = null) { BindableCollection <FactureModel> factures = new BindableCollection <FactureModel>(); if (this.Id == 0) { return(null); } else { FactureModel fm = new FactureModel(); string[] value = new string[2] { "number", Id.ToString() }; List <KeyValuePair <string, string[]> > Data = new List <KeyValuePair <string, string[]> > { new KeyValuePair <string, string[]>("customer_id", value) }; value = new string[2] { "number", "0" }; Data.Add(new KeyValuePair <string, string[]>("cleared", value)); if (season != null) { if (season != 0) { value = new string[2] { "number", season.ToString() } } ; else { value = new string[2] { "number", "NULL" } }; Data.Add(new KeyValuePair <string, string[]>("season_id", value)); } factures = fm.GiveCollection(fm.FindByParameters(Data)); } return(factures); }