Ejemplo n.º 1
0
        private void mniThemLoaiPhong_Click(object sender, EventArgs e)
        {
            FormLoaiPhong.state = 0;
            FormLoaiPhong frm = new FormLoaiPhong();

            frm.ShowDialog();
        }
Ejemplo n.º 2
0
 private void btnThem_LP_Click(object sender, EventArgs e)
 {
     try
     {
         if (cboTenChuPhong.Items.Count > 0)
         {
             FormLoaiPhong.state = 0;
             FormLoaiPhong.MaChu = Convert.ToInt32(cboTenChuPhong.SelectedValue);
             FormLoaiPhong frm = new FormLoaiPhong();
             frm.ShowDialog();
             dgvLoaiPhong.DataSource = balLP.GetAllByMaChu(Convert.ToInt32(cboTenChuPhong.SelectedValue));
             cboLoaiPhong.DataSource = balLP.GetAll();
         }
     }catch (Exception ex) { MessageBox.Show("Lỗi: \n" + ex.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); }
 }
Ejemplo n.º 3
0
 private void dgvLoaiPhong_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dgvLoaiPhong.Columns[e.ColumnIndex].Name == "xem_LP" && e.RowIndex > -1)//Xem
     {
         FormLoaiPhong.state  = 1;
         FormLoaiPhong.MaLoai = Convert.ToInt32(dgvLoaiPhong.Rows[e.RowIndex].Cells["maloaiphong_LP"].Value);
         FormLoaiPhong.MaChu  = Convert.ToInt32(dgvLoaiPhong.Rows[e.RowIndex].Cells["machuphong_LP"].Value);
         FormLoaiPhong frm = new FormLoaiPhong();
         frm.ShowDialog();
         dgvLoaiPhong.DataSource = balLP.GetAllByMaChu(Convert.ToInt32(cboTenChuPhong.SelectedValue));
     }
     else if (dgvLoaiPhong.Columns[e.ColumnIndex].Name == "sua_LP" && e.RowIndex > -1)//sửa
     {
         FormLoaiPhong.state  = -1;
         FormLoaiPhong.MaLoai = Convert.ToInt32(dgvLoaiPhong.Rows[e.RowIndex].Cells["maloaiphong_LP"].Value);
         FormLoaiPhong.MaChu  = Convert.ToInt32(dgvLoaiPhong.Rows[e.RowIndex].Cells["machuphong_LP"].Value);
         FormLoaiPhong frm = new FormLoaiPhong();
         frm.ShowDialog();
         dgvLoaiPhong.DataSource = balLP.GetAllByMaChu(Convert.ToInt32(cboTenChuPhong.SelectedValue));
     }
     else if (dgvLoaiPhong.Columns[e.ColumnIndex].Name == "xoa_LP" && 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
             {
                 balLP.XoaLoaiPhong(Convert.ToInt32(dgvLoaiPhong.Rows[e.RowIndex].Cells["maloaiphong_LP"].Value));
                 MessageBox.Show("Xóa dữ liệu thành công.", "Thông báo");
                 dgvLoaiPhong.DataSource = balLP.GetAllByMaChu(Convert.ToInt32(cboTenChuPhong.SelectedValue));
                 cboLoaiPhong.DataSource = balLP.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); }
         }
     }
 }