private void bunifuDropdown1_onItemSelected_1(object sender, EventArgs e) { string delimiteur = " "; char[] limite = delimiteur.ToCharArray(); string value = bunifuDropdown1.selectedValue; string[] split = value.Split(limite); string req1 = "select IdClient from Client where Nom='" + split[1] + "'"; SqlDataReader d1 = ClassConnection.FillDataReader(req1); if (d1.Read()) { Id_Client = (int)d1["IdClient"]; d1.Close(); } string req3 = @"SELECT dbo.Material.Nom_Mt, dbo.Material.Nombre, dbo.Material.image, dbo.Material.Id_C, dbo.Material.Prix FROM dbo.Client INNER JOIN dbo.Commande ON dbo.Client.IdClient = dbo.Commande.IdClient INNER JOIN dbo.Material ON dbo.Commande.Id_C = dbo.Material.Id_C where dbo.Client.IdClient =" + Id_Client + ""; ClassConnection.OpenCnx(); SqlDataReader d2 = ClassConnection.FillDataReader(req3); dataGridView2.Rows.Clear(); while (d2.Read()) { dataGridView2.Rows.Add(d2[0], d2[1], d2[2], d2[3], d2[4]); } d2.Close(); }
private void bunifuDropdown1_onItemSelected(object sender, EventArgs e) { string delimiteur = " "; char[] limite = delimiteur.ToCharArray(); string value = bunifuDropdown1.selectedValue; string[] split = value.Split(limite); string req1 = "select IdClient from Client where Nom='" + split[1] + "'"; SqlDataReader dr1 = ClassConnection.FillDataReader(req1); if (dr1.Read()) { Id_Client = (int)dr1["IdClient"]; string req3 = "SELECT Id_C from Commande where IdClient=" + Id_Client + ""; ClassConnection.OpenCnx(); dr1.Close(); SqlDataReader dr2 = ClassConnection.FillDataReader(req3); if (dr2.Read()) { Id_C = (int)dr2["Id_C"]; } dr2.Close(); } }
private void Material_Load(object sender, EventArgs e) { dataGridView2.Columns[2].Visible = false; string req = "SELECT * FROM Material"; SqlDataReader dr = ClassConnection.FillDataReader(req); while (dr.Read()) { dataGridView2.Rows.Add(dr[0], dr[1], dr[2], dr[3], dr[4]); } dr.Close(); string req1 = "SELECT * FROM Client ORDER BY IdClient DESC"; SqlDataReader dr1 = ClassConnection.FillDataReader(req1); while (dr1.Read()) { bunifuDropdown1.AddItem(dr1["Prenom"] + " " + dr1["Nom"]); } dr1.Close(); dataGridView2.BorderStyle = BorderStyle.None; dataGridView2.AlternatingRowsDefaultCellStyle.BackColor = Color.FromArgb(238, 239, 249); dataGridView2.CellBorderStyle = DataGridViewCellBorderStyle.SingleHorizontal; dataGridView2.DefaultCellStyle.SelectionBackColor = Color.DarkTurquoise; dataGridView2.DefaultCellStyle.SelectionForeColor = Color.WhiteSmoke; dataGridView2.BackgroundColor = Color.White; dataGridView2.EnableHeadersVisualStyles = false; dataGridView2.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.None; dataGridView2.ColumnHeadersDefaultCellStyle.BackColor = Color.FromArgb(20, 25, 72); dataGridView2.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; }
private void checkBox1_CheckedChanged(object sender, EventArgs e) { if (bunifuDropdown1.selectedIndex == -1) { MessageBox.Show("Selectioné un client", "Ereur", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { if (checkBox1.Checked == true) { ClassConnection.OpenCnx(); string delimiteur = " "; char[] limite = delimiteur.ToCharArray(); string value = bunifuDropdown1.selectedValue; string[] split = value.Split(limite); string req1 = "select IdClient from Client where Nom='" + split[1] + "'"; SqlDataReader dr1 = ClassConnection.FillDataReader(req1); if (dr1.Read()) { Id_Client = (int)dr1["IdClient"]; string req2 = "insert into Commande values(" + Id_Client + ")"; dr1.Close(); ClassConnection.Excute(req2); } bunifuImageButton1.Enabled = true; bunifuImageButton2.Enabled = true; } else { bunifuImageButton1.Enabled = false; bunifuImageButton2.Enabled = false; } } }
private void bunifuFlatButton1_Click(object sender, EventArgs e) { if (strFilePath == "") { if (ImageByteArray.Length != 0) { ImageByteArray = new byte[] { } } ; } else { Image temp = new Bitmap(strFilePath); MemoryStream strm = new MemoryStream(); temp.Save(strm, System.Drawing.Imaging.ImageFormat.Jpeg); ImageByteArray = strm.ToArray(); } string req4 = "update Material set Nombre=" + textBox5.Text + ", image='" + ImageByteArray + "',Prix=" + textBox4.Text + " where Nom_Mt='" + textBox6.Text + "'"; ClassConnection.Excute(req4); dataGridView2.Rows.Clear(); dataGridView2.Columns[2].Visible = false; string req = "SELECT * FROM Material"; SqlDataReader dr = ClassConnection.FillDataReader(req); while (dr.Read()) { dataGridView2.Rows.Add(dr[1], dr[2], dr[3], dr[4], dr[5]); } dr.Close(); ClassConnection.CloseCnx(); }
private void LoadNextImage() { ClassConnection.OpenCnx(); SqlCommand cmd = new SqlCommand("select Image from Image where ImageID=" + imageNumber + "", ClassConnection.cnx); string req = "select Image from Image where ImageID=" + imageNumber + ""; SqlCommand cmd2 = new SqlCommand("SELECT COUNT(*) FROM Image", ClassConnection.cnx); SqlDataReader reader = ClassConnection.FillDataReader(req); if (reader.Read()) { byte[] picData = reader["Image"] as byte[] ?? null; reader.Close(); if (picData != null) { using (MemoryStream ms = new MemoryStream(picData)) { System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(ms); Int32 count = (Int32)cmd2.ExecuteScalar(); slidePic.Image = Image.FromStream(ms); if (imageNumber == count) { imageNumber = 1; } else { imageNumber++; } } } } ClassConnection.CloseCnx(); }
private void bunifuFlatButton2_Click(object sender, EventArgs e) { try { if (radioButton1.Checked == true) { string req = "update client set Prenom='" + textBox2.Text + "',Nom='" + textBox3.Text + "',Adresse='" + textBox6.Text + "',telephone='" + textBox4.Text + "',Email='" + textBox5.Text + "' where IdClient='" + textBox1.Text + "'"; ClassConnection.Excute(req); MessageBox.Show("la Modification effectué", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); refresh(); } if (radioButton2.Checked == true) { string req = "update client set Prenom='" + textBox2.Text + "',Nom='" + textBox3.Text + "',Adresse='" + textBox6.Text + "',telephone='" + textBox4.Text + "',Email='" + textBox5.Text + "' where Nom=" + textBox1.Text + ""; ClassConnection.Excute(req); MessageBox.Show("la Modification effectué", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); refresh(); } if (radioButton3.Checked == true) { string req = "update client set Prenom='" + textBox2.Text + "',Nom='" + textBox3.Text + "',Adresse='" + textBox6.Text + "',telephone='" + textBox4.Text + "',Email='" + textBox5.Text + "' where Prenom='" + textBox1.Text + "'"; ClassConnection.Excute(req); MessageBox.Show("la Modification effectué", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); refresh(); } else { MessageBox.Show("selectioné un radiobutton de modification", "Information", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch { MessageBox.Show("Erreur de modification", "Information", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void bunifuImageButton4_Click_1(object sender, EventArgs e) { try { if (bunifuDropdown1.selectedIndex == -1 || NomMtxt.selectedIndex == -1 || nbMtxt.Text == string.Empty || prixMtxt.Text == string.Empty) { MessageBox.Show("Tu doit Remlir tout les champs", "Ereur", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { string delimiteur = " "; char[] limite = delimiteur.ToCharArray(); string value = bunifuDropdown1.selectedValue; string[] split = value.Split(limite); string req1 = "select IdClient from Client where Nom='" + split[1] + "'"; SqlDataReader dr1 = ClassConnection.FillDataReader(req1); if (dr1.Read()) { Id_Client = (int)dr1["IdClient"]; string req3 = "SELECT Id_C from Commande where IdClient=" + Id_Client + ""; ClassConnection.OpenCnx(); dr1.Close(); SqlDataReader dr2 = ClassConnection.FillDataReader(req3); if (dr2.Read()) { Id_C = (int)dr2["Id_C"]; } dr2.Close(); if (strFilePath == "") { if (ImageByteArray.Length != 0) { ImageByteArray = new byte[] { } } ; } else { Image temp = new Bitmap(strFilePath); MemoryStream strm = new MemoryStream(); temp.Save(strm, System.Drawing.Imaging.ImageFormat.Jpeg); ImageByteArray = strm.ToArray(); } string req4 = "insert into Material values('" + NomMtxt.selectedValue + "'," + nbMtxt.Text + ",'" + ImageByteArray + "'," + Id_C.ToString() + "," + prixMtxt.Text + ")"; dr2.Close(); ClassConnection.Excute(req4); ClassConnection.CloseCnx(); MessageBox.Show("la Commande effectuer", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch { MessageBox.Show("Problem d'ajouter la Commande", "Ereur", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void AddCommande_Load(object sender, EventArgs e) { string req = "SELECT * FROM Client ORDER BY IdClient DESC"; SqlDataReader dr = ClassConnection.FillDataReader(req); while (dr.Read()) { bunifuDropdown1.AddItem(dr["Prenom"] + " " + dr["Nom"]); //bunifuDropdown1.DropDownStyle = ComboBoxStyle.DropDownList; } dr.Close(); }
public RdvForm() { InitializeComponent(); req = "select * from RDV"; dr = ClassConnection.FillDataReader(req); while (dr.Read()) { DateTime d = (DateTime)dr[1]; monthCalendar1.AddBoldedDate(DateTime.Parse(d.ToString())); } dr.Close(); }
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 7) { DialogResult dialogResult = MessageBox.Show("Voulez-Vous Supprimé ce client !!", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dialogResult == DialogResult.Yes) { int row = e.RowIndex; int idc = (int)dataGridView1.Rows[e.RowIndex].Cells[0].Value; string req = "select Id_C from Commande where IdClient='" + idc + "'"; dr2 = ClassConnection.FillDataReader(req); if (dr2.Read()) { string req1 = "delete from RDV where Id_C='" + dr2["Id_C"] + "'"; string req2 = "delete from Plats where Id_C='" + dr2["Id_C"] + "'"; string req3 = "delete from Material where Id_C='" + dr2["Id_C"] + "'"; string req4 = "delete from Commande where Id_C='" + dr2["Id_C"] + "'"; string req5 = "delete from Client where IdClient='" + idc + "'"; dr2.Close(); ClassConnection.Excute(req1); ClassConnection.Excute(req2); ClassConnection.Excute(req3); ClassConnection.Excute(req4); ClassConnection.Excute(req5); dataGridView1.Rows.RemoveAt(e.RowIndex); MessageBox.Show("la Supprision effectué", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } if (e.ColumnIndex == 8) { DialogResult dialogResult = MessageBox.Show("Voulez-Vous Modifier ce client !!", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dialogResult == DialogResult.Yes) { int row = e.RowIndex; int idc = (int)dataGridView1.Rows[e.RowIndex].Cells[0].Value; string Prenom = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(); string Nom = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString(); string Adresse = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString(); int Tlf = (int)dataGridView1.Rows[e.RowIndex].Cells[4].Value; string Email = dataGridView1.Rows[e.RowIndex].Cells[5].Value.ToString(); string Type = dataGridView1.Rows[e.RowIndex].Cells[6].Value.ToString(); string req = "update client set Prenom='" + Prenom + "',Nom='" + Nom + "',Adresse='" + Adresse + "',telephone='" + Tlf + "', Email='" + Email + "' , TypeEvenement='" + Type + "'where IdClient=" + idc + ""; ClassConnection.Excute(req); MessageBox.Show("la Modification effectué", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); refresh(); } } }
private void Commande_Load(object sender, EventArgs e) { this.Height = 239; string req = "SELECT * FROM Client ORDER BY IdClient DESC"; SqlDataReader dr = ClassConnection.FillDataReader(req); while (dr.Read()) { bunifuDropdown1.AddItem(dr["Prenom"] + " " + dr["Nom"]); //bunifuDropdown1.DropDownStyle = ComboBoxStyle.DropDownList; } dr.Close(); bunifuImageButton1.Enabled = false; bunifuImageButton2.Enabled = false; }
private void bunifuFlatButton1_Click_2(object sender, EventArgs e) { string req5 = "SELECT Id_C from Commande where IdClient=" + Id_Client + ""; ClassConnection.OpenCnx(); SqlDataReader dr1 = ClassConnection.FillDataReader(req5); if (dr1.Read()) { Id_C = (int)dr1["Id_C"]; dr1.Close(); RDV r = new RDV(); r.Pass((int)Id_C); r.ShowDialog(); } }
private void bunifuImageButton8_Click(object sender, EventArgs e) { try { if (bunifuDropdown1.selectedIndex == -1 || Plattxt.selectedIndex == -1 || platnbtxt.Text == string.Empty || prixplattxt.Text == string.Empty) { MessageBox.Show("Tu doit Remlir tout les champs", "Ereur", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { string req3 = "SELECT Id_C from Commande where IdClient=" + Id_Client + ""; ClassConnection.OpenCnx(); SqlDataReader dr2 = ClassConnection.FillDataReader(req3); if (dr2.Read()) { Id_C = (int)dr2["Id_C"]; } dr2.Close(); if (strFilePath == "") { if (ImageByteArray.Length != 0) { ImageByteArray = new byte[] { } } ; } else { Image temp = new Bitmap(strFilePath); MemoryStream strm = new MemoryStream(); temp.Save(strm, System.Drawing.Imaging.ImageFormat.Jpeg); ImageByteArray = strm.ToArray(); } string req4 = "insert into Plats values('" + Plattxt.selectedValue + "'," + platnbtxt.Text + ",'" + ImageByteArray + "'," + Id_C.ToString() + "," + prixplattxt.Text + ")"; ClassConnection.Excute(req4); ClassConnection.CloseCnx(); MessageBox.Show("la Commande effectuer", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); dr2.Close(); } } catch { MessageBox.Show("Problem d'ajouter la Commande", "Ereur", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 5) { DialogResult dialogResult = MessageBox.Show("Voulez-Vous Supprimé ce type de Material !!", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dialogResult == DialogResult.Yes) { int row = e.RowIndex; string NomP = dataGridView2.Rows[e.RowIndex].Cells[0].Value.ToString(); string req1 = "delete from Material where Nom_Mt='" + NomP + "'"; ClassConnection.Excute(req1); dataGridView2.Rows.RemoveAt(e.RowIndex); MessageBox.Show("la Supprision effectué", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void bunifuFlatButton1_Click(object sender, EventArgs e) { try { if (Nomtxt.Text == string.Empty || prenomtxt.Text == string.Empty || adresstxt.Text == string.Empty || emailtxt.Text == string.Empty || eventtxt.Text == string.Empty) { label1.Visible = true; label2.Visible = true; label3.Visible = true; label4.Visible = true; label5.Visible = true; label5.Visible = true; label6.Visible = true; label1.Text = "* champs obligatoire"; label2.Text = "* champs obligatoire"; label3.Text = "* champs obligatoire"; label4.Text = "* champs obligatoire"; label5.Text = "* champs obligatoire"; label6.Text = "* champs obligatoire"; } else { label1.Visible = false; label2.Visible = false; label3.Visible = false; label4.Visible = false; label5.Visible = false; label6.Visible = false; string req1 = "INSERT INTO Client VALUES('" + Nomtxt.Text + "','" + prenomtxt.Text + "','" + adresstxt.Text + "'," + tlftxt.Text + ",'" + emailtxt.Text + "','" + eventtxt.Text + "')"; ClassConnection.Excute(req1); SuccessDialog s = new SuccessDialog(); s.ShowDialog(); } } catch { MessageBox.Show("Ereur d'ajouter le client", "Ereur", MessageBoxButtons.YesNo, MessageBoxIcon.Error); } }
private void bunifuFlatButton1_Click(object sender, EventArgs e) { if (radioButton1.Checked == true) { dataGridView1.ClearSelection(); string req = "SELECT * FROM Client where IdClient=" + textBox1.Text + ""; dr = ClassConnection.FillDataReader(req); if (dr.Read()) { idclient = (int)dr[0]; textBox2.Text = dr[1].ToString(); textBox3.Text = dr[2].ToString(); textBox4.Text = dr[4].ToString(); textBox5.Text = dr[5].ToString(); textBox6.Text = dr[3].ToString(); dr.Close(); int searchstring = idclient; foreach (DataGridViewRow r in dataGridView1.Rows) { foreach (DataGridViewCell c in r.Cells) { if (c.Value.ToString().Contains(searchstring.ToString())) { r.Selected = true; break; } } } } else { dr.Close(); MessageBox.Show("Client avec ce Id n'existe pas", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } if (radioButton2.Checked == true) { dataGridView1.ClearSelection(); string req = "SELECT * FROM Client where Nom='" + textBox1.Text + "'"; dr = ClassConnection.FillDataReader(req); if (dr.Read()) { NomC = dr[2].ToString(); textBox2.Text = dr[1].ToString(); textBox3.Text = dr[2].ToString(); textBox4.Text = dr[4].ToString(); textBox5.Text = dr[5].ToString(); textBox6.Text = dr[3].ToString(); dr.Close(); string searchstring = NomC; foreach (DataGridViewRow r in dataGridView1.Rows) { foreach (DataGridViewCell c in r.Cells) { if (c.Value.ToString().Contains(searchstring.ToString())) { r.Selected = true; break; } } } } else { dr.Close(); MessageBox.Show("Client avec ce Nom n'existe pas", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } if (radioButton3.Checked == true) { dataGridView1.ClearSelection(); string req = "SELECT * FROM Client where Prenom='" + textBox1.Text + "'"; dr = ClassConnection.FillDataReader(req); if (dr.Read()) { PrenomC = dr[1].ToString(); textBox2.Text = dr[1].ToString(); textBox3.Text = dr[2].ToString(); textBox4.Text = dr[4].ToString(); textBox5.Text = dr[5].ToString(); textBox6.Text = dr[3].ToString(); dr.Close(); string searchstring = PrenomC; foreach (DataGridViewRow r in dataGridView1.Rows) { foreach (DataGridViewCell c in r.Cells) { if (c.Value.ToString().Contains(searchstring.ToString())) { r.Selected = true; break; } } } } else { dr.Close(); MessageBox.Show("Client avec ce Prenom n'existe pas", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }