示例#1
0
        private void formbook_FormClosed(object sender, FormClosedEventArgs e)
        {
            frmChonPhong froom = new frmChonPhong();

            this.Hide();
            froom.ShowDialog();
        }
示例#2
0
        private void btbook_Click(object sender, EventArgs e)
        {
            NhanVien pq = (from n in db.NhanViens
                           where n.MaNhanVien == mnv
                           select n).SingleOrDefault();
            frmChonPhong fbook = new frmChonPhong(pq);

            fbook.ShowDialog();
            this.Show();
        }
示例#3
0
        private void bthoanthanhgiatien_Click(object sender, EventArgs e)
        {
            DatPhong datphong = db.DatPhongs.FirstOrDefault(s => s.MaDatPhong == dp.MaDatPhong);

            datphong.TinhTrangThanhToan = "Da thanh toan";
            datphong.ThanhTien          = int.Parse(txtTongTienTT.Text);
            db.SubmitChanges();
            Phong phong = db.Phongs.FirstOrDefault(s => s.MaPhong == dp.MaPhong);

            phong.Available = "Trong";
            db.SubmitChanges();
            MessageBox.Show("Trả phòng thành công!");
            frmChonPhong f = new frmChonPhong(nhanVien);

            this.Close();
            f.ShowDialog();
        }
示例#4
0
        private void btcomfirm_Click(object sender, EventArgs e)
        {
            if (cboKhachHang.Text == "")
            {
                KhachHang kh = new KhachHang();
                kh.MaKhachHang  = txtMaKHDP.Text;
                kh.TenKhachHang = txtHoTenDP.Text;
                kh.SoDienThoai  = txtSDTDP.Text;
                kh.NgaySinh     = dtpNgaySinhDP.Value.ToString();
                kh.PassPort     = txtPassPortDP.Text;
                kh.QuocTich     = txtQuocTichDP.Text;
                db.KhachHangs.InsertOnSubmit(kh);
                db.SubmitChanges();
                //Ma Dat Phong
                DatPhong      dp   = new DatPhong();
                List <string> mdp  = new List <string>();
                var           madp = (from n in db.DatPhongs
                                      select n.MaDatPhong);
                mdp = madp.ToList <string>();
                mdp.Sort();
                int count = mdp.Count() - 1;
                mdp[count] = mdp[count].Remove(mdp[count].Length - 1, 1) + (int.Parse(mdp[count].Last().ToString()) + 1).ToString();
                //Ma Dich Vu
                string dv    = clbDichVu.CheckedItems.ToString();
                string query = (from n in db.DichVus
                                where n.TenDichVu == dv
                                select n.MaDichVu).FirstOrDefault();
                //Tinh tien

                double ngay = (dtpNgayTra.Value - dtpNgayDat.Value).TotalDays;
                //int ngay = int.Parse((dtpNgayTra.Value.Date - dtpNgayDat.Value.Date).ToString());
                int giaP = (from n in db.LoaiPhongs
                            where n.MaLoaiPhong == ph.MaLoaiPhong
                            select n.Gia).FirstOrDefault();
                int giaDV = (from n in db.DichVus
                             where n.TenDichVu == dv
                             select n.Gia).FirstOrDefault();
                double giaphong = ngay * giaP;
                //Ma Nhan Vien


                dp.MaDatPhong = mdp[count];
                dp.MaPhong    = ph.MaPhong;
                //dp.MaDichVu = query;
                dp.MaNhanVien         = nv.MaNhanVien;
                dp.MaKhachHang        = kh.MaKhachHang;
                dp.NgayDat            = dtpNgayDat.Value.ToString();
                dp.NgayTra            = dtpNgayTra.Value.ToString();
                dp.TinhTrangThanhToan = "Chua thanh toan";
                //dp.ThanhTien = int.Parse(giaphong.ToString());
                db.DatPhongs.InsertOnSubmit(dp);
                db.SubmitChanges();


                MessageBox.Show("Dat phong thanh cong");

                //Chinh tinh trang phong
                Phong phon = db.Phongs.FirstOrDefault(s => s.MaPhong == ph.MaPhong);
                phon.Available = "Dat";
                db.SubmitChanges();

                frmChonPhong f = new frmChonPhong(nv);
                this.Close();
                f.ShowDialog();
            }
            else if (cboKhachHang.Text != null)
            {
                string    tkh = cboKhachHang.Text;
                KhachHang kha = (from n in db.KhachHangs
                                 where n.TenKhachHang == tkh
                                 select n).FirstOrDefault();
                //Ma Dat Phong
                DatPhong      dp   = new DatPhong();
                List <string> mdp  = new List <string>();
                var           madp = (from n in db.DatPhongs
                                      select n.MaDatPhong);
                mdp = madp.ToList <string>();
                mdp.Sort();
                int count = mdp.Count() - 1;
                mdp[count] = mdp[count].Remove(mdp[count].Length - 1, 1) + (int.Parse(mdp[count].Last().ToString()) + 1).ToString();
                //Ma Dich Vu
                string dv    = clbDichVu.CheckedItems.ToString();
                string query = (from n in db.DichVus
                                where n.TenDichVu == dv
                                select n.MaDichVu).FirstOrDefault();
                //Tinh tien
                double ngay = (dtpNgayTra.Value - dtpNgayDat.Value).TotalDays;
                //int ngay = int.Parse((dtpNgayTra.Value.Date - dtpNgayDat.Value.Date).ToString());
                int giaP = (from n in db.LoaiPhongs
                            where n.MaLoaiPhong == ph.MaLoaiPhong
                            select n.Gia).FirstOrDefault();
                int giaDV = (from n in db.DichVus
                             where n.TenDichVu == dv
                             select n.Gia).FirstOrDefault();
                double giaphong = ngay * giaP;
                //Ma Nhan Vien


                dp.MaDatPhong = mdp[count];
                dp.MaPhong    = ph.MaPhong;
                //dp.MaDichVu = query;
                dp.MaNhanVien  = nv.MaNhanVien;
                dp.MaKhachHang = kha.MaKhachHang;
                dp.NgayDat     = dtpNgayDat.Value.ToString();
                dp.NgayTra     = dtpNgayTra.Value.ToString();
                //dp.ThanhTien = giaphong;
                dp.TinhTrangThanhToan = "Chua thanh toan";
                db.DatPhongs.InsertOnSubmit(dp);
                db.SubmitChanges();


                MessageBox.Show("Dat phong thanh cong");

                //Chinh tinh trang phong
                Phong phon = db.Phongs.FirstOrDefault(s => s.MaPhong == ph.MaPhong);
                phon.Available = "Dat";
                db.SubmitChanges();

                frmChonPhong f = new frmChonPhong(nv);
                this.Close();
                f.ShowDialog();
            }
        }