Пример #1
0
        public HoaDon getHoaDon_with_BanSuDung(string maBan)
        {
            int param = 1;
            string[] names = new string[param];
            Object[] values = new Object[param];

            names[0] = "@maBan";
            values[0] = maBan;

            DataTable tb = db.LoadData("[HOADON_proc_get_with_BanSuDung]", names, values, param);

            HoaDon hd = new HoaDon();

            foreach(DataRow row in tb.Rows)
            {
                hd.MaHoaDon = row["MaHoaDon"].ToString();
                Ban bansd = new Ban();
                bansd.maBan = row["MaBan"].ToString();

                Ban bantt = new Ban();
                bantt.maBan = row["MaBanThanhToan"].ToString();

                hd.BanSuDung = bansd;
                hd.BanThanhToan = bantt;

                hd.TongTien = decimal.Parse(row["TongTien"].ToString());
                hd.ThoiGian = DateTime.Parse(row["ThoiGian"].ToString());
                hd.DaThanhToan = bool.Parse(row["DaThanhToan"].ToString());
            }

            return hd;
        }
Пример #2
0
        public Ban getBan_theo_maBan(string maBan)
        {
            int param = 1;
            string[] names = new string[param];
            Object[] values = new Object[param];

            names[0] = "@maBan";

            values[0] = maBan;

            DataTable tb = db.LoadData("[BAN_proc_get]", names, values, param);

            Ban ban = new Ban();

            foreach(DataRow row in tb.Rows)
            {
                ban.maBan = row["MaBan"].ToString();
                ban.tenBan = row["TenBan"].ToString();
                ban.maKhuVuc = row["MaKhuVuc"].ToString();
                ban.TinhTrang = int.Parse(row["TinhTrang"].ToString());
                ban.ghiChu = row["GhiChu"].ToString();

            }
            return ban;
        }
Пример #3
0
        public List<HoaDon> getHoaDonList()
        {
            DataTable tb = db.LoadData("HOADON_proc_load");

            List<DTO.HoaDon> list = new List<HoaDon>();

            foreach (DataRow row in tb.Rows)
            {
                HoaDon hd = new HoaDon();
                hd.MaHoaDon = row["MaHoaDon"].ToString();
                Ban bansd = new Ban();
                bansd.maBan = row["MaBan"].ToString();
                bansd.tenBan = row["TenBan"].ToString();

                Ban bantt = new Ban();
                bantt.maBan = row["MaBanThanhToan"].ToString();
                bantt.tenBan = row["TenBan"].ToString();

                hd.BanSuDung = bansd;
                hd.BanThanhToan = bantt;

                hd.TongTien = decimal.Parse(row["TongTien"].ToString());
                hd.ThoiGian = DateTime.Parse(row["ThoiGian"].ToString());
                hd.DaThanhToan = bool.Parse(row["DaThanhToan"].ToString());

                list.Add(hd);
            }

            return list;
        }
Пример #4
0
 public HoaDon(string _maHoaDon, Ban _banSuDung, Ban _banThanhToan, DateTime _thoiGian, decimal _tongTien, bool _daThanhToan)
 {
     MaHoaDon = _maHoaDon;
     banSuDung = _banSuDung;
     banThanhToan = _banThanhToan;
     thoiGian = _thoiGian;
     TongTien = _tongTien;
     daThanhToan = _daThanhToan;
 }
Пример #5
0
        private static void loadDataBan()
        {
            DataTable table = DataBus.getInstance().getAllBan();
            listBan = new List<Ban>();

            foreach (DataRow row in table.Rows)
            {
                Ban ban = new Ban(row["MaBan"].ToString(), row["TenBan"].ToString(), row["MaKhuVuc"].ToString(), int.Parse(row["TinhTrang"].ToString()), row["GhiChu"].ToString());
                listBan.Add(ban);
            }
        }
