public void LoadAddressData() { var ef = new Models.EmployeeAddress(); var employee = (Employee)comboBox1.SelectedValue; var q = ef.RetrieveEmployeeAddress(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 Models.EmployeeAddress(); em.DeleteEmployeeAddress(int.Parse(id)); LoadAddressData(); } }
private void EmployeeEntryAddressData_Load(object sender, EventArgs e) { var employee = new Employee(); var q = employee.RetrieveEmployees().Select(x => new { Display = x.nickname + " - " + x.NIK, Value = x }).ToList(); comboBox1.DisplayMember = "Display"; comboBox1.ValueMember = "Value"; comboBox1.DataSource = q; comboBox3.Items.Add("KTP"); comboBox3.Items.Add("Current"); var employeePhone = new Models.EmployeeAddress(); formReady = true; LoadEmployeeData(); LoadAddressData(); }
private void button1_Click(object sender, EventArgs e) { if (!Validation(groupBox1)) { MessageBox.Show("All data must be filled"); return; } try { string addressdetail = textBox1.Text; string addressType = comboBox3.SelectedItem.ToString(); var employee = (Employee)comboBox1.SelectedValue; Models.EmployeeAddress ef = new Models.EmployeeAddress(addressdetail, employee.NIK, addressType); ef.AddEmployeeAddress(); LoadAddressData(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }