/// <summary> /// Chargement de la fenêtre de modification d'un client. /// </summary> /// <param name="b"></param> /// <param name="cli"></param> public Gestion_Fiche_Client(bool b, Clients cli) { InitializeComponent(); bIsUpdate = b; Commerciaux com = new Commerciaux(); com = CDAO.FindCom(cli.Commercial); if (cli.Type) { radioButton_Particulier.Checked = true; } else { radioButton_Entreprise.Checked = true; } textBox_ID.Text = Convert.ToString(cli.Id); textBox_Coeff.Text = Convert.ToString(Math.Round(cli.Coeff, 2)); textBox_NomCommercial.Text = com.Nom; textBox_PrenomCommercial.Text = com.Prenom; if (cli.Civilite == "M") radioButton_Monsieur.Checked = true; else radioButton_Madame.Checked = true; textBox_Nom.Text = cli.Nom; textBox_Prenom.Text = cli.Prenom; textBox_Societe.Text = cli.Entreprise; textBox_Adresse.Text = cli.Adresse; textBox_CP.Text = cli.Codepostal; textBox_Ville.Text = cli.Ville; textBox_Pays.Text = cli.Pays; textBox_Mail.Text = cli.Mail; textBox_Tel.Text = cli.Telephone1; textBox_Tel2.Text = cli.Telephone2; radioButton_Particulier_CheckedChanged(null, null); radioButton_Entreprise_CheckedChanged(null, null); a = b = c = d = E = f = g = h = i = j = true; }
/// <summary> /// Permet de retrouver le commercial associé au client. /// </summary> /// <param name="id"></param> /// <returns></returns> public Commerciaux FindCom(int id) { _connect.Open(); Commerciaux result = new Commerciaux(); SqlCommand requete = new SqlCommand("SELECT * FROM COMMERCIAUX WHERE com_id = @id", _connect); requete.Parameters.AddWithValue("@id", id); SqlDataReader lecture = requete.ExecuteReader(); while (lecture.Read()) { result.ID = Convert.ToInt32(lecture["com_id"].ToString()); result.Civilite = lecture["com_civilite"].ToString(); result.Nom = lecture["com_nom"].ToString(); result.Prenom = lecture["com_prenom"].ToString(); } _connect.Close(); return result; }