Exemplo n.º 1
0
        //
        //
        private void btn_QuanLyPhong_Click(object sender, EventArgs e)
        {
            panelQuanLyChung.Visible  = false;
            panelTraCuu.Visible       = false;
            panelThongKe.Visible      = false;
            panelChoThuePhong.Visible = false;
            panelQuanLyPhong.Visible  = true;
            List <LoaiPhongDTO> dsLoaiPhong = PhongBUS.LayDSLoaiPhong();

            foreach (LoaiPhongDTO loaiPhong in dsLoaiPhong)
            {
                cb_MaLoaiPhong.Items.Add(loaiPhong.MaLoaiPhong.ToString());
            }
            cb_MaLoaiPhong.SelectedIndex = 0;
            cb_TinhTrangPhong.Items.Add("Trống");
            cb_TinhTrangPhong.Items.Add("Có người");
            cb_TinhTrangPhong.SelectedIndex = 0;

            foreach (LoaiPhongDTO loaiPhong in dsLoaiPhong)
            {
                cbSua_MaLoaiPhong.Items.Add(loaiPhong.MaLoaiPhong.ToString());
            }
            cbSua_MaLoaiPhong.SelectedIndex = 0;
            cbSua_TinhTrangPhong.Items.Add("Trống");
            cbSua_TinhTrangPhong.Items.Add("Có người");
            cbSua_TinhTrangPhong.SelectedIndex = 0;

            dgv_DSPhong.DataSource = PhongBUS.LayDSPhong();
        }
