예제 #1
0
        private void datBanToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DatBan frm = new DatBan();

            frm.MdiParent = this;
            frm.Show();
        }
    protected void btnReserv_Click(object sender, EventArgs e)
    {
        //lbBookingMess.Text = "Đặt bàn";
        int rs = 0;

        DatBan data = new DatBan();

        data.Ten = custumerName.Text;
        data.DiaChi = Address.Text;
        data.Email = String.Empty;
        data.SDT = Convert.ToInt32(Phone.Text.Trim());
        data.SoNguoi = Amount.Text;

        DateTime Ngay = DateTime.ParseExact(Date.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
        data.Ngay = Ngay;
        data.Gio = Hour.Text;

        data.NgayGui = DateTime.Now;
        data.TrangThai = 0;

        rs = DatBan.Them(data);
        if (rs > 0)
        {
            refesh();
            lbBookingMess.Text = "Success, Thank you!";
        }
        else
        {
            lbBookingMess.Text = "Cannot book";
        }
    }
예제 #3
0
 private void btnSuaPhieu_Click(object sender, EventArgs e)
 {
     try
     {
         if (iddatbanSelected != 0)
         {
             DatBan db = new DatBan();
             db.id_datban    = iddatbanSelected;
             db.id_khachhang = (int)cbxKhachHang.EditValue;
             db.id_ban       = idbanSelected;
             db.thoigian     = dtNgayDat.DateTime;
             db.tiencoc      = Convert.ToDecimal(txtDatCoc.EditValue);
             datban_bll.SuaPhieuDatBan(db);
             MessageBox.Show("Sửa phiếu thành công");
             LoadDsBan();
             LoadDsDatBan();
             //LoadChiTietDatBan();
         }
         else
         {
             MessageBox.Show("Chọn phiếu đặt bàn muốn sửa");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
예제 #4
0
 public UC_BanHang()
 {
     InitializeComponent();
     _lstBanAn      = new List <BanAn>();
     _lstMonAn      = new List <MonAn>();
     _SelectedMonAn = new MonAn();
     _SelectedBanAn = new BanAn();
     _CurrDatBan    = new DatBan();
 }
예제 #5
0
        public double LoadTienCoc(int iddatban)
        {
            DatBan ts = dbContext.DatBans.Single(p => p.id_datban == iddatban);

            if (ts.tiencoc == null)
            {
                ts.tiencoc = 0;
            }
            return((double)ts.tiencoc);
        }
예제 #6
0
        public void SuaTienCoc(DatBan db)
        {
            var query =
                from datban in dbContext.DatBans
                where
                datban.id_datban == db.id_datban
                select datban;

            foreach (var q in query)
            {
                q.tiencoc = db.tiencoc;
            }
            dbContext.SubmitChanges();
        }
예제 #7
0
 protected void LoadDatBan(DatBan data)
 {
     //Thong tin khach hang
     lbID.Text = data.ID.ToString();
     lbdiachi.Text = data.DiaChi;
     lbhoten.Text = data.Ten;
     lbemail.Text = data.Email;
     lbgio.Text = data.Gio;
     lbnguoi.Text = data.SoNguoi;
     lbngaydat.Text = String.Format("{0:dd/MM/yyyy}", data.Ngay);
     lbsdt.Text = data.SDT.ToString();
     lbngaygui.Text = String.Format("{0:dd/MM/yyyy}", data.NgayGui);
     lbtrangthai.Text = LoaiStatus(data.TrangThai);
     titletrangthai.Text = data.TrangThai.ToString();
 }
예제 #8
0
        private void btnThemMoi_Click(object sender, EventArgs e)
        {
            try
            {
                if (cbxKhachHang.EditValue == null)
                {
                    MessageBox.Show("Xin chọn khách hàng");
                    return;
                }
                if (DateTime.Compare(dtNgayDat.DateTime, DateTime.Today) < 0)
                {
                    MessageBox.Show("Ngày đặt bàn không nhỏ hơn ngày hiện tại");
                    return;
                }
                DatBan db = new DatBan();


                if (lvDsBan.SelectedItems.Count > 0)
                {
                    db.id_ban = Convert.ToInt16(lvDsBan.SelectedItems[0].Name);
                }
                else
                {
                    MessageBox.Show("Xin chọn Bàn");
                    return;
                }

                db.id_khachhang = (int)cbxKhachHang.EditValue;
                db.id_nhanvien  = ID_NHANVIEN;
                db.thoigian     = dtNgayDat.DateTime.Date;
                db.trangthai    = ttdatban[0]; //0.chờ  1.nhận  2.hủy
                db.tiencoc      = 0;
                datban_bll.ThemMoiPhieuDatBan(db);
                IQueryable <DatBan> query = datban_bll.LoadPhieuDatBan(db.id_ban, db.thoigian);
                foreach (var i in query)
                {
                    iddatbanSelected = i.id_datban;
                }
                MessageBox.Show("Thêm phiếu đặt thành công");
                LoadDsBan();
                LoadDsDatBan();
                LoadChiTietDatBan();
                txtDatCoc.EditValue = 0;
            }
            catch (Exception)
            {
            }
        }
예제 #9
0
        public void SuaPhieuDatBan(DatBan db)
        {
            var query =
                from datban in dbContext.DatBans
                where
                datban.id_datban == db.id_datban
                select datban;

            foreach (var q in query)
            {
                q.id_ban       = db.id_ban;
                q.id_khachhang = db.id_khachhang;
                q.thoigian     = db.thoigian;
                q.tiencoc      = db.tiencoc;
            }
            dbContext.SubmitChanges();
        }
예제 #10
0
 private void listViewBanAn_SelectedIndexChanged(object sender, EventArgs e)
 {
     listViewMonAnDaGoi.Items.Clear();
     lblTongTien.Text       = lblTongTien.Tag.ToString();
     lblTenBan.Text         = lblTenBan.Tag.ToString();
     lblTenKhuVuc.Text      = lblTenKhuVuc.Tag.ToString();
     lblThoiGianDatBan.Text = lblThoiGianDatBan.Tag.ToString();
     _SelectedBanAn         = null;
     _CurrDatBan            = null;
     if (listViewBanAn.SelectedItems.Count > 0)
     {
         var banAnID = int.Parse(listViewBanAn.SelectedItems[0].Name);
         this._SelectedBanAn = _lstBanAn.Find(x => x.BanAnID == banAnID);
         lblTenBan.Text      = _SelectedBanAn.TenBan;
         lblTenKhuVuc.Text   = _SelectedBanAn.TenKhuVuc;
         if (this._SelectedBanAn.TrangThaiID == 1)
         {
             RestaurantServicesSoapClient serv = new RestaurantServicesSoapClient();
             var ds = serv.Lay_DanhSachDatBan(banAnID);
             _CurrDatBan            = new DatBan(ds.Tables[0].Rows[0]);
             lblThoiGianDatBan.Text = _CurrDatBan.NgayDatBan.ToString();
             _lstChiTiet            = new List <ChiTietDatBan>();
             foreach (DataRow dr in ds.Tables[1].Rows)
             {
                 var ct = new ChiTietDatBan(dr);
                 _lstChiTiet.Add(ct);
                 ListViewItem item = new ListViewItem();
                 item.Text = ct.TenMonAn;
                 item.SubItems.Add(ct.DonGia.ToString("#,#"));
                 item.SubItems.Add(ct.SoLuong.ToString());
                 item.SubItems.Add((ct.SoLuong * ct.DonGia).ToString("#,#"));
                 listViewMonAnDaGoi.Items.Add(item);
             }
             _TongTien = 0;
             _lstChiTiet.ForEach(x =>
             {
                 _TongTien += x.DonGia * x.SoLuong;
             });
             _TongTien       *= 1000;
             lblTongTien.Text = _TongTien.ToString("#,#");
         }
     }
 }
예제 #11
0
        //public int Layidkhachhang(int iddatban)
        //{
        //    int idkh = 0;
        //    var query = from hd in dbContext.DatBans
        //                where hd.id_datban == iddatban
        //                select hd;
        //    foreach (var i in query)
        //    {
        //        i.id_khachhang = idkh;
        //    }
        //    return idkh;
        //}
        //public void ChuyenKhachHang(int iddatban, HoaDonThanhToan m)
        //{
        //    int idkh = Layidkhachhang(iddatban);
        //}


        public void ChuyenChiTietDatBan(int idban, DateTime today, int idhoadon, List <string> ttdatban)
        {
            int?iddatban      = 0;
            var chitietdatban = from ct in dbContext.Chitiet_DatBans
                                where
                                ct.DatBan.id_ban == idban &&
                                ct.DatBan.thoigian == today &&
                                ct.DatBan.trangthai == ttdatban[0]
                                select new
            {
                ct.id_datban,
                ct.id_mon,
                ct.Mon.tenmon,
                ct.soluong,
                gia = (decimal?)ct.Mon.gia,
                ct.thanhtien
            };

            foreach (var ctdb in chitietdatban)
            {
                Chitiet_HoaDonThanhToan cthoadon = new Chitiet_HoaDonThanhToan();
                cthoadon.id_hoadon = idhoadon;
                cthoadon.id_mon    = ctdb.id_mon;
                cthoadon.soluong   = ctdb.soluong;
                cthoadon.dongia    = ctdb.gia;
                cthoadon.thanhtien = ctdb.thanhtien;
                ThemMoiChiTietHoaDon(cthoadon);
                iddatban = ctdb.id_datban;
            }
            HoaDonThanhToan hdtt = dbContext.HoaDonThanhToans.Single <HoaDonThanhToan>(hd => hd.id_hoadon == idhoadon);
            DatBan          db   = dbContext.DatBans.Single <DatBan>(d => d.id_datban == iddatban);

            hdtt.datra        = db.tiencoc;
            hdtt.id_khachhang = db.id_khachhang;

            // update
            dbContext.SubmitChanges();
        }
예제 #12
0
 public ActionResult CapNhatDonDatBan(int id, FormCollection collection, DatBan db)
 {
     if (Session["SDT"] == null || Session["SDT"].ToString() == "")
     {
         return(RedirectToAction("DangNhap", "ChiNhanh_Z9TheCoffee"));
     }
     else
     {
         //Them vao CSDL
         if (ModelState.IsValid)
         {
             try
             {
                 db        = data.DatBans.SingleOrDefault(n => n.MaDatBan == id);
                 db.DaXong = Convert.ToBoolean(collection["DaXong"]);
                 //Luu vao CSDL
                 data.SubmitChanges();
             }
             catch { ViewBag.Loi = "Vui lòng kiểm tra đầy đủ thông tin"; }
         }
         return(RedirectToAction("HienThiDonDatBan", "ChiNhanh_Z9TheCoffee", new { id = Session["MaChiNhanh"] }));
     }
 }
예제 #13
0
        private void button1_Click(object sender, EventArgs e)
        {
            DatBan frm = new DatBan();

            frm.ShowDialog();
        }
예제 #14
0
 public void ThemMoiPhieuDatBan(DatBan db)
 {
     dbContext.DatBans.InsertOnSubmit(db);
     dbContext.SubmitChanges();
 }