public void DeleteFact(Facture fac) { Article Artic; MySqlCommand = new SqlCommand("DELETE FROM [Facture] WHERE Reference = @Rdel"); MySqlCommand.Parameters.Add("@Rdel", SqlDbType.VarChar).Value = fac.RefProp; foreach (LigneFacture ListLf in fac.ListLgFacture) { DataTable MyDat = new DALArticle().SelectByRef(fac.RefProp); Artic = new Article(ListLf.RefProp, MyDat.Rows[0]["Designation"].ToString(), float.Parse(MyDat.Rows[0]["Prix"].ToString()), Convert.ToBoolean(MyDat.Rows[0]["Promo"].ToString()) , MyDat.Rows[0]["DateInPromo"].ToString(), Int32.Parse(MyDat.Rows[0]["Quantite"].ToString()) + ListLf.QuantProp); new DALArticle().Update(ListLf.RefProp, Artic); } Connexion.FunctionToWrite(MySqlCommand); }
static Facture ConvertRowToFacture(DataRow row) { Facture CurrentFacture = new Facture(); string Reff = (row["Reference"].ToString().Length != 0) ? row["Reference"].ToString() : "pas de reference"; CurrentFacture.RefProp = Reff; float Mnt = float.Parse(row["Montant"].ToString()); CurrentFacture.MontantProp = Mnt; string dateF = (row["Date"].ToString().Length != 0) ? row["Date"].ToString() : "pas de Date"; CurrentFacture.DateProp = Convert.ToDateTime(dateF); return(CurrentFacture); }
public Facture GetFactureByRef(string _Ref) { Facture FactureSearched = new Facture(); MySqlCommand = new SqlCommand("select * from [Facture] where Reference = @_Ref "); MySqlCommand.Parameters.Add("@_Ref", SqlDbType.VarChar).Value = _Ref; dt = Connexion.FunctionToRead(MySqlCommand); foreach (DataRow row in dt.Rows) { FactureSearched = ConvertRowToFacture(row); } if (dt.Rows.Count == 0) { return(null); } else { return(FactureSearched); } }
public List <Facture> GetFactureList( ) { List <Facture> ListF = new List <Facture>(); Facture Factures = new Facture(); MySqlCommand = new SqlCommand("select [Reference],[Montant], [Date] FROM[Facture] "); dt = Connexion.FunctionToRead(MySqlCommand); foreach (DataRow row in dt.Rows) { Factures = ConvertRowToFacture(row); ListF.Add(Factures); } if (dt.Rows.Count == 0) { return(null); } else { return(ListF); } }
public AjouterLineFacture(Facture Fac) { InitializeComponent(); fact = Fac; Txt_RefFac.Text = Fac.RefProp; }