private void btnEditStaff_Click(object sender, EventArgs e) { if (grid.RowCount > 0) { DataRow row = grid.GetDataRow(grid.GetSelectedRows()[0]); EditStaff.oldInfo = row; EditStaff edit = new EditStaff(); edit.ShowDialog(); dgvListStaff.DataSource = Staff_BUS.ListStaff(); } else { MessageBox.Show("Error!", "My Application", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } }
private void btnEdit_Click(object sender, EventArgs e) { Staff_DTO staff = new Staff_DTO( idStaff.Text.ToString(), fName.Text.ToString(), lName.Text.ToString(), birthday.Text.ToString(), sex.Text.ToString(), placeOfBirth.Text.ToString(), address.Text.ToString(), iNumber.Text.ToString(), email.Text.ToString(), position.Text.ToString(), pNumber.Text.ToString()); Staff_BUS.EditStaff(staff); this.Close(); }
private void btnDeleteStaff_Click(object sender, EventArgs e) { if (grid.RowCount > 0) { DataRow row = grid.GetDataRow(grid.GetSelectedRows()[0]); DialogResult dialogResult = MessageBox.Show("Are you sure?", "Delete staff", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { Staff_BUS.DeleteStaff(row["IDStaff"].ToString()); MessageBox.Show("Staff was deleted", "My Application", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } dgvListStaff.DataSource = Staff_BUS.ListStaff(); } else { MessageBox.Show("Error!", "My Application", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } }
private void btnAdd_Click(object sender, EventArgs e) { string id = idStaff.Text; string firstname = fName.Text; string lastname = lName.Text; string birthday1 = birthday.Text; string sex1 = sex.Text; string pOB = placeOfBirth.Text; string add = address.Text; string identityNumber = iNumber.Text; string email1 = email.Text; string pos = position.Text; string phoneNumber = pNumber.Text; Staff_DTO staff = new Staff_DTO(id, firstname, lastname, birthday1, sex1, pOB, add, identityNumber, email1, pos, phoneNumber); Staff_BUS.AddStaff(staff); MessageBox.Show("Complete!", "Add staff", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.Close(); }
private void btnSearchStaff_Click(object sender, EventArgs e) { switch (typeSearchStaff) { case 1: { dgvListStaff.DataSource = Staff_BUS.FindStaffById(keySearchStaff.Text.ToString()); break; } case 2: { dgvListStaff.DataSource = Staff_BUS.FindStaffByName(keySearchStaff.Text.ToString()); break; } default: { MessageBox.Show("Error!", "Search staff", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); break; } } }
private void btnUpdate_Click(object sender, EventArgs e) { dgvListStaff.DataSource = Staff_BUS.ListStaff(); }
private void ListStaff_Load(object sender, EventArgs e) { dgvListStaff.DataSource = Staff_BUS.ListStaff(); }