Esempio n. 1
0
 private void dgvChuPhong_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dgvChuPhong.Columns[e.ColumnIndex].Name == "xem_CP" && e.RowIndex > -1)//Xem
     {
         FormChuPhong.state      = 1;
         FormChuPhong.MaChuPhong = Convert.ToInt32(dgvChuPhong.Rows[e.RowIndex].Cells["machuphong_CP"].Value);
         FormChuPhong frm = new FormChuPhong();
         frm.ShowDialog();
         dgvChuPhong.DataSource = balCP.GetAll();
     }
     else if (dgvChuPhong.Columns[e.ColumnIndex].Name == "sua_CP" && e.RowIndex > -1)//Sửa
     {
         FormChuPhong.state      = -1;
         FormChuPhong.MaChuPhong = Convert.ToInt32(dgvChuPhong.Rows[e.RowIndex].Cells["machuphong_CP"].Value);
         FormChuPhong frm = new FormChuPhong();
         frm.ShowDialog();
         dgvChuPhong.DataSource = balCP.GetAll();
     }
     else if (dgvChuPhong.Columns[e.ColumnIndex].Name == "xoa_CP" && e.RowIndex > -1)//Xóa
     {
         if (DialogResult.Yes == MessageBox.Show("Bạn muốn xóa dữ liệu trên?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
         {
             try
             {
                 balCP.XoaChuphong(Convert.ToInt32(dgvChuPhong.Rows[e.RowIndex].Cells["machuphong_CP"].Value));
                 MessageBox.Show("Xóa dữ liệu thành công.", "Thông báo");
                 dgvChuPhong.DataSource = balCP.GetAll();
             }
             catch (Exception ex)
             {
                 MessageBox.Show("Xóa dữ liệu thất bại.\n" + ex.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
Esempio n. 2
0
        private void mniThemChuPhong_Click(object sender, EventArgs e)
        {
            FormChuPhong.state = 0;
            FormChuPhong frm = new FormChuPhong();

            frm.ShowDialog();
        }
Esempio n. 3
0
        private void btnThem_CP_Click(object sender, EventArgs e)
        {
            FormChuPhong.state = 0;
            FormChuPhong frm = new FormChuPhong();

            frm.ShowDialog();
            dgvChuPhong.DataSource = balCP.GetAll();
        }