Exemplo n.º 2
0
        private void btnDoanhThu_ThongKe_Click(object sender, EventArgs e)
        {
            if (cbDoanhThu_Thang.Text != "")
            {
                int             thang = int.Parse(cbDoanhThu_Thang.Text.Trim());
                List <PhongDTO> dsphg = new List <PhongDTO>();
                dsphg = PhongBUS.LayDSPhong();

                int[] arrDoanhThu = new int[dsphg.Count];

                arrDoanhThu = PhongBUS.LapBaoCaoDoanhThu(thang);
                int dt = 0;
                for (int i = 0; i < arrDoanhThu.Length; ++i)
                {
                    dt += arrDoanhThu[i];
                }
                tbDoanhThu.Text = dt.ToString("00.00");
                List <int> dstb = new List <int>();
                dstb = PhongBUS.layDSTBThang(thang);
                dgvDoanhThu.Rows.Clear();
                for (int i = 0; i < dsphg.Count; i++)
                {
                    dgvDoanhThu.Rows.Add(i + 1, dsphg[i].MaPhong, arrDoanhThu[i], dstb[i]);
                }
            }
            else
            {
                MessageBox.Show("Bạn chưa chọn tháng", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 3
0
 //
 // Màn hình Thêm phòng mới
 //
 private void btn_Them_Click(object sender, EventArgs e)
 {
     if (tb_MaPhong.TextLength > 0)
     {
         String   maPhong = tb_MaPhong.Text;
         PhongDTO phong   = PhongBUS.LayPhong(maPhong);
         if (phong.GhiChu.Equals("Phong khong ton tai"))
         {
             try
             {
                 PhongBUS.NhapPhong(maPhong, tb_TenPhong.Text, Int32.Parse(cb_MaLoaiPhong.SelectedItem.ToString()), tb_GhiChu.Text, cb_TinhTrangPhong.SelectedItem.ToString());
                 MessageBox.Show("Thêm phòng thành công.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 dgv_DSPhong.DataSource = PhongBUS.LayDSPhong();
             }
             catch (Exception ex)
             {
                 MessageBox.Show("Thêm phòng thất bại.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else
         {
             MessageBox.Show("Mã phòng đã tồn tại\nVui lòng nhập mã phòng khác.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("Bạn chưa nhập mã phòng", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 4
0
        private void btnMatDoSuDung_ThongKe_Click(object sender, EventArgs e)
        {
            if (cbMatDoSuDung_Thang.Text != "")
            {
                List <PhongDTO> dsphg = new List <PhongDTO>();
                dsphg = PhongBUS.LayDSPhong();
                int[] arrNgayThue = new int[dsphg.Count];
                arrNgayThue = PhongBUS.LapBaoCaoMatDo(Int32.Parse(cbMatDoSuDung_Thang.Text));

                int tong = 0;
                for (int i = 0; i < dsphg.Count; i++)
                {
                    tong += arrNgayThue[i];
                }

                dgv_MatDoSudung.Rows.Clear();
                for (int i = 0; i < dsphg.Count; i++)
                {
                    dgv_MatDoSudung.Rows.Add(i + 1, dsphg[i].MaPhong, arrNgayThue[i],
                                             (Convert.ToDouble(arrNgayThue[i]) * 100 / Convert.ToDouble(tong)).ToString("00.00") + "%");
                }
            }
            else
            {
                MessageBox.Show("Bạn chưa chọn tháng", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 5
0
        private void btnSua_Xoa_Click(object sender, EventArgs e)
        {
            string MP = tbSua_MaPhong.Text.Trim();

            if ((MP == "") || (string.Compare(MP, "000", true) < 0))
            {
                MessageBox.Show("Vui lòng nhập mã số phòng muốn xóa", "Thong bao", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                PhongDTO phg = new PhongDTO();
                phg = PhongBUS.LayPhong(MP);
                if (phg.MaPhong == null)
                {
                    MessageBox.Show(phg.GhiChu);
                }
                else if (string.Compare(phg.TinhTrang, "Có người", true) == 0)
                {
                    MessageBox.Show("Phòng đang cho thuê,\nkhông thể xóa", "Thong bao", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    PhongBUS.XoaPhong(MP);
                    MessageBox.Show("Xóa thành công!", "Thong bao", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    dgvSua_DSPhong.DataSource = PhongBUS.LayDSPhong();
                    tb_MaPhong.Text           = tb_SoLuongKhach.Text = tb_GhiChu.Text = tb_TenPhong.Text = "";
                }
            }
        }
Exemplo n.º 6
0
        private void btn_ChoThuePhong_Click(object sender, EventArgs e)
        {
            panelQuanLyChung.Visible  = false;
            panelTraCuu.Visible       = false;
            panelThongKe.Visible      = false;
            panelQuanLyPhong.Visible  = false;
            panelChoThuePhong.Visible = true;
            List <PhongDTO> dsPhong      = PhongBUS.LayDSPhong();
            List <PhongDTO> dsPhongTrong = new List <PhongDTO>();

            foreach (PhongDTO phg in dsPhong)
            {
                if (phg.TinhTrang.Equals("Trống"))
                {
                    dsPhongTrong.Add(phg);
                }
            }
            dgvChonPhong_DSPhongTrong.DataSource = dsPhongTrong;
        }
Exemplo n.º 7
0
        //
        // Màn hình Cập nhật phòng
        //
        private void btnSua_CapNhat_Click(object sender, EventArgs e)
        {
            string   maPhong = dgvSua_DSPhong.SelectedRows[0].Cells[0].Value.ToString();
            PhongDTO phg     = new PhongDTO();

            if (tbSua_MaPhong.TextLength > 0 && tbSua_TenPhong.TextLength > 0 && tbSua_GhiChu.TextLength > 0)
            {
                //Lấy các thông tin đã sửa từ các textbox và combobox
                string TP = tbSua_TenPhong.Text.Trim();
                int    LP = int.Parse(cb_MaLoaiPhong.Text.Trim());
                string GC = tbSua_GhiChu.Text.Trim();
                string TT = cbSua_TinhTrangPhong.Text.Trim();
                int    SL;
                if (tbSuaSoLuongKhach.Text.Trim() == "")
                {
                    SL = 0;
                }
                else
                {
                    SL = int.Parse(tbSuaSoLuongKhach.Text.Trim());
                }

                phg = PhongBUS.LayPhong(maPhong);
                if (phg.MaPhong == null)
                {
                    MessageBox.Show(phg.GhiChu, "Thong bao", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                }
                else
                {
                    PhongBUS.CapNhat(maPhong, TP, LP, GC, TT, SL);
                    MessageBox.Show("Cập nhật phòng thành công", "Thong bao", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    tb_MaPhong.Text           = tb_SoLuongKhach.Text = tb_GhiChu.Text = tb_TenPhong.Text = "";
                    tbSua_MaPhong.ReadOnly    = false;
                    dgvSua_DSPhong.DataSource = PhongBUS.LayDSPhong();
                }
            }
            else
            {
                MessageBox.Show("Vui lòng click chọn bảng bên dưới để sửa\nVui lòng điền đầy đủ thông tin", "Thong bao", MessageBoxButtons.OK, MessageBoxIcon.Information);
                tbSua_MaPhong.ReadOnly = false;
            }
        }
Exemplo n.º 8
0
 private void tabPage_CapNhatPhong_Enter(object sender, EventArgs e)
 {
     dgvSua_DSPhong.DataSource = PhongBUS.LayDSPhong();
 }