public void AddByList(Facture fc) { try { Article Artic; SqlCommand MySqlCommand = new SqlCommand("insert into [Facture](Reference,Montant, Date) values(@Facture_ref, @Facture_Montant ,@Facture_date)"); MySqlCommand.Parameters.Add("@Facture_ref", SqlDbType.VarChar).Value = Convert.ToString(fc.RefProp); MySqlCommand.Parameters.Add("@Facture_Date", SqlDbType.DateTime).Value = Convert.ToDateTime(fc.DateProp); MySqlCommand.Parameters.Add("@Facture_Montant", SqlDbType.Int).Value = fc.MontantProp; Connexion.FunctionToWrite(MySqlCommand); foreach (LigneFacture ListLf in fc.ListLgFacture) { MySqlCommand = new SqlCommand("insert into [LigneFacture](IdFacture, IdArticle, Reference , Pu, Quantite) values(@FactureId, @ArticleId, @articles_ref, @articles_prix, @articles_quant)"); MySqlCommand.Parameters.Add("@articles_ref", SqlDbType.VarChar).Value = Convert.ToString(ListLf.RefProp); MySqlCommand.Parameters.Add("@articles_prix", SqlDbType.Float).Value = Convert.ToDouble(ListLf.PrixUProp); MySqlCommand.Parameters.Add("@articles_quant", SqlDbType.Int).Value = Convert.ToInt32(ListLf.QuantProp); MySqlCommand.Parameters.Add("@ArticleId", SqlDbType.Int).Value = Convert.ToInt32(GetArticleId(ListLf.RefProp)); MySqlCommand.Parameters.Add("@FactureId", SqlDbType.Int).Value = Convert.ToInt32(GetFactureId(fc.RefProp)); DataTable MyDat = new DALArticle().SelectByRef(ListLf.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); } } catch (SqlException es) { MessageBox.Show(es.Message); } }
public void Add(Article artic) { MySqlCommand = new SqlCommand("insert into [Article](Reference, Designation, Prix, Promo, DateInPromo, Quantite) values(@articles_ref, @articles_desi, @articles_prix, @articles_promo, @articles_datepro, @articles_quant)"); MySqlCommand.Parameters.Add("@articles_ref", SqlDbType.VarChar).Value = Convert.ToString(artic.RefProp); MySqlCommand.Parameters.Add("@articles_desi", SqlDbType.VarChar).Value = Convert.ToString(artic.DesiProp); MySqlCommand.Parameters.Add("@articles_prix", SqlDbType.Float).Value = Convert.ToDouble(artic.PrixProp); MySqlCommand.Parameters.Add("@articles_promo", SqlDbType.Bit).Value = Convert.ToBoolean(artic.PromoProp); MySqlCommand.Parameters.Add("@articles_datepro", SqlDbType.Date).Value = Convert.ToDateTime(artic.DatePromoProp); MySqlCommand.Parameters.Add("@articles_quant", SqlDbType.Int).Value = Convert.ToInt32(artic.QuantProp); Connexion.FunctionToWrite(MySqlCommand); }
public void AddUser(User newUser) { MySqlCommand = new SqlCommand("insert into [Users]( FirstName, LastName, Email,PassWord, Profil )" + "values ( @FirstName, @LastName,@Email, @PassWord, @Profil)"); MySqlCommand.Parameters.Add("@Email", SqlDbType.VarChar).Value = newUser.UserEmail; MySqlCommand.Parameters.Add("@FirstName", SqlDbType.VarChar).Value = newUser.UserFirstName; MySqlCommand.Parameters.Add("@LastName", SqlDbType.VarChar).Value = newUser.UserLastName; MySqlCommand.Parameters.Add("@PassWord", SqlDbType.VarChar).Value = newUser.UserPassWord; MySqlCommand.Parameters.Add("@Profil", SqlDbType.VarChar).Value = newUser.UserProfil; Connexion.FunctionToWrite(MySqlCommand); }