private void button1_Click(object sender, EventArgs e) { if (!Validation(groupBox1)) { MessageBox.Show("All data must be filled"); return; } try { string name = textBox1.Text; string gender = comboBox2.SelectedItem.ToString()[0].ToString(); var dob = dateTimePicker1.Value; var relationship = comboBox3.SelectedValue as EmployeeRelationship; var employee = (Employee)comboBox1.SelectedValue; EmployeeFamily ef = new EmployeeFamily(0, name, gender, dob, relationship.Id, employee.NIK); ef.AddEmployeeFamily(); LoadFamilyData(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void LoadFamilyData() { var ef = new EmployeeFamily(); var employee = (Employee)comboBox1.SelectedValue; var q = ef.RetrieveEmployeeFamily(employee.NIK); dataGridView2.DataSource = q; }
private void button2_Click(object sender, EventArgs e) { if (dataGridView2.CurrentRow == null) { MessageBox.Show("Please choose the data in the datagridview first"); return; } var msg = MessageBox.Show("Are you sure to delete this data ?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (msg == DialogResult.Yes) { var id = dataGridView2.CurrentRow.Cells["Id"].Value.ToString(); var em = new EmployeeFamily(); em.DeleteEmployeeFamily(int.Parse(id)); LoadFamilyData(); } }