Пример #6
0
 private void btnDongY_Click(object sender, EventArgs e)
 {
     Ban ban = new Ban(key, txtTenBan.Text.ToString(), cbKhuVuc.SelectedValue.ToString(), 0, rtxtGhiChu.Text.ToString());
     if(DataBus.getInstance().insertBan(ban) != 0)
     {
         MessageBox.Show("Thêm bàn thành công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         Global.updateListBan(ban);
         Global.KhuVuc.updateBan();
         Global.KhuVuc.TopMost = true;
         Global.KhuVucBan.loadKhuVuc_Ban();
         Hide();
     }
 }
Пример #7
0
        public int updateTinhTrang(Ban ban)
        {
            int param = 2;
            string[] names = new string[param];
            Object[] values = new Object[param];

            names[0] = "@maBan";
            names[1] = "@tinhTrang";

            values[0] = ban.maBan;
            values[1] = ban.tinhTrang;

            return db.Update("[BAN_proc_updateTinhTrang]", names, values, param);
        }
Пример #8
0
        public int insertBan(Ban ban)
        {
            int param = 4;

            string[] name = new string[param];
            object[] value = new object[param];

            name[0] = "@MaBan"; value[0] = ban.maBan;
            name[1] = "@MaKhuVuc"; value[1] = ban.maKhuVuc;
            name[2] = "@Tenban"; value[2] = ban.tenBan;
            name[3] = "@GhiChu"; value[3] = ban.ghiChu;

            return db.Update("BAN_proc_insert", name, value, param);
        }
Пример #9
0
        public int updateBan(Ban ban)
        {
            int param = 3;
            string[] names = new string[param];
            Object[] values = new Object[param];

            names[0] = "@maBan";
            names[1] = "@tenBan";
            names[2] = "@ghiChu";

            values[0] = ban.maBan;
            values[1] = ban.tenBan;
            values[2] = ban.ghiChu;

            return db.Update("[BAN_proc_update]", names, values, param);
        }
Пример #10
0
        private void btnDongY_Click(object sender, EventArgs e)
        {
            Ban ban = new Ban();
            ban.maBan = txtMaBan.Text.ToString();
            ban.tenBan = txtTenBan.Text.ToString();
            ban.ghiChu = rtxtGhiChu.Text.ToString();

            if(DataBus.getInstance().updateBan(ban) != 0)
            {
                Global.updateBan(ban);
                Global.KhuVuc.updateBan();
                this.Close();
                MessageBox.Show("Cập nhật bàn thành công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                Global.KhuVuc.TopMost = true;
                Global.KhuVucBan.loadKhuVuc_Ban();
                
            }
        }
Пример #11
0
        void listview_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListViewEx listView = sender as ListViewEx;
            if (listView.SelectedItems.Count > 0)
            {
                /// chọn currentBan, currentHD của mỗi bàn, bàn còn trống thì enable Mở bàn btn.
                /// chuyển các trạng thái
                
                currentItem = listView.SelectedItems[0];
                //lblTenBan.Text = currentItem.Text;
                //lblTrangThai.Text = currentItem.Tag.ToString();

                // currentBan = banBUS.getBan_theo_maBan(currentItem.Name);
                currentBan = Global.getBanByMaBan(currentItem.Name);
                lblTenBan.Text = currentBan.tenBan;
                switch (currentBan.tinhTrang)
                {
                    case 0:
                        lblTrangThai.Text = bantrong;

                        dgvMonDaGoi.DataSource = null;
                        dgvMonDaGoi.Update();
                        lblThanhTien.Text = "0";
                        lblGioDen.Text = "";
                        lblBanThanhToan.Text = "";

                        btnMoBan.Enabled = true;
                        btnDatBan.Enabled = true;
                        btnHuyBan.Enabled = false;
                        btnGoiMon.Enabled = false;
                        btnHuyMon.Enabled = false;
                        btnChuanBi.Enabled = false;
                        btnThanhToan.Enabled = false;
                        btnChuyenBan.Enabled = false;
                        btnGopBan.Enabled = false;
                        btnTachBan.Enabled = false;
                        break;
                    case 1:
                        lblTrangThai.Text = bandadat;
                        btnTachBan.Enabled = false;
                        break;
                    case 2:
                        lblTrangThai.Text = bancokhach;
                        currentHD = hoaDonBus.getHoaDon_with_BanSuDung(currentBan.maBan);
                        if (currentHD.MaHoaDon != null)
                        {
                            currentHD.BanSuDung = currentBan;
                            currentListCTHD = ctHoaDonBus.loadCTHoaDon_with_MaHoaDon(currentHD.MaHoaDon);
                            parseDataDgvMonDaGoi(currentListCTHD);
                            lblThanhTien.Text = currentHD.TongTien.ToString("#,###");
                            lblGioDen.Text = currentHD.ThoiGian.ToShortTimeString();
                            lblBanThanhToan.Text = currentHD.BanThanhToan.tenBan;
                        }

                        btnDatBan.Enabled = false;
                        btnMoBan.Enabled = false;
                        btnGoiMon.Enabled = true;
                        btnHuyBan.Enabled = true;
                        btnGopBan.Enabled = true;
                        btnChuyenBan.Enabled = true;
                        btnTachBan.Enabled = true;
                        break;
                    case 3:
                        lblTrangThai.Text = bandathanhtoan;
                        lblGioDen.Text = "";
                        lblThanhTien.Text = "0";
                        dgvMonDaGoi.DataSource = null;
                        dgvMonDaGoi.Update();
                        
                        btnMoBan.Enabled = false;
                        btnHuyBan.Enabled = true;
                        btnGoiMon.Enabled = false;
                        btnGopBan.Enabled = false;
                        btnChuyenBan.Enabled = false;
                        btnTachBan.Enabled = false;
                        break;
                }
               
            }

            
        }
Пример #12
0
 public int updateTinhTrang(Ban ban)
 {
     return banDAO.updateTinhTrang(ban);
 }
Пример #13
0
 public static void updateListBan(Ban ban)
 {
     listBan.Add(ban);
 }
Пример #14
0
 public int updateBan(Ban ban)
 {
     return banDao.updateBan(ban);
 }
Пример #15
0
 public int insertBan(Ban ban)
 {
     return banDao.insertBan(ban);
 }
Пример #16
0
 public void clone(Ban ban)
 {
     this.tenBan = ban.tenBan;
     this.ghiChu = ban.ghiChu;
 }
Пример #17
0
 public static void updateBan(Ban _ban)
 {
     foreach (Ban ban in listBan)
     {
         if (ban.maBan == _ban.maBan)
         {
             ban.clone(_ban);
         }
     }
 }
Пример #18
0
        public List<Ban> getListBan_with_MaKhuVuc(string maKhuVuc)
        {
            List<Ban> list = new List<Ban>();
            int param = 1;
            string[] names = new string[param];
            Object[] values = new Object[param];

            names[0] = "@maKhuVuc";

            values[0] = maKhuVuc;

            DataTable tb = db.LoadData("[BAN_proc_load_with_MaKhuVuc]", names, values, param);

            foreach (DataRow row in tb.Rows)
            {
                Ban ban = new Ban();
                ban.maBan = row["MaBan"].ToString();
                ban.tenBan = row["TenBan"].ToString();
                ban.maKhuVuc = row["MaKhuVuc"].ToString();
                ban.ghiChu = row["GhiChu"].ToString();
                ban.tinhTrang = int.Parse(row["TinhTrang"].ToString());
                list.Add(ban);
            }
            return list;
        }
Пример #19
0
 public void updateData(Ban ban)
 {
     txtMaBan.Text = ban.maBan;
     txtTenBan.Text = ban.tenBan;
     rtxtGhiChu.Text = ban.ghiChu;
 }
Пример #20
0
        public List<HoaDon> search_with_MaHoaDon(string ma)
        {
            int param = 1;
            string[] names = new string[param];
            object[] values = new object[param];

            names[0] = "@maHoaDon";
            values[0] = ma;

            DataTable tb = db.LoadData("HOADON_proc_search_with_MaHoaDon", names, values, param);

            List<DTO.HoaDon> list = new List<HoaDon>();

            foreach (DataRow row in tb.Rows)
            {
                HoaDon hd = new HoaDon();
                hd.MaHoaDon = row["MaHoaDon"].ToString();
                Ban bansd = new Ban();
                bansd.maBan = row["MaBan"].ToString();
                bansd.tenBan = row["TenBan"].ToString();

                Ban bantt = new Ban();
                bantt.maBan = row["MaBanThanhToan"].ToString();
                bantt.tenBan = row["TenBan"].ToString();

                hd.BanSuDung = bansd;
                hd.BanThanhToan = bantt;

                hd.TongTien = decimal.Parse(row["TongTien"].ToString());
                hd.ThoiGian = DateTime.Parse(row["ThoiGian"].ToString());
                hd.DaThanhToan = bool.Parse(row["DaThanhToan"].ToString());

                list.Add(hd);
            }

            return list;
        }
Пример #21
0
        private void btnMoBan_Click(object sender, EventArgs e)
        {
            //lblTrangThai.Text = currentItem.Tag.ToString();
            //TODO tạo mới hóa đơn here

            string mahd = DataBus.getInstance().getMaHoaDonMoi();

            currentHD = new DTO.HoaDon();
            Ban bansudung = new Ban();

            bansudung.maBan = currentItem.Name;
            bansudung.tenBan = currentItem.Text;
            bansudung.TinhTrang = 2;

            Ban banThanhToan = new Ban();
            banThanhToan.maBan = currentItem.Name;
            banThanhToan.tenBan = currentItem.Text;

            currentHD.MaHoaDon = mahd;
            currentHD.BanSuDung = bansudung;
            currentHD.BanThanhToan = banThanhToan;
            currentHD.TongTien = 0;
            currentHD.ThoiGian = DateTime.Now;
            currentHD.DaThanhToan = false;

            banBUS.updateTinhTrang(bansudung);
            hoaDonBus.insertHoaDon(currentHD);
            currentListCTHD = ctHoaDonBus.loadCTHoaDon_with_MaHoaDon(currentHD.MaHoaDon);

            lblTrangThai.Text = bancokhach;
            lblThanhTien.Text = currentHD.TongTien.ToString("#,###");
            lblGioDen.Text = currentHD.ThoiGian.ToShortTimeString();
            lblBanThanhToan.Text = currentItem.Text;
            btnGoiMon.Enabled = true;
            btnHuyBan.Enabled = true;
        }