Beispiel #1
0
        private void btEd_Click(object sender, EventArgs e)
        {
            if (dtgv.DataSource == null || row == -1)
            {
                return;
            }
            object        id = dtgv.Rows[row].Cells["Mã Nhân Viên"].Value;
            PeopleDTO     nv;
            PhongQuanLyBO bo = new PhongQuanLyBO();

            bo.GetNhanVienDTO(out nv, id);
            if (nv.ID != 0)
            {
                Form4 f4 = new Form4(true);
                f4.TranslationPeople(nv, listPhongBan, "Edit", false);
                f4.ShowDialog();
                txttrang2.Text = null;
                txttrang2.Text = txtTrang.Text;
            }
        }
Beispiel #2
0
        private void dtgv_DoubleClick(object sender, EventArgs e)
        {
            if (dtgv.DataSource == null || row == -1)
            {
                return;
            }
            if (string.Compare(dtgv.Name, "Remove") == 0)
            {
                return;
            }
            object        id = dtgv.Rows[row].Cells["Mã Nhân Viên"].Value;
            PeopleDTO     nv;
            PhongQuanLyBO bo = new PhongQuanLyBO();

            bo.GetNhanVienDTO(out nv, id);
            if (nv.ID != 0)
            {
                Form4 f4 = new Form4(false);
                f4.TranslationPeople(nv, listPhongBan, "Edit", false);
                f4.ShowDialog();
            }
        }
Beispiel #3
0
        /// <summary>
        /// Khi xóa nhân viên các trường hợp có thể xảy ra:
        /// Nếu là trưởng phòng thì chỉ có thể chỉnh sữa lại các thuộc tình
        /// Nếu . phải trưởng phòng thì xóa trực tiếp trong DB
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btDel_Click(object sender, EventArgs e)
        {
            if (dtgv.DataSource == null || row == -1 || dtgv.Rows[row].Cells["Mã Nhân Viên"].Value == null)
            {
                return;
            }
            PeoPleBO     nvbo = new PeoPleBO();
            int          idtp = nvbo.test(MaPB);
            int          id   = int.Parse(dtgv.Rows[row].Cells["Mã Nhân Viên"].Value.ToString());
            DialogResult result;

            if (id == idtp)
            {
                result = MessageBox.Show("Không thể xóa trưởng phong\n Bạn có muốn thay đổi trưởng phòng", "Remove", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    PeopleDTO     nv;
                    PhongQuanLyBO bo = new PhongQuanLyBO();
                    bo.GetNhanVienDTO(out nv, id);
                    bo.XoaThanNhan(id);
                    if (nv.ID != 0)
                    {
                        nv.FName    = "";
                        nv.LName    = "";
                        nv.DOB      = new DateTime();
                        nv.HD       = new DateTime();
                        nv.GioiTinh = "";
                        nv.QueQuan  = "";
                        Form4 f4 = new Form4(true);
                        f4.TranslationPeople(nv, listPhongBan, "Edit", false);
                        f4.ShowDialog();
                        txttrang2.Text = null;
                        txttrang2.Text = txtTrang.Text;
                    }
                }
                return;
            }
            result = MessageBox.Show("Bạn có thực sự muốn xóa", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (result == DialogResult.Yes)
            {
                PhongQuanLyBO qlbo = new PhongQuanLyBO();
                //Lưu vào DB temp
                qlbo.SaveTemp(id);
                //Tiến hành xóa

                int kq = qlbo.XoaThanNhan(id);
                kq = qlbo.XoaNVKTKL(id);
                kq = qlbo.XoaNhanVien(id);

                if (kq != -1)
                {
                    MessageBox.Show("Xóa thành công", "Xóa");
                    row--;
                    txttrang2.Text = null;
                    txttrang2.Text = txtTrang.Text;
                }
                else
                {
                    MessageBox.Show("Thất bại", "Xóa");
                }
            }
        }