private void btn_Enregister_Click(object sender, EventArgs e) { if (textBoxRef.Text == "" && textBoxDes.Text == "" && textBoxPrix.Text == "" && textBoxQte.Text == "") { MessageBox.Show("Selectionner un Article"); } else { if (ValidateChildren(ValidationConstraints.Enabled)) { DAL d = new DAL(); Class_Article a = new Class_Article(); a.Reference1 = textBoxRef.Text; a.Designation1 = textBoxDes.Text; a.Prix1 = float.Parse(textBoxPrix.Text); a.Quantite1 = int.Parse(textBoxQte.Text); a.Promo1 = checkBox1.Checked; a.Date_Fin1 = Convert.ToDateTime(dateTimePicker1.Value); string rf = textBoxRef.Text; if (d.UpDate(a, rf) == true) { MessageBox.Show("Article Modifié"); Clear(); } else { MessageBox.Show("Article n'est pas Modifié"); } dataGridView1.DataSource = d.SelectAll(); } } }
private void button1_Click(object sender, EventArgs e) { if (ValidateChildren(ValidationConstraints.Enabled)) { DAL d = new DAL(); Class_Article a = new Class_Article(); a.Reference1 = textBoxRef.Text; a.Designation1 = textBoxDes.Text; a.Prix1 = float.Parse(textBoxPrix.Text); a.Quantite1 = int.Parse(textBoxQte.Text); a.Promo1 = checkBox1.Checked; a.Date_Fin1 = Convert.ToDateTime(dateTimePicker2.Value); string refe = textBoxRef.Text; if (d.VerifRef(refe) == false) { if (d.Insert(a) == true) { MessageBox.Show("Article Ajouté"); Clear(); } else { MessageBox.Show("Article n'est pas Ajouté"); } } else { MessageBox.Show("Référence Existe déjà"); } } }
private void button2_Click(object sender, EventArgs e) { DAL d = new DAL(); Facture f = new Facture(); Class_Article a = new Class_Article(); LigneFacture c = new LigneFacture(); f.Num_facture = textBox1.Text; f.Date_facture = dateTimePicker1.Value; // int IdFact = d.Insert Facture(f); // if (IdFact > 0) // { MessageBox.Show("Facture Ajouté"); foreach (DataGridViewRow r in dataGridView1.Rows) { c.Reference = textBox1.Text; //c.IdArticle = Convert.ToString(r.Cells[0].Value); c.Quantite = Convert.ToInt16(r.Cells[3].Value); d.Insert_Commande(c); int qte = Convert.ToInt16(r.Cells[3].Value); a = d.fill_art_ref(Convert.ToString(r.Cells[0].Value)); // MessageBox.Show("" + a.Quantite1); a.Quantite1 = a.Quantite1 - qte; string refe = Convert.ToString(r.Cells[0].Value); d.UpDate_qte(a, refe); } MessageBox.Show("Facture n'est pas Ajouté"); this.Hide(); }
public Boolean UpDate_qte(Class_Article a, string rf) { conn.Open(); string Marequet = " UPDATE Article SET Quantite = @qte WHERE Reference = '" + rf + "' "; SqlCommand cmd = new SqlCommand(Marequet, conn); cmd.Parameters.AddWithValue("@qte", a.Quantite1); cmd.ExecuteNonQuery(); conn.Close(); return(true); }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { DAL d = new DAL(); valeur = comboBox1.SelectedValue.ToString(); Class_Article a = new Class_Article(); Class_Article at = d.get_reference(valeur); textBoxRef.Text = at.Reference1; textBoxPrix.Text = Convert.ToString(at.Prix1); textBoxRef.ReadOnly = true; textBoxPrix.ReadOnly = true; }
//Ajout d'un Article public Boolean Insert(Class_Article a) { conn.Open(); string Marequet = "INSERT INTO Article (Reference,Designation,Prix,Quantite,Promo,DateFinPromo) Values (@rf,@des,@px,@qte,@prm,@df)"; SqlCommand cmd = new SqlCommand(Marequet, conn); cmd.Parameters.AddWithValue("@rf", a.Reference1); cmd.Parameters.AddWithValue("@des", a.Designation1); cmd.Parameters.AddWithValue("@px", a.Prix1); cmd.Parameters.AddWithValue("@qte", a.Quantite1); cmd.Parameters.AddWithValue("@prm", a.Promo1); cmd.Parameters.AddWithValue("@df", a.Date_Fin1); cmd.ExecuteNonQuery(); conn.Close(); return(true); }
// Modifier Article public Boolean UpDate(Class_Article a, string rf) { conn.Open(); string Marequet = " UPDATE Article SET Reference = @rf, Designation = @des, Prix = @px, Quantite = @qte, Promo = @prm, DateFinPromo = @df WHERE Reference = '" + rf + "' "; SqlCommand cmd = new SqlCommand(Marequet, conn); cmd.Parameters.AddWithValue("@rf", a.Reference1); cmd.Parameters.AddWithValue("@des", a.Designation1); cmd.Parameters.AddWithValue("@px", a.Prix1); cmd.Parameters.AddWithValue("@qte", a.Quantite1); cmd.Parameters.AddWithValue("@prm", a.Promo1); cmd.Parameters.AddWithValue("@df", a.Date_Fin1); cmd.ExecuteNonQuery(); conn.Close(); return(true); }
private void button1_Click(object sender, EventArgs e) { if (MessageBox.Show("Êtes-vous sûr de vouloir Supprimer" + "\n" + "ces enregistrements?" + "\n" + "A T T E N T I O N." + "\n" + "Cette opération est irréversible...", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { DAL d = new DAL(); Class_Article a = new Class_Article(); a.Reference1 = this.dataGridView1.CurrentRow.Cells[1].Value.ToString(); // MessageBox.Show("" + a.Reference1); d.Delete(a.Reference1); dataGridView1.DataSource = d.SelectAll(); } else { this.Close(); } }
public Class_Article get_reference(string des) { Class_Article A = new Class_Article(); conn.Open(); string Marequet = "SELECT * FROM Article where designation= @des"; SqlCommand cmd = new SqlCommand(Marequet, conn); cmd.Parameters.AddWithValue("@des", des); DataTable dts = new DataTable(); SqlDataReader r1 = cmd.ExecuteReader(); while (r1.Read()) { A.Reference1 = r1.GetString(1); A.Prix1 = r1.GetFloat(6); A.Quantite1 = r1.GetInt32(5); } conn.Close(); return(A); }
public Class_Article fill_art_ref(string v) { Class_Article a = new Class_Article(); conn.Open(); String reqsql = "SELECT id, reference, designation, promo, datefinpromo, quantite, prix FROM Article WHERE Reference = @rf"; SqlCommand cmd = new SqlCommand(reqsql, conn); cmd.Parameters.AddWithValue("@rf", v); SqlDataReader reader = cmd.ExecuteReader(); //reader = cmd.ExecuteReader(); string rf; float prix; int? qte; while (reader.Read()) { try { rf = reader.GetString(1); prix = reader.GetFloat(6); qte = reader.GetInt32(5); a.Reference1 = rf; a.Prix1 = Convert.ToSingle(prix); a.Quantite1 = Convert.ToInt16(qte); } catch { } } reader.Close(); conn.Close(); return(a); }
public Class_Article fill_textbox(string v) { Class_Article a = new Class_Article(); conn.Open(); String reqsql = "SELECT Reference , PrixUnit, Quantite FROM Article WHERE Designation = @des"; SqlCommand cmd = new SqlCommand(reqsql, conn); cmd.Parameters.AddWithValue("@des", v); SqlDataReader reader = cmd.ExecuteReader(); reader = cmd.ExecuteReader(); string rf; float prix; int qte; while (reader.Read()) { rf = reader.GetString(1); prix = reader.GetFloat(5); qte = reader.GetInt16(6); a.Reference1 = rf; a.Prix1 = Convert.ToSingle(prix); a.Quantite1 = Convert.ToInt16(qte); } reader.Close(); conn.Close(); return(a); }