private void Button_Click_1(object sender, RoutedEventArgs e) { if (NomTextBox.Text == "" || PrenomTextBox.Text == "") { messageContent.Text = "Merci De Remplir Tous Les Champs"; animateBorder(borderMessage); } else { try { if (imageName != null) { FileStream fs = new FileStream(imageName, FileMode.Open, FileAccess.Read); byte[] imgByte = new byte[fs.Length]; fs.Read(imgByte, 0, Convert.ToInt32(fs.Length)); fs.Close(); cn.Open(); cmd.Connection = cn; cmd.CommandText = "update Clients set nom = '" + NomTextBox.Text.Replace("'", "''") + "', prenom ='" + PrenomTextBox.Text.Replace("'", "''") + "', Tel ='" + TelTextBox.Text.Replace("'", "''") + "', img = @img where IdClient = '" + id + "'"; cmd.Parameters.AddWithValue("img", imgByte); cmd.ExecuteNonQuery(); messageContent.Text = "Client Bien Modifié"; animateBorder(borderMessage); } else { cn.Open(); cmd.Connection = cn; cmd.CommandText = "update Clients set nom = '" + NomTextBox.Text.Replace("'", "''") + "', prenom ='" + PrenomTextBox.Text.Replace("'", "''") + "', Tel ='" + TelTextBox.Text.Replace("'", "''") + "' where IdClient = '" + id + "'"; cmd.ExecuteNonQuery(); messageContent.Text = "Client Bien Modifié"; animateBorder(borderMessage); } } catch (Exception ex) { string msg = ex.Message; MessageForm m = new MessageForm(msg); m.ShowDialog(); } finally { cn.Close(); dade.MainFrame.Navigate(new ClientsPage(dade, ConnectedSalle, ConnectedSport)); dade.Effect = null; dade.Opacity = 1; this.Close(); } } }
private void BtnModifier_Click(object sender, RoutedEventArgs e) { if (ListViewUtilisateurs.SelectedIndex == -1) { messageContent.Text = "Veuillez Selectioner Une Ligne"; animateBorder(borderMessage); } else { if (DepensesTextBox.Text == "" || DateTimePicker.Text == "" || PrixTextBox.Text == "") { messageContent.Text = "Merci De Remplir Tous Les Champs"; animateBorder(borderMessage); } else { try { int index = ListViewUtilisateurs.SelectedIndex; DataRowView row = ListViewUtilisateurs.Items.GetItemAt(index) as DataRowView; int id = int.Parse(row.Row[0].ToString()); cn.Open(); cmd.Connection = cn; cmd.Parameters.Clear(); cmd.CommandText = "update Depenses set Depense ='" + DepensesTextBox.Text.Replace("'", "''") + "', date_dep = @a, prix = @b where IdDep = '" + id + "'"; cmd.Parameters.AddWithValue("@a", DateTime.Parse(DateTimePicker.Text.ToString(), new System.Globalization.CultureInfo("fr"))); cmd.Parameters.AddWithValue("@b", double.Parse(PrixTextBox.Text)); cmd.ExecuteNonQuery(); messageContent.Text = "Bien Modifiée"; animateBorder(borderMessage); } catch (Exception ex) { string msg = ex.Message; MessageForm m = new MessageForm(msg); m.ShowDialog(); } finally { cn.Close(); BtnAjouter.Content = "Ajouter"; DepensesTextBox.Text = null; DateTimePicker.Text = null; PrixTextBox.Text = null; ListViewUtilisateurs.UnselectAll(); loaded(); } } } }
private void BtnModifier_Click(object sender, RoutedEventArgs e) { if (ListViewSports.SelectedIndex == -1) { messageContent.Text = "Veuillez Sélectionner Une Ligne"; animateBorder(borderMessage); } else { if (SportName.Text == "" || SportPrix.Text == "" || SallesComboBox.SelectedIndex == -1) { messageContent.Text = "Merci De Remplir Tous Les Champs"; animateBorder(borderMessage); } else { try { int index = ListViewSports.SelectedIndex; DataRowView row = ListViewSports.Items.GetItemAt(index) as DataRowView; int id = int.Parse(row.Row[0].ToString()); cn.Open(); cmd.Connection = cn; cmd.CommandText = "update Type_Sport set nom_Type = '" + SportName.Text.Replace("'", "''") + "' where IdType ='" + id + "'"; cmd.ExecuteNonQuery(); cmd.CommandText = "update SportSalle set IdSalle ='" + SallesComboBox.SelectedValue + "', prix ='" + double.Parse(SportPrix.Text) + "' where IdType ='" + id + "'"; cmd.ExecuteNonQuery(); cn.Close(); BtnAjouter.Content = "Ajouter"; SportName.Text = null; SportPrix.Text = null; SallesComboBox.SelectedIndex = -1; ListViewSports.UnselectAll(); loaded(); messageContent.Text = "Sport Bien Modifié"; animateBorder(borderMessage); } catch (Exception ex) { string msg = ex.Message; MessageForm m = new MessageForm(msg); m.ShowDialog(); } } } }
private void BtnAjouter_Click(object sender, RoutedEventArgs e) { if (BtnAjouter.Content.ToString() == "Nouveau") { BtnAjouter.Content = "Ajouter"; SportName.Text = null; SportPrix.Text = null; SallesComboBox.SelectedIndex = -1; ListViewSports.UnselectAll(); } else if (BtnAjouter.Content.ToString() == "Ajouter") { if (SportName.Text == "" || SportPrix.Text == "" || SallesComboBox.SelectedIndex == -1) { messageContent.Text = "Merci De Remplir Tous Les Champs"; animateBorder(borderMessage); } else { try { cn.Open(); cmd.Connection = cn; cmd.CommandText = "insert into Type_Sport values ('" + SportName.Text.Replace("'", "''") + "')"; cmd.ExecuteNonQuery(); cmd.CommandText = "select MAX(IdType) from Type_Sport"; int id = int.Parse(cmd.ExecuteScalar().ToString()); cmd.CommandText = "insert into SportSalle values ('" + SallesComboBox.SelectedValue + "','" + id + "','" + double.Parse(SportPrix.Text) + "')"; cmd.ExecuteNonQuery(); cn.Close(); loaded(); SportName.Text = null; SportPrix.Text = null; SallesComboBox.SelectedIndex = -1; messageContent.Text = "Sport Bien Ajouté"; animateBorder(borderMessage); } catch (Exception ex) { string msg = ex.Message; MessageForm m = new MessageForm(msg); m.ShowDialog(); } } } }
private void BtnAjouter_Click(object sender, RoutedEventArgs e) { if (BtnAjouter.Content.ToString() == "Nouveau") { BtnAjouter.Content = "Ajouter"; DepensesTextBox.Text = null; DateTimePicker.Text = null; PrixTextBox.Text = null; ListViewUtilisateurs.UnselectAll(); } else if (BtnAjouter.Content.ToString() == "Ajouter") { if (DepensesTextBox.Text == "" || DateTimePicker.Text == "" || PrixTextBox.Text == "") { messageContent.Text = "Merci De Remplir Tous Les Champs"; animateBorder(borderMessage); } else { try { cn.Open(); cmd.Connection = cn; cmd.Parameters.Clear(); cmd.CommandText = "insert into Depenses values ('" + DepensesTextBox.Text.Replace("'", "''") + "', @a ,'" + double.Parse(PrixTextBox.Text.Replace("'", "''")) + "','" + ConnectedSalle + "','" + ConnectedSport + "','" + iduser + "')"; cmd.Parameters.AddWithValue("@a", DateTime.Parse(DateTimePicker.Text.ToString(), new System.Globalization.CultureInfo("fr"))); cmd.ExecuteNonQuery(); messageContent.Text = "Bien Ajoutée"; animateBorder(borderMessage); } catch (Exception ex) { string msg = ex.Message; MessageForm m = new MessageForm(msg); m.ShowDialog(); } finally { cn.Close(); DepensesTextBox.Text = null; DateTimePicker.Text = null; PrixTextBox.Text = null; loaded(); } } } }
private void OnOffClientModalBtn_Click(object sender, RoutedEventArgs e) { if (ListClient.SelectedIndex != -1) { int index = ListClient.SelectedIndex; DataRowView row = ListClient.Items.GetItemAt(index) as DataRowView; int id = int.Parse(row.Row[0].ToString()); try { if (state.Text == "Activé") { icon.Foreground = new SolidColorBrush(Color.FromRgb(255, 52, 73)); state.Text = "Desactivé"; cn.Open(); cn = cmd.Connection; cmd.CommandText = "update Clients set Active = '" + false + "' where IdClient = '" + id + "'"; cmd.ExecuteNonQuery(); cn.Close(); messageContent.Text = "Client Désactivé"; animateBorder(borderMessage); } else if (state.Text == "Desactivé") { icon.Foreground = new SolidColorBrush(Color.FromRgb(52, 255, 72)); state.Text = "Activé"; cn.Open(); cn = cmd.Connection; cmd.CommandText = "update Clients set Active = '" + true + "' where IdClient = '" + id + "'"; cmd.ExecuteNonQuery(); cn.Close(); messageContent.Text = "Client Activé"; animateBorder(borderMessage); } } catch (Exception ex) { string msg = ex.Message; MessageForm m = new MessageForm(msg); m.ShowDialog(); } } }
public void connexion() { try { cn.Open(); cmd.Connection = cn; cmd.CommandText = "select * from Utilisateur u left join UtilisateurSportSalle us on u.IdUser=us.IdUser where u.UserName = '******'", "''") + "' and Password_User = '******'", "''") + "'"; dr = cmd.ExecuteReader(); if (dr.Read()) { string iduser = dr[0].ToString(); string nom = dr[1].ToString(); string prenom = dr[2].ToString(); string ConnectedSalle = dr[8].ToString(); string ConnectedSport = dr[9].ToString(); bool valid = (bool)dr[5]; MainApp app = new MainApp(nom, prenom, valid, ConnectedSalle, ConnectedSport, iduser); mw.Hide(); app.Show(); } else { messageContent.Text = "Nom D'Utilisateur Ou Mot De Passe Incorrect"; animateBorder(borderMessage); } dr.Close(); } catch (Exception ex) { string msg = ex.Message; MessageForm m = new MessageForm(msg); m.ShowDialog(); } finally { cn.Close(); } }
private void BtnAjouter_Click(object sender, RoutedEventArgs e) { if (BtnAjouter.Content.ToString() == "Nouveau") { BtnAjouter.Content = "Ajouter"; SalleName.Text = null; ListViewSalles.UnselectAll(); } else if (BtnAjouter.Content.ToString() == "Ajouter") { try { if (SalleName.Text == "") { messageContent.Text = "Merci De Remplir Tous Les Champs"; animateBorder(borderMessage); } else { cn.Open(); cmd.Connection = cn; cmd.CommandText = "insert into Salle values ('" + SalleName.Text.Replace("'", "''") + "')"; cmd.ExecuteNonQuery(); cn.Close(); messageContent.Text = "Salle Bien Ajoutée"; animateBorder(borderMessage); ListViewSalles.UnselectAll(); SalleName.Text = null; LoadResoource(); } } catch (Exception ex) { string msg = ex.Message; MessageForm m = new MessageForm(msg); m.ShowDialog(); } } }
public void changePass() { if (UsertextBox.Text == "" || OldPassTextBox.Password == "") { messageContent.Text = "Merci De Saisir Toutes Les Informations"; animateBorder(borderMessage); } else { try { cn.Open(); cmd.Connection = cn; cmd.CommandText = "select * from Utilisateur where UserName = '******'", "''") + "' and Password_User = '******'", "''") + "'"; dr = cmd.ExecuteReader(); if (dr.Read() && NewPassTextBox.Password == ConfirmNewPassTextBox.Password && NewPassTextBox.Password.Length >= 8) { dr.Close(); cmd.CommandText = "update Utilisateur set Password_User = '******'", "''") + "' where UserName ='******'", "''") + "'"; cmd.ExecuteNonQuery(); messageContent.Text = "Mot De Passe Bien Modifiée"; animateBorder(borderMessage); } else { messageContent.Text = "Merci De Confirmer Votre Mot De Passe"; animateBorder(borderMessage); } } catch (Exception ex) { string msg = ex.Message; MessageForm m = new MessageForm(msg); m.ShowDialog(); } finally { cn.Close(); } } }
private void Upload_Click(object sender, RoutedEventArgs e) { try { FileDialog fl = new OpenFileDialog(); fl.InitialDirectory = Environment.SpecialFolder.MyPictures.ToString(); if (fl.ShowDialog() == true) { imageName = fl.FileName; ImageSourceConverter isc = new ImageSourceConverter(); image.SetValue(Image.SourceProperty, isc.ConvertFromString(imageName)); } } catch (Exception ex) { string msg = ex.Message; MessageForm m = new MessageForm(msg); m.ShowDialog(); } }
private void AddBackImageBtn_Click(object sender, RoutedEventArgs e) { try { FileDialog fl = new OpenFileDialog(); fl.InitialDirectory = Environment.SpecialFolder.MyPictures.ToString(); if (fl.ShowDialog() == true) { imageName = fl.FileName; ImageSourceConverter isc = new ImageSourceConverter(); back.SetValue(Image.SourceProperty, isc.ConvertFromString(imageName)); if (imageName != null) { FileStream fs = new FileStream(imageName, FileMode.Open, FileAccess.Read); byte[] imgByte = new byte[fs.Length]; fs.Read(imgByte, 0, Convert.ToInt32(fs.Length)); fs.Close(); cn.Open(); cmd.Connection = cn; cmd.CommandText = "update Utilisateur set imaBack = @img where IdUser = '******'"; cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("img", imgByte); cmd.ExecuteNonQuery(); cn.Close(); } } } catch (Exception ex) { string msg = ex.Message; MessageForm m = new MessageForm(msg); m.ShowDialog(); } }
private void BtnAjouter_Click(object sender, RoutedEventArgs e) { if (BtnAjouter.Content.ToString() == "Nouveau") { BtnAjouter.Content = "Ajouter"; NomTextBox.Text = null; PrenomTextBox.Text = null; UserNameTextBox.Text = null; PassTextBox.Text = null; SportsComboBox.SelectedIndex = -1; ch1.IsChecked = false; ch2.IsChecked = false; ListViewUtilisateurs.UnselectAll(); } else if (BtnAjouter.Content.ToString() == "Ajouter") { if (NomTextBox.Text.Replace("'", "''") == "" || UserNameTextBox.Text.Replace("'", "''") == "" || PrenomTextBox.Text.Replace("'", "''") == "" || PassTextBox.Text.Replace("'", "''") == "" || SportsComboBox.SelectedIndex == -1 || ch1.IsChecked == false && ch2.IsChecked == false) { messageContent.Text = "Merci De Remplir Tous Les Champs"; animateBorder(borderMessage); } else { for (int i = 0; i < ds.Tables["users"].Rows.Count; i++) { if (ds.Tables["users"].Rows[i][3].ToString().ToLower() == UserNameTextBox.Text.ToLower()) { messageContent.Text = "Le Nom D'Utilisateur Existe Déja"; animateBorder(borderMessage); return; } } try { cn.Open(); cmd.Connection = cn; if (ch1.IsChecked == true) { cmd.CommandText = "insert into Utilisateur(Nom, Prenom, UserName, Password_User, Valide) values ('" + NomTextBox.Text.Replace("'", "''") + "','" + PrenomTextBox.Text.Replace("'", "''") + "','" + UserNameTextBox.Text.Replace("'", "''") + "','" + PassTextBox.Text.Replace("'", "''") + "','" + true + "')"; cmd.ExecuteNonQuery(); } else if (ch1.IsChecked == false) { cmd.CommandText = "insert into Utilisateur(Nom, Prenom, UserName, Password_User, Valide) values ('" + NomTextBox.Text.Replace("'", "''") + "','" + PrenomTextBox.Text.Replace("'", "''") + "','" + UserNameTextBox.Text.Replace("'", "''") + "','" + PassTextBox.Text.Replace("'", "''") + "','" + false + "')"; cmd.ExecuteNonQuery(); } cmd.CommandText = "select MAX(IdUser) from Utilisateur"; int IdUser = int.Parse(cmd.ExecuteScalar().ToString()); cmd.CommandText = "select IdSalle from SportSalle where IdType='" + SportsComboBox.SelectedValue + "'"; int IdSalle = int.Parse(cmd.ExecuteScalar().ToString()); cmd.CommandText = "insert into UtilisateurSportSalle values ('" + IdSalle + "','" + SportsComboBox.SelectedValue + "','" + IdUser + "')"; cmd.ExecuteNonQuery(); messageContent.Text = "Utilisateur Bien Ajouté"; animateBorder(borderMessage); } catch (Exception ex) { string msg = ex.Message; MessageForm m = new MessageForm(msg); m.ShowDialog(); } finally { cn.Close(); NomTextBox.Text = null; PrenomTextBox.Text = null; UserNameTextBox.Text = null; PassTextBox.Text = null; SportsComboBox.SelectedIndex = -1; ch1.IsChecked = false; ch2.IsChecked = false; loaded(); } } } }
private void BtnModifier_Click(object sender, RoutedEventArgs e) { if (ListViewUtilisateurs.SelectedIndex == -1) { messageContent.Text = "Veuillez Sélectionner Une Ligne"; animateBorder(borderMessage); } else { if (NomTextBox.Text == "" || UserNameTextBox.Text == "" || PrenomTextBox.Text == "" || PassTextBox.Text == "" || SportsComboBox.SelectedIndex == -1 || ch1.IsChecked == false && ch2.IsChecked == false) { messageContent.Text = "Merci De Remplir Tous Les Champs"; animateBorder(borderMessage); } else { for (int i = 0; i < ds.Tables["users"].Rows.Count; i++) { int index = ListViewUtilisateurs.SelectedIndex; DataRowView row = ListViewUtilisateurs.Items.GetItemAt(index) as DataRowView; string psd = row.Row[3].ToString().ToLower(); if (ds.Tables["users"].Rows[i][3].ToString().ToLower() == UserNameTextBox.Text.ToLower() && psd != UserNameTextBox.Text.ToLower()) { messageContent.Text = "Le Pseudo Existe Déja"; animateBorder(borderMessage); return; } } try { int index = ListViewUtilisateurs.SelectedIndex; DataRowView row = ListViewUtilisateurs.Items.GetItemAt(index) as DataRowView; int id = int.Parse(row.Row[0].ToString()); cn.Open(); cmd.Connection = cn; if (ch1.IsChecked == true) { cmd.CommandText = "update Utilisateur set Nom = '" + NomTextBox.Text.Replace("'", "''") + "' , Prenom = '" + PrenomTextBox.Text.Replace("'", "''") + "' , UserName = '******'", "''") + "',Password_User = '******'", "''") + "', Valide = '" + true + "' where IdUser = '******'"; cmd.ExecuteNonQuery(); } else { cmd.CommandText = "update Utilisateur set Nom = '" + NomTextBox.Text.Replace("'", "''") + "' , Prenom = '" + PrenomTextBox.Text.Replace("'", "''") + "' , UserName = '******'", "''") + "',Password_User = '******'", "''") + "', Valide = '" + false + "' where IdUser = '******'"; cmd.ExecuteNonQuery(); } cmd.CommandText = "select IdSalle from SportSalle where IdType='" + SportsComboBox.SelectedValue + "'"; int IdSalle = int.Parse(cmd.ExecuteScalar().ToString()); cmd.CommandText = "update UtilisateurSportSalle set IdSalle = '" + IdSalle + "', IdType = '" + SportsComboBox.SelectedValue + "' where IdUser = '******'"; cmd.ExecuteNonQuery(); messageContent.Text = "Utilisateur Bien Modifié"; animateBorder(borderMessage); } catch (Exception ex) { string msg = ex.Message; MessageForm m = new MessageForm(msg); m.ShowDialog(); } finally { cn.Close(); BtnAjouter.Content = "Ajouter"; NomTextBox.Text = null; PrenomTextBox.Text = null; UserNameTextBox.Text = null; PassTextBox.Text = null; SportsComboBox.SelectedIndex = -1; ch1.IsChecked = false; ch2.IsChecked = false; ListViewUtilisateurs.UnselectAll(); loaded(); } } } }
private void Button_Click(object sender, RoutedEventArgs e) { if (ajouter.Content.ToString() == "Nouveau") { ajouter.Content = "Ajouter"; NomTextBox.Text = null; PrixTextBox.Text = null; ListPayments.UnselectAll(); } else if (ajouter.Content.ToString() == "Ajouter") { if (PrixTextBox.Text == "" || NomTextBox.Text == "") { messageContent.Text = "Merci De Remplir tous Les Champs"; animateBorder(borderMessage); } else { try { if (ListPayments.SelectedIndex != -1) { DataRowView row1 = ListPayments.Items.GetItemAt(0) as DataRowView; date = DateTime.Parse(row1.Row[4].ToString(), new System.Globalization.CultureInfo("fr")); } cn.Open(); cmd.Connection = cn; cmd.Parameters.Clear(); cmd.CommandText = "insert into Payments values (@a,'" + id.ToString() + "','" + ConnectedSalle.ToString() + "','" + ConnectedSport.ToString() + "','" + double.Parse(PrixTextBox.Text) + "')"; cmd.Parameters.AddWithValue("@a", DateTime.Parse(NomTextBox.Text.ToString(), new System.Globalization.CultureInfo("fr"))); cmd.ExecuteNonQuery(); messageContent.Text = "Paiement Bien Ajoutée"; animateBorder(borderMessage); if (DateTime.Parse(NomTextBox.Text.ToString(), new System.Globalization.CultureInfo("fr")) > date) { cmd.Parameters.Clear(); cmd.CommandText = "update Clients set LastPay = @b where IdClient = '" + id.ToString() + "'"; cmd.Parameters.AddWithValue("@b", DateTime.Parse(NomTextBox.Text.ToString(), new System.Globalization.CultureInfo("fr"))); cmd.ExecuteNonQuery(); } } catch (Exception ex) { string msg = ex.Message; MessageForm m = new MessageForm(msg); m.ShowDialog(); } finally { cn.Close(); loaded(); NomTextBox.Text = null; PrixTextBox.Text = null; } } } }
private void Modifier_Click(object sender, RoutedEventArgs e) { if (ListPayments.SelectedIndex == -1) { messageContent.Text = "Veuillez Sélectionner Une Ligne"; animateBorder(borderMessage); } else { if (PrixTextBox.Text == "" || NomTextBox.Text == "") { messageContent.Text = "Merci De Remplir tous Les Champs"; animateBorder(borderMessage); } else { try { DataRowView row1 = ListPayments.Items.GetItemAt(0) as DataRowView; DateTime date = DateTime.Parse(row1.Row[4].ToString(), new System.Globalization.CultureInfo("fr")); int index = ListPayments.SelectedIndex; DataRowView row = ListPayments.Items.GetItemAt(index) as DataRowView; int idpay = int.Parse(row.Row[0].ToString()); cn.Open(); cmd.Connection = cn; cmd.Parameters.Clear(); cmd.CommandText = "update Payments set date_Payment =@a, Prix ='" + double.Parse(PrixTextBox.Text) + "' where IdPayment ='" + idpay + "'"; cmd.Parameters.AddWithValue("@a", DateTime.Parse(NomTextBox.Text.ToString(), new System.Globalization.CultureInfo("fr"))); cmd.ExecuteNonQuery(); messageContent.Text = "Paiement Bien Modifiée"; animateBorder(borderMessage); if (count == 1) { cmd.Parameters.Clear(); cmd.CommandText = "update Clients set LastPay = @b where IdClient = '" + id.ToString() + "'"; cmd.Parameters.AddWithValue("@b", DateTime.Parse(NomTextBox.Text.ToString(), new System.Globalization.CultureInfo("fr"))); cmd.ExecuteNonQuery(); } else if (DateTime.Parse(NomTextBox.Text.ToString(), new System.Globalization.CultureInfo("fr")) > date) { cmd.Parameters.Clear(); cmd.CommandText = "update Clients set LastPay = @c where IdClient = '" + id.ToString() + "'"; cmd.Parameters.AddWithValue("@c", DateTime.Parse(NomTextBox.Text.ToString(), new System.Globalization.CultureInfo("fr"))); cmd.ExecuteNonQuery(); } } catch (Exception ex) { string msg = ex.Message; MessageForm m = new MessageForm(msg); m.ShowDialog(); } finally { cn.Close(); ajouter.Content = "Ajouter"; NomTextBox.Text = null; PrixTextBox.Text = null; ListPayments.UnselectAll(); loaded(); } } } coutItems(); }
private void insertclient() { if (NomTextBox.Text == "" || PrenomTextBox.Text == "") { messageContent.Text = "Merci De Remplir Tous Les Champs"; animateBorder(borderMessage); } else { try { if (imageName != null) { FileStream fs = new FileStream(imageName, FileMode.Open, FileAccess.Read); byte[] imgByte = new byte[fs.Length]; fs.Read(imgByte, 0, Convert.ToInt32(fs.Length)); fs.Close(); cn.Open(); cmd.Connection = cn; cmd.CommandText = "insert into Clients(nom, prenom, Tel, img) values('" + NomTextBox.Text.Replace("'", "''") + "','" + PrenomTextBox.Text.Replace("'", "''") + "','" + TelTextBox.Text.Replace("'", "''") + "',@img)"; cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("img", imgByte); cmd.ExecuteNonQuery(); cmd.CommandText = "select MAX(IdClient) from Clients"; int id = int.Parse(cmd.ExecuteScalar().ToString()); cmd.CommandText = "insert into SportClients values ('" + id + "','" + ConnectedSalle + "','" + ConnectedSport + "')"; cmd.ExecuteNonQuery(); //string msg = "Client ajouté avec success"; //MessageForm m = new MessageForm(msg); //m.ShowDialog(); messageContent.Text = "Client Bien Ajouté"; animateBorder(borderMessage); } else { FileStream fs = new FileStream(System.IO.Path.Combine(Environment.CurrentDirectory, @"../../Resource/avatar.png"), FileMode.Open, FileAccess.Read); byte[] imgByte = new byte[fs.Length]; fs.Read(imgByte, 0, Convert.ToInt32(fs.Length)); fs.Close(); cn.Open(); cmd.Connection = cn; cmd.CommandText = "insert into Clients(nom, prenom, Tel, img) values('" + NomTextBox.Text.Replace("'", "''") + "','" + PrenomTextBox.Text.Replace("'", "''") + "','" + TelTextBox.Text.Replace("'", "''") + "',@img)"; cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("img", imgByte); cmd.ExecuteNonQuery(); cmd.CommandText = "select MAX(IdClient) from Clients"; int id = int.Parse(cmd.ExecuteScalar().ToString()); cmd.CommandText = "insert into SportClients values ('" + id + "','" + ConnectedSalle + "','" + ConnectedSport + "')"; cmd.ExecuteNonQuery(); //string msg = "Client ajouté avec success"; //MessageForm m = new MessageForm(msg); //m.ShowDialog(); messageContent.Text = "Client Bien Ajouté"; animateBorder(borderMessage); } } catch (Exception ex) { string msg = ex.Message; MessageForm m = new MessageForm(msg); m.ShowDialog(); } finally { cn.Close(); NomTextBox.Text = null; PrenomTextBox.Text = null; TelTextBox.Text = null; image.Source = new BitmapImage(new Uri("/Resource/avatar.png", UriKind.Relative)); dade.MainFrame.Navigate(new ClientsPage(dade, ConnectedSalle, ConnectedSport)); } } }