示例#1
0
        public TraPhong(int maPhong)
        {
            InitializeComponent();



            MaPhong         = maPhong;
            txtMaPhong.Text = maPhong.ToString();
            Phong     p  = PhongDAO.LoadOne(maPhong);
            LoaiPhong lp = LoaiPhongDAO.LoadOne(p.LoaiPhong);

            txtLoaiPhong.Text = lp.TenLoai;

            DataTable thuePhongDTO = ThuePhongDAO.LoadByMaPhong(maPhong);
            DateTime  dNgayThue    = thuePhongDTO.Rows[0].Field <DateTime>("NgayBatDauThue");
            DateTime  dNgayTra     = DateTime.Now;

            txtNgayThue.Text = dNgayThue.ToString("MM-dd-yyyy HH:mm");
            txtNgayTra.Text  = dNgayTra.ToString("MM-dd-yyyy HH:mm");

            dataGridDsKhach.ItemsSource = ThuePhongDAO.LoadThongTinKhach(maPhong).DefaultView;

            DataTable dtGioHang = LoadDsDichVu();

            dgGioHang.ItemsSource = dtGioHang.DefaultView;

            float donGiaPhong = LoaiPhongDAO.GetDonGiaPhong(txtLoaiPhong.Text);
            float tienPhong   = 0;
            float tienDichVu  = TinhTongTien(dtGioHang);
            int   dayDateDiff = (dNgayTra - dNgayThue).Days;

            if (dayDateDiff < 1)
            {
                int hourDiff = dNgayTra.Hour - dNgayThue.Hour;
                if (hourDiff < 10)
                {
                    tienPhong = (hourDiff + 1) * (donGiaPhong / 10);
                }
                else
                {
                    tienPhong = donGiaPhong;
                }
            }
            else
            {
                tienPhong = dayDateDiff * donGiaPhong;
            }
            txtTienPhong.Text = string.Format("{0:0,0}", tienPhong);
            txtDichVu.Text    = string.Format("{0:0,0}", tienDichVu);

            ThanhTien         = tienDichVu + tienPhong;
            txtThanhTien.Text = string.Format("{0:0,0}", ThanhTien);
        }
        public ManHinhDatPhong(int maPhong)
        {
            InitializeComponent();
            cbbLoaiKhach.ItemsSource    = LoaiKhachDAO.LoadAll().DefaultView;
            dataGridDsKhach.ItemsSource = KhachHangDAO.LoadAll().DefaultView;
            soLuongKhach    = KhachHangDAO.GetSoLuongKhach();
            MaPhong         = maPhong;
            txtMaPhong.Text = maPhong.ToString();
            Phong     p  = PhongDAO.LoadOne(maPhong);
            LoaiPhong lp = LoaiPhongDAO.LoadOne(p.LoaiPhong);

            txtLoaiPhong.Text          = lp.TenLoai;
            txtMaKhach.Text            = (soLuongKhach + 1).ToString();
            cbbLoaiKhach.SelectedIndex = 0;
        }
示例#3
0
        public ChiTietDatPhong(int maPhong)
        {
            InitializeComponent();
            MaPhong         = maPhong;
            txtMaPhong.Text = maPhong.ToString();
            Phong     p  = PhongDAO.LoadOne(maPhong);
            LoaiPhong lp = LoaiPhongDAO.LoadOne(p.LoaiPhong);

            cbbLoaiKhach.ItemsSource = LoaiKhachDAO.LoadAll().DefaultView;
            txtLoaiPhong.Text        = lp.TenLoai;

            DataTable table = DatPhongDAO.LoadByMaPhong(maPhong);

            dpNgayThue.Text = table.Rows[0].Field <DateTime>(2).ToString("MM/dd/yyyy");

            dataGridDsKhach.ItemsSource = DatPhongDAO.LoadThongTinKhach(maPhong).DefaultView;
            cbbLoaiKhach.SelectedIndex  = 0;
        }
示例#4
0
 private void btn_ThemConfirm_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (txt_maphong.Text == "")
         {
             MessageBox.Show("Vui lòng nhập mã phòng.");
             return;
         }
         Phong       p           = new Phong();
         DataRowView rowview_lp  = cb_loaiphong.SelectedItem as DataRowView;
         DataRowView rowview_tt  = cb_tinhtrang.SelectedItem as DataRowView;
         DataRowView rowview_tth = cb_trangthai.SelectedItem as DataRowView;
         p.MaPhong   = Int32.Parse(txt_maphong.Text);
         p.LoaiPhong = rowview_lp["MaLoai"].ToString();
         p.TinhTrang = Int32.Parse(rowview_tt["MaTT"].ToString());
         p.TrangThai = Int32.Parse(rowview_tth["MaTT"].ToString());
         p.GhiChu    = txt_ghichu.Text;
         MessageBoxResult kq = MessageBox.Show("Bạn có chắc chắn không?", "Xác nhận", MessageBoxButton.YesNo);
         if (kq == MessageBoxResult.Yes)
         {
             PhongDAO.Insert(p);
             MessageBox.Show("Thêm thành công", "Thành công");
             EmptyText();
             UnenableText();
             btn_Them.IsEnabled         = true;
             btn_ThemConfirm.Visibility = Visibility.Hidden;
             btn_Huy.Visibility         = Visibility.Hidden;
             grid_phong.ItemsSource     = PhongDAO.LoadAll().DefaultView;
         }
         else
         {
             EmptyText();
             UnenableText();
             btn_Them.IsEnabled         = true;
             btn_ThemConfirm.Visibility = Visibility.Hidden;
             return;
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#5
0
 private void btn_Xoa_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Phong       p       = new Phong();
         DataRowView rowview = grid_phong.SelectedItem as DataRowView;
         p.MaPhong = Int32.Parse(rowview.Row["MaPhong"].ToString());
         MessageBoxResult kq = MessageBox.Show("Bạn có chắc chắn không?", "Xác nhận", MessageBoxButton.YesNo);
         grid_phong.UnselectAll();
         if (kq == MessageBoxResult.Yes)
         {
             PhongDAO.Delete(p);
             MessageBox.Show("Xóa thành công", "Thành công");
             grid_phong.ItemsSource = PhongDAO.LoadAll().DefaultView;
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#6
0
 private void grid_phong_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         if (btn_Them.IsEnabled == false)
         {
             btn_Them.IsEnabled         = true;
             btn_ThemConfirm.Visibility = Visibility.Hidden;
             btn_Huy.Visibility         = Visibility.Hidden;
             UnenableText();
         }
         Phong       p       = new Phong();
         DataRowView rowview = grid_phong.SelectedItem as DataRowView;
         if (rowview != null)
         {
             int maphong = Int32.Parse(rowview.Row["MaPhong"].ToString());
             p = PhongDAO.LoadOne(maphong);
             txt_maphong.Text = p.MaPhong.ToString();
             for (int i = 0; i < cb_loaiphong.Items.Count; i++)
             {
                 DataRowView rowcbview = cb_loaiphong.Items[i] as DataRowView;
                 if (rowcbview["MaLoai"].ToString().Equals(p.LoaiPhong))
                 {
                     cb_loaiphong.SelectedIndex = i;
                 }
             }
             cb_tinhtrang.SelectedIndex = p.TinhTrang - 1;
             cb_trangthai.SelectedIndex = p.TrangThai - 1;
             txt_ghichu.Text            = p.GhiChu;
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#7
0
        private void bntPhong_Click(object sender, RoutedEventArgs e)
        {
            Phong frm = new Phong();

            frm.Show();
        }