public GestionClient(int Id) { InitializeComponent(); Client_Controller client = Client_Model.ExistingClients.Find(c => c.IdProperty == Id); this.Title = Id.ToString(); Nom.Text = client.NomProperty; Prenom.Text = client.PrenomProperty; Adresse.Text = client.AdresseProperty; Telephone.Text = client.TelephoneProperty; Points.Text = client.PointsProperty.ToString(); }
private void AddNewClient(object sender, RoutedEventArgs e) { if (System.Windows.Forms.MessageBox.Show("Confirmer l'enregistrement de ce client ?", "Attention", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes) { Client_Controller client = new Client_Controller(Client_Model.ExistingClients.Count, Nom.Text, Prenom.Text, Adresse.Text, Telephone.Text, Mail.Text, 0); Client_Model.AddNewClient(client); MainWindow m = new MainWindow(); m.Activate(); m.Show(); this.Close(); } }
private void DeleteClient(object sender, RoutedEventArgs e) { if (System.Windows.Forms.MessageBox.Show("Confirmer la suppression de ce client ?", "Attention", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes) { Client_Controller.DeleteClient(Convert.ToInt32(this.Title)); MainWindow m = new MainWindow(); m.Activate(); m.Show(); this.Close(); } }
public static void AddNewClient(Client_Controller client) { using (MySqlConnection c = BddSQL.InitConnexion()) { MySqlCommand command = c.CreateCommand(); command.CommandText = "INSERT INTO clients (idclient, nom, prenom, adresse, telephone, mail) " + "VALUES (NULL, @nom, @prenom, @adresse, @telephone, @mail)"; command.Parameters.AddWithValue("@nom", client.NomProperty); command.Parameters.AddWithValue("@prenom", client.PrenomProperty); command.Parameters.AddWithValue("@adresse", client.AdresseProperty); command.Parameters.AddWithValue("@telephone", client.TelephoneProperty); command.Parameters.AddWithValue("@mail", client.MailProperty); command.ExecuteNonQuery(); } }