private void mniThemPhong_Click(object sender, EventArgs e)
        {
            FormPhong.state = 0;
            FormPhong frm = new FormPhong();

            frm.ShowDialog();
        }
Example #2
0
 private void btnThem_P_Click(object sender, EventArgs e)
 {
     if (dgvLoaiPhong.RowCount > 0)
     {
         FormPhong.state  = 0;
         FormPhong.MaLoai = Convert.ToInt32(cboLoaiPhong.SelectedValue);
         FormPhong frm = new FormPhong();
         frm.ShowDialog();
         dgvPhong.DataSource = balP.GetAllByMaLoai(Convert.ToInt32(dgvLoaiPhong.CurrentRow.Cells["maloaiphong_LP"].Value));
     }
 }
Example #3
0
 private void dgvPhong_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dgvPhong.Columns[e.ColumnIndex].Name == "quanly" && e.RowIndex > -1)//Quản lý thuê phòng
     {
         FormHopDongCuaPhong.MaPhong = Convert.ToInt32(dgvPhong.Rows[e.RowIndex].Cells["maphong"].Value);
         FormHopDongCuaPhong frm = new FormHopDongCuaPhong();
         frm.ShowDialog();
     }
     else if (dgvPhong.Columns[e.ColumnIndex].Name == "chisothang" && e.RowIndex > -1)//Số điện - nước
     {
         FormChiSoThang_Detail.MaPhongCST = Convert.ToInt32(dgvPhong.Rows[e.RowIndex].Cells["maphong"].Value);
         FormChiSoThang_Detail frm = new FormChiSoThang_Detail();
         frm.ShowDialog();
     }
     else if (dgvPhong.Columns[e.ColumnIndex].Name == "xem_P" && e.RowIndex > -1)//Xem
     {
         FormPhong.state   = 1;
         FormPhong.MaPhong = Convert.ToInt32(dgvPhong.Rows[e.RowIndex].Cells["maphong"].Value);
         FormPhong.MaLoai  = Convert.ToInt32(dgvPhong.Rows[e.RowIndex].Cells["maloaiphong_P"].Value);
         FormPhong frm = new FormPhong();
         frm.ShowDialog();
     }
     else if (dgvPhong.Columns[e.ColumnIndex].Name == "sua_P" && e.RowIndex > -1)//sửa
     {
         FormPhong.state   = -1;
         FormPhong.MaPhong = Convert.ToInt32(dgvPhong.Rows[e.RowIndex].Cells["maphong"].Value);
         FormPhong.MaLoai  = Convert.ToInt32(dgvPhong.Rows[e.RowIndex].Cells["maloaiphong_P"].Value);
         FormPhong frm = new FormPhong();
         frm.ShowDialog();
         dgvPhong.DataSource = balP.GetAllByMaLoai(Convert.ToInt32(cboLoaiPhong.SelectedValue));
     }
     else if (dgvPhong.Columns[e.ColumnIndex].Name == "xoa_P" && 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
             {
                 balP.XoaPhong(Convert.ToInt32(dgvPhong.Rows[e.RowIndex].Cells["maphong"].Value));
                 MessageBox.Show("Xóa dữ liệu thành công.", "Thông báo");
                 dgvPhong.DataSource = balP.GetAllByMaLoai(Convert.ToInt32(cboLoaiPhong.SelectedValue));
             }
             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); }
         }
     }
 }