private void btnXoa_Click(object sender, EventArgs e) { if (txtMaNhanVien.Text == frmSieuThi.nv.MaNhanVien + "") { MessageBox.Show("Thao tác thất bạt, không được xóa chính bạn", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Stop); } else { BULHoaDon bulHoaDon = new BULHoaDon(); if (bulHoaDon.coNhanVien(txtMaNhanVien.Text)) { MessageBox.Show("Có dữ liệu khác đang chứa nhân viên này", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Stop); } else { try { BULNhanVien bul = new BULNhanVien(); bul.xoaNhanVien(new NhanVien(int.Parse(txtMaNhanVien.Text))); frmST.hienDanhSachNhanVien(); MessageBox.Show("Xóa thành công", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } catch (Exception) { MessageBox.Show("Thao tác thất bạt, dữ liệu sai", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Stop); } } } }
private void btnSua_Click(object sender, EventArgs e) { try { BULTaiKhoan bultk = new BULTaiKhoan(); bultk.suaTaiKhoan(new TaiKhoan(txtTaiKhoan.Text, txtMatKhau.Text, cbQuyen.Text)); BULNhanVien bul = new BULNhanVien(); bul.suaNhanVien(new NhanVien(int.Parse(txtMaNhanVien.Text), txtTenNhanVien.Text, txtSoDienThoai.Text, txtChungMinhThu.Text, txtTaiKhoan.Text)); frmST.hienDanhSachNhanVien(); MessageBox.Show("Sửa thành công", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } catch (Exception) { MessageBox.Show("Thao tác thất bạt, dữ liệu sai", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }