private void button1_Click(object sender, EventArgs e) { if (!Validation(groupBox1)) { MessageBox.Show("All data must be filled"); return; } try { dateTimePicker1.Format = DateTimePickerFormat.Custom; dateTimePicker1.CustomFormat = "yyyy"; string institution = textBox2.Text; string educationlevel = comboBox2.SelectedItem.ToString(); var major = textBox5.Text; var gradyear = dateTimePicker1.Value; var score = textBox7.Text; var employee = (Employee)comboBox1.SelectedValue; Models.EmployeeEducation ef = new Models.EmployeeEducation(employee.NIK, educationlevel, institution, major, Convert.ToDateTime(gradyear), Convert.ToInt32(score)); ef.AddEmployeeEducation(); LoadEducationData(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void LoadEducationData() { var ef = new Models.EmployeeEducation(); var employee = (Employee)comboBox1.SelectedValue; var q = ef.RetrieveEmployeeEducation(employee.NIK); dataGridView2.DataSource = q; dataGridView2.Columns["GraduationYear"].DefaultCellStyle.Format = "yyyy"; }
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 Models.EmployeeEducation(); em.DeleteEmployeeEducation(int.Parse(id)); LoadEducationData(); } }