private void bindingSourceEmp_CurrentItemChanged(object sender, EventArgs e) { if (bindingSourceEmp.Current != null) { _RecordedEmploye = (BO_Employe)bindingSourceEmp.Current; textBox1.Text = _RecordedDept.Dname; textBox2.Text = _RecordedEmploye.Nom; textBox3.Text = _RecordedEmploye.Job; textBox4.Text = _RecordedEmploye.Salaire.ToString(); textBox2.Enabled = true; buttonUpdateEmp.Enabled = true; } else { _RecordedEmploye = null; textBox1.Text = string.Empty; textBox2.Text = string.Empty; textBox3.Text = string.Empty; textBox4.Text = string.Empty; textBox2.Enabled = false; buttonUpdateEmp.Enabled = false; if (bindingSourceDept.Current != null) { textBox1.Text = _RecordedDept.Dname; } } }
public Form1() { InitializeComponent(); label4.Text = string.Empty; _RecordedDept = new BO_Departement(); _RecordedEmploye = new BO_Employe(); this.FillingComboBox(); if (bindingSourceDept.Current != null) { _RecordedDept = (BO_Departement)bindingSourceDept.Current; } this.FillingDataGridView(_RecordedDept.Deptno); }
public static int UpdateEmp(BO_Employe newEmploye) { int retour = 0; RestRequest request = new RestRequest("UpdateEmp", Method.POST); request.RequestFormat = DataFormat.Json; request.AddBody(newEmploye); IRestResponse <int> response = Client.Execute <int>(request); if (response.ResponseStatus == ResponseStatus.Completed) { retour = response.Data; } return(retour); }
private void buttonUpdateEmp_Click(object sender, EventArgs e) { if (bindingSourceEmp.Current != null) { _RecordedEmploye = (BO_Employe)bindingSourceEmp.Current; string oldName = _RecordedEmploye.Nom; string newName = textBox2.Text.ToUpper(); int resultat = 0; _RecordedEmploye.Nom = newName; string message = $"{oldName} => {newName}"; DialogResult dialogResult = MessageBox.Show(message, "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2); if (dialogResult == DialogResult.Yes) { resultat = BLL_OAI.UpdateEmp(_RecordedEmploye); } if (resultat != 0) { this.FillingDataGridView(_RecordedDept.Deptno); } } }