Example #1
0
        //Thêm
        public void insertChiTietDatPhong(ChiTietDatPhongDTO ctdpDTO)
        {
            chitietdatphong ctdp = new chitietdatphong();

            ctdp.maphieudat = ctdpDTO.Maphieudat;
            ctdp.maphong    = ctdpDTO.Maphong;
            htDataContext.chitietdatphongs.InsertOnSubmit(ctdp);
            htDataContext.SubmitChanges();
        }
Example #2
0
        public ChuyenPhong(ChiTietDatPhongDTO chiTietDatPhong) : this()
        {
            this.chiTietDatPhong = chiTietDatPhong;

            RefreshDataBinding_ChuyenDatPhong();


            ValidateChildren();
        }
Example #3
0
        public ActionResult DatHang()
        {
            //Kiểm tra đăng đăng nhập
            if (Session["TaiKhoan"] == null || Session["TaiKhoan"].ToString() == "")
            {
                return(RedirectToAction("DangNhap", "NguoiDung"));
            }
            //Kiểm tra giỏ hàng
            if (Session["GioDatHang"] == null)
            {
                RedirectToAction("Index", "Home");
            }
            else
            {
                //Thêm đơn hàng
                PhieuDatPhongDTO  pdpDTO = new PhieuDatPhongDTO();
                KhachHangDTO[]    kh     = (KhachHangDTO[])Session["TaiKhoan"];
                List <GioDatHang> gh     = LayGioDatHang();
                foreach (var item in gh)
                {
                    pdpDTO.Maphieudat = "PDP00" + newid();
                    foreach (var itum in kh)
                    {
                        pdpDTO.Makhachhang = itum.Makhachhang;
                    }
                    pdpDTO.Username     = "";
                    pdpDTO.Ngayden      = DateTime.Parse(item.dNgayden);
                    pdpDTO.Ngaydi       = DateTime.Parse(item.dNgaydi);
                    pdpDTO.Sotiendatcoc = 0;
                    pdpDTO.Tinhtrang    = "waitting";
                    pdpDTO.Songuoi      = item.iSonguoi;
                    if (pdp.insertPhieuDatPhong(pdpDTO) == 1)
                    {
                        ChiTietDatPhongDTO ctdpDTO = new ChiTietDatPhongDTO();
                        ctdpDTO.Maphieudat = pdpDTO.Maphieudat;
                        ctdpDTO.Maphong    = item.sMaphong;
                        ctdp.insertChiTietDatPhong(ctdpDTO);

                        //Cập nhật trạng thái phòng
                        PhongDTO pDTO = new PhongDTO();
                        pDTO.Maphong = ctdpDTO.Maphong;
                        PhongDTO ptemp = p.getPhongByID(ctdpDTO.Maphong);
                        pDTO.Maloai = ptemp.Maloai;
                        pDTO.Dadat  = true;
                        pDTO.Danhan = ptemp.Danhan;
                        p.updatePhong(pDTO);
                    }
                }
            }
            var query = (from dv in entity.ngaydatphongs
                         select dv);

            entity.ngaydatphongs.RemoveRange(query);
            entity.SaveChanges();
            return(RedirectToAction("Index", "Home"));
        }
        public ActionResult DatHang()
        {
            //Kiểm tra đăng đăng nhập
            if (Session["TaiKhoan"] == null || Session["TaiKhoan"].ToString() == "")
            {
                return RedirectToAction("DangNhap", "NguoiDung");
            }
            //Kiểm tra giỏ hàng
            if (Session["GioDatHang"] == null)
            {
                RedirectToAction("Index", "Home");
            }
            else
            {
                //Thêm đơn hàng
                PhieuDatPhongDTO pdpDTO = new PhieuDatPhongDTO();
                KhachHangDTO[] kh = (KhachHangDTO[])Session["TaiKhoan"];
                List<GioDatHang> gh = LayGioDatHang();
                foreach (var item in gh)
                {
                    pdpDTO.Maphieudat = "PDP00" + newid();
                    foreach (var itum in kh)
                    {
                        pdpDTO.Makhachhang = itum.Makhachhang;
                    }
                    pdpDTO.Username = "";
                    pdpDTO.Ngayden = DateTime.Parse(item.dNgayden);
                    pdpDTO.Ngaydi = DateTime.Parse(item.dNgaydi);
                    pdpDTO.Sotiendatcoc = 0;
                    pdpDTO.Tinhtrang = "waitting";
                    pdpDTO.Songuoi = item.iSonguoi;
                    if (pdp.insertPhieuDatPhong(pdpDTO) == 1)
                    {
                        ChiTietDatPhongDTO ctdpDTO = new ChiTietDatPhongDTO();
                        ctdpDTO.Maphieudat = pdpDTO.Maphieudat;
                        ctdpDTO.Maphong = item.sMaphong;
                        ctdp.insertChiTietDatPhong(ctdpDTO);

                        //Cập nhật trạng thái phòng
                        PhongDTO pDTO = new PhongDTO();
                        pDTO.Maphong = ctdpDTO.Maphong;
                        PhongDTO ptemp = p.getPhongByID(ctdpDTO.Maphong);
                        pDTO.Maloai = ptemp.Maloai;
                        pDTO.Dadat = true;
                        pDTO.Danhan = ptemp.Danhan;
                        p.updatePhong(pDTO);
                    }
                }
            }
            var query = (from dv in entity.ngaydatphongs
                         select dv);

            entity.ngaydatphongs.RemoveRange(query);
            entity.SaveChanges();
            return RedirectToAction("Index", "Home");
        }
Example #5
0
        //Sửa
        public void updateChiTietDatPhong(ChiTietDatPhongDTO ctdpDTO)
        {
            var querry = (from ctdp in htDataContext.chitietdatphongs
                          where ctdp.maphieudat == ctdpDTO.Maphieudat
                          select ctdp).FirstOrDefault <chitietdatphong>();

            querry.maphieudat = ctdpDTO.Maphieudat;
            querry.maphong    = ctdpDTO.Maphong;
            htDataContext.SubmitChanges();
        }
        public static bool LuuThongTinDatPhong(ChiTietDatPhongDTO datPhongDTO)
        {
            StringBuilder stringBuilder = new StringBuilder("INSERT INTO `quanlykaraoke`.`chitietdatphong` (`MaChiTietDatPhong`, `MaPhong`, `MaDatPhong`) VALUES ('$0', '$1', '$2');");

            stringBuilder.Replace("$0", datPhongDTO.MaChiTietDatPhong.ToString());
            stringBuilder.Replace("$1", datPhongDTO.MaPhong.ToString());
            stringBuilder.Replace("$2", datPhongDTO.MaDatPhong.ToString());


            DataProvider.ExecuseNonQuery(stringBuilder.ToString());
            return(true);
        }
Example #7
0
 public int updateChiTietDatPhong(ChiTietDatPhongDTO htDTO)
 {
     try
     {
         ctdpDAO.updateChiTietDatPhong(htDTO);
         return(1);
     }
     catch
     {
         return(0);
     }
 }
Example #8
0
 public int insertChiTietDatPhong(ChiTietDatPhongDTO htDTO)
 {
     try
     {
         ctdpDAO.insertChiTietDatPhong(htDTO);
         return(1);
     }
     catch
     {
         return(0);
         //throw new Exception("Không thêm được dữ liệu!");
     }
 }
Example #9
0
        internal void RefreshDataBinding(ChiTietDatPhongDTO chiTiet)
        {
            chiTietDatPhong = chiTiet;

            phong = PhongBUS.LayThongTinPhong(chiTiet.MaPhong);
            txtMaPhong.EditValue        = phong.MaPhong;
            txtTenPhong.EditValue       = phong.TenPhong;
            txtLoaiPhong.EditValue      = LoaiPhongBUS.LayLoaiPhong(phong).TenLoaiPhong;
            txtTang.EditValue           = phong.Tang;
            txtTinhTrangPhong.EditValue = PhongBUS.LayTinhTrangPhong(phong.MaTinhTrangPhong).TinhTrangPhong;
            txtGhiChu.EditValue         = phong.GhiChu;

            RefreshDataBindingDichVuPhong();
        }
        //Xử lý sự kiên của button Sửa phiếu đặt phòng
        private void btnSua_Click(object sender, EventArgs e)
        {
            if (chang == true||Nochangdi==true||Nochangden==true)
            {
                if (kiemtradl() == false)
                {
                    MessageBox.Show("Chưa nhập đủ thông tin, Kiểm tra lại!!!");
                    return;
                }
                if (ktsonguoi() == false)
                {
                    MessageBox.Show("Quá số người quy định cho phòng!!!.Kiểm tra lại.");
                    return;
                }
                sua();

                PhieuDatPhongDTO listpdp = pdp.getPhieuDatPhongByID(labMaPD.Text);
                pdpDTO = new PhieuDatPhongDTO();
                pdpDTO.Maphieudat = listpdp.Maphieudat;
                pdpDTO.Makhachhang = listpdp.Makhachhang;
                pdpDTO.Ngayden = DateTime.Parse(lsvChiTiet.Groups[1].Items[0].SubItems[1].Text);
                pdpDTO.Ngaydi = DateTime.Parse(lsvChiTiet.Groups[1].Items[1].SubItems[1].Text);
                pdpDTO.Songuoi = int.Parse(lsvChiTiet.Groups[1].Items[2].SubItems[1].Text);
                pdpDTO.Sotiendatcoc = 0;
                pdpDTO.Username = frmMain.m_username;
                pdpDTO.Tinhtrang = "waitting";

                if (pdp.updatePhieuDatPhong(pdpDTO) == 1)
                {
                    for (int i = 0; i < lsvViewPhong.Items.Count; i++)
                    {
                        ctdpDTO = new ChiTietDatPhongDTO();
                        ctdpDTO.Maphieudat = pdpDTO.Maphieudat;
                        ctdpDTO.Maphong = lsvViewPhong.Items[i].SubItems[0].Text;
                        ctp.insertChiTietDatPhong(ctdpDTO);

                        pDTO = new PhongDTO();
                        pDTO.Maphong = ctdpDTO.Maphong;
                        pDTO.Maloai = lsvViewPhong.Items[i].SubItems[1].Text;
                        pDTO.Danhan = false;
                        pDTO.Dadat = true;
                        phong.updatePhong(pDTO);
                    }
                    lsvViewPhong.Items.Clear();

                    IList<ChiTietDatPhongDTO> listctdp = ctp.getChiTietDatPhongByID(labMaPD.Text);
                    foreach (ChiTietDatPhongDTO ctdp in listctdp)
                    {
                        int i = lsvViewPhong.Items.Count;
                        lsvViewPhong.Items.Add(ctdp.Maphong);

                        IList<PhongDTO> listp = phong.getLikePhongByID(ctdp.Maphong);
                        foreach (PhongDTO p in listp)
                        {
                            LoaiPhongDTO listlp = lphong.getLoaiPhongByID(p.Maloai);
                            lsvViewPhong.Items[i].SubItems.Add(listlp.Maloai);
                            lsvViewPhong.Items[i].SubItems.Add(listlp.Songuoi.ToString());
                            lsvViewPhong.Items[i].SubItems.Add(listlp.Gia.ToString("0,0"));
                        }
                    }
                    show_lsvPDP();
                    lsvTimPhong.Items.Clear();
                    frmMain.capnhatphong();
                    MessageBox.Show("Đã sửa thành công!");
                    chang = false;
                    Nochangden = false;
                    Nochangdi = false;
                    lsvTimPhong.Items.Clear();

                    lsvChiTiet.Groups[1].Items[0].SubItems[1].Text = "";
                    lsvChiTiet.Groups[1].Items[1].SubItems[1].Text = "";
                    lsvChiTiet.Groups[1].Items[2].SubItems[1].Text = "";
                    txtSonguoi.Clear();
                    lsvViewPhong.Items.Clear();
                }
                else
                {
                    MessageBox.Show("Error!");
                    return;
                }
            }
            else
            {
                lsvViewPhong.Items.Clear();
                lsvChiTiet.Groups[1].Items[0].SubItems[1].Text = "";
                lsvChiTiet.Groups[1].Items[1].SubItems[1].Text = "";
                lsvChiTiet.Groups[1].Items[2].SubItems[1].Text = "";
                labMaPD.Text = "HD00" + newid();
                MessageBox.Show("Chưa tạo phiếu đặt phòng!");
            }
        }
Example #11
0
 public static void CapNhatThongTinDatPhong(ChiTietDatPhongDTO chiTietDatPhongDTO)
 {
     DAL.ChiTietDatPhongDAL.CapNhatThongTinDatPhong(chiTietDatPhongDTO);
 }
Example #12
0
 public static void XoaCacDichVuDatPhong(ChiTietDatPhongDTO chiTietDatPhong)
 {
     DAL.DatPhongDAL.XoaCacDichVuDatPhong(chiTietDatPhong);
 }
        //Đặt phòng
        private void button1_datphong_Click(object sender, EventArgs e)
        {
            if (kiemtradl() == false)
            {
                MessageBox.Show("Chưa nhập đủ thông tin, Kiểm tra lại!!!");
                return;
            }
            if (ktsonguoi() == false)
            {
                MessageBox.Show("Quá số người quy định cho phòng!!!.Kiểm tra lại.");
                return;
            }
            if (dtpNgayden.Value.Day < DateTime.Now.Day)
            {
                MessageBox.Show("Ngày đến không được nhỏ hơn ngày hiện tại!");
                lsvChiTiet.Groups[1].Items[0].SubItems[1].Text = "";
                lsvChiTiet.Groups[1].Items[1].SubItems[1].Text = "";
                dtpNgayden.Value = DateTime.Now.Date;
                return;
            }
            //Thêm phiếu đặt phòng
            pdpDTO = new PhieuDatPhongDTO();
            pdpDTO.Maphieudat = labMaPD.Text;
            maphieudat = pdpDTO.Maphieudat;
            pdpDTO.Makhachhang = cmbKhachHang.SelectedValue.ToString();
            pdpDTO.Username = txt_NVien.Text;
            pdpDTO.Ngayden = dtpNgayden.Value;
            pdpDTO.Ngaydi = dtpNgaydi.Value;
            pdpDTO.Sotiendatcoc = 0;
            pdpDTO.Tinhtrang = "waitting";
            pdpDTO.Songuoi = int.Parse(txtSonguoi.Text);
            if (pdp.insertPhieuDatPhong(pdpDTO) == 1)
            {
                for (int i = 0; i < lsvViewPhong.Items.Count; i++)
                {
                    //Thêm chi tiết đặt phòng
                    ctdpDTO = new ChiTietDatPhongDTO();
                    ctdpDTO.Maphieudat = pdpDTO.Maphieudat;
                    ctdpDTO.Maphong = lsvViewPhong.Items[i].SubItems[0].Text;
                    ctp.insertChiTietDatPhong(ctdpDTO);

                    //Cập nhật trạng thái phòng
                    pDTO = new PhongDTO();
                    pDTO.Maphong = ctdpDTO.Maphong;
                    PhongDTO ptemp = phong.getPhongByID(ctdpDTO.Maphong);
                    pDTO.Maloai = lsvViewPhong.Items[i].SubItems[1].Text;
                    pDTO.Dadat = true;
                    pDTO.Danhan = ptemp.Danhan;
                    phong.updatePhong(pDTO);
                }
                MessageBox.Show("Đã tạo phiếu đặt phòng!");
            }
            else
            {
                MessageBox.Show("Không tạo được!");
                labMaPD.Text = "PDP00" + newid();
            }
            lsvTimPhong.Items.Clear();
            lsvChiTiet.Groups[1].Items[0].SubItems[1].Text = "";
            lsvChiTiet.Groups[1].Items[1].SubItems[1].Text = "";
            lsvChiTiet.Groups[1].Items[2].SubItems[1].Text = "";
            txtSonguoi.Clear();
            lsvViewPhong.Items.Clear();
            frmMain.capnhatphong();
        }
Example #14
0
 public static void XoaDatChiTietDatPhong(ChiTietDatPhongDTO chiTietDatPhong)
 {
     DAL.DatPhongDAL.XoaChiTietDatPhong(chiTietDatPhong);
 }
Example #15
0
 public static bool CapNhatThongTinDatPhong(ChiTietDatPhongDTO chiTietDatPhongDTO)
 {
     DataProvider.ExecuseNonQuery("UPDATE chitietdatphong SET MaPhong = '" + chiTietDatPhongDTO.MaPhong + "'  WHERE MaChiTietDatPhong = '" + chiTietDatPhongDTO.MaChiTietDatPhong + "'  ;");
     return(true);
 }
Example #16
0
 public static DataTable LayTatCaDichVuDatPhong_DichVu_LoaiDV(ChiTietDatPhongDTO chiTietDatPhong)
 {
     return(DAL.DichVuDatPhongDAL.LayTatCaDichVuDatPhong_DichVu_LoaiDV(chiTietDatPhong));
 }
Example #17
0
        public ChuyenPhong()
        {
            InitializeComponent();

            chiTietDatPhong = null;
        }
Example #18
0
 public static void XoaChiTietDatPhong(ChiTietDatPhongDTO chiTietDatPhong)
 {
     DataProvider.ExecuseNonQuery("DELETE FROM chitietdatphong WHERE MaChiTietDatPhong = '" + chiTietDatPhong.MaChiTietDatPhong + "';");
 }
Example #19
0
 public static DataTable LayTatCaDichVuDatPhong_DichVu_LoaiDV(ChiTietDatPhongDTO chiTietDatPhong)
 {
     return(DataProvider.ExecuseQuery("SELECT MaDichVuDatPhong,dichvudatphong.MaChiTietDatPhong, dichvudatphong.MaDichVu,SoLuong, Gia, TenDV,DonGia, DonVi, dichvu.MaLDV, TenLDV FROM quanlykaraoke.dichvudatphong,quanlykaraoke.dichvu,quanlykaraoke.loaidichvu  WHERE  quanlykaraoke.dichvudatphong.MaDichVu = quanlykaraoke.dichvu.MaDV AND quanlykaraoke.dichvu.MaLDV = quanlykaraoke.loaidichvu.MaLDV AND dichvudatphong.MaChiTietDatPhong = '" + chiTietDatPhong.MaChiTietDatPhong + "'; "));
 }
Example #20
0
 public static bool LuuThongTinDatPhong(ChiTietDatPhongDTO datPhongDTO)
 {
     return(DAL.ChiTietDatPhongDAL.LuuThongTinDatPhong(datPhongDTO));
 }