Exemplo n.º 1
0
        private TableDTO CreateAddBillByIDTable(DrinkDTO drink)
        {
            TableDTO table = lstBill.Tag as TableDTO;


            int idBill = BillBUS.GetIDBillNoPaymentByIDTable(table.ID);//lấy lên cái mã id của hóa đơn

            // int idDrink = (cbDrink. SelectedItem as DrinkDTO).ID;//thêm vào 1 gridview để hiển thị
            int idDrink  = drink.ID;
            int quantity = 1;

            //kiểm tra hóa đơn có chưa hay
            if (idBill == -1)//nếu chưa thì tạo 1 hóa đơn mới với mã hóa đơn
            {
                quantity = DetailBillBUS.GetQuantityDrink(idBill, idDrink);
                // sau khi tạo xong 1 hóa đơn mới thì thêm vào bảng chi tiết hóa đơn với các trường tương ứng
                DetailBillBUS.InsertDetailBill(BillBUS.GetIDBillMax(), idDrink, quantity + 1);
            }
            else//nếu đã có thì thêm nó vào cái cá bảng chi tiêt hóa đơn với các trường là mã hóa đơn, mã thức uống và số lượng
            {
                quantity = DetailBillBUS.GetQuantityDrink(idBill, idDrink);
                DetailBillBUS.InsertDetailBill(idBill, idDrink, quantity + 1);
            }
            return(table);
        }
Exemplo n.º 2
0
        private void btnThemHoaDon_Click(object sender, EventArgs e)
        {
            txtTongTien.Text = txtTongTien.Text.Replace(" VNĐ", String.Empty);
            dgvHoaDon.Rows.Add();
            dgvHoaDon.Rows[numRow].Cells["colSTT"].Value        = numRow + 1;
            dgvHoaDon.Rows[numRow].Cells["colMaPhong"].Value    = cmbMaPhong.Text;
            dgvHoaDon.Rows[numRow].Cells["colSoNgayThue"].Value = txtSoNgayThue.Text;
            dgvHoaDon.Rows[numRow].Cells["colDonGia"].Value     = txtDonGia.Text;
            dgvHoaDon.Rows[numRow].Cells["colPhuThu"].Value     = txtPhuThu.Text;
            dgvHoaDon.Rows[numRow].Cells["colHeSo"].Value       = txtHeSo.Text;

            btnThemHoaDon.Enabled = false;
            decimal thanhtien = BillBUS.ThanhTien(int.Parse(txtSoNgayThue.Text), Convert.ToDecimal(txtDonGia.Text),
                                                  Convert.ToDecimal(txtPhuThu.Text), Convert.ToDecimal(txtHeSo.Text), Convert.ToDecimal(txtPhiDichVu.Text));

            /*decimal thanhtien = HoaDonBUS.ThanhTien(int.Parse(txtSoNgayThue.Text), Convert.ToDecimal(txtDonGiaPhong.Text),
             * Convert.ToDecimal(txtPhuThu.Text), Convert.ToDecimal(txtHeSo.Text));*/
            //dgvHoaDon.Rows[numRow].Cells["colThanhTien"].Value = thanhtien.ToString();
            dgvHoaDon.Rows[numRow].Cells["colThanhTien"].Value = string.Format("{0:0,0}", thanhtien);
            numRow++;

            txtTongTien.Text = string.Format("{0:0,0 VNĐ}", (Convert.ToDecimal(txtTongTien.Text) + thanhtien));
            // tongtien = string.Format("{0:0,0}", (Convert.ToDecimal(txtTongTien.Text) + thanhtien)) ;
            //txtTongTien.Text = Convert.ToString( Convert.ToDecimal(txtTongTien.Text) + thanhtien);
            ThietLapButton(true);
            if (txtTenKhachHang.ToString() == "")
            {
                btnThanhToan.Enabled = false;
            }
        }
Exemplo n.º 3
0
        public void button_Click(object sender, EventArgs e)
        {
            hoverClickButton(sender);
            choseTable  = sender;
            txtHD.Text  = "";
            txtBan.Text = "";

            // Viết hàm lấy thông tin bàn bằng mã
            Button btnTable = (Button)sender;

            lstBill.Tag = btnTable.Tag;
            // Kiểm tra trạng thai ở
            int idTable = (btnTable.Tag as TableDTO).ID;

            txtBan.Text            = (btnTable.Tag as TableDTO).NameTable + "";
            btnThanhToan.Enabled   = false;
            btnTamTinh.Enabled     = false;
            cbLoaiThucUong.Enabled = true;
            lstSanPham.Enabled     = true;
            txttotalPrice.Text     = "0";
            if (TableBUS.GetStatusByIDTable(idTable) == 1)
            {
                txtHD.Text           = "HD00" + (string)BillBUS.GetIDBillNoPaymentByIDTable((int)idTable).ToString();
                btnThanhToan.Enabled = true;
                btnTamTinh.Enabled   = true;
                if (lstBill.Tag != null)
                {
                    ShowBill(idTable);
                }
            }
            else
            {
                lstBill.Items.Clear();
            }
        }
Exemplo n.º 4
0
        private void filterByTime_CheckedChanged(object sender, EventArgs e)
        {
            tuDateTime.Enabled     = !tuDateTime.Enabled;
            denDateTime.Enabled    = !denDateTime.Enabled;
            currentPageNumber      = 1;
            pageNumberTextBox.Text = currentPageNumber.ToString();

            if (filterByTime.Checked)
            {
                maxPageNumber           = BillBUS.GetMaxPageNumberByTime(int.Parse(billsPerPageComboBox.Text), tuDateTime.Value, denDateTime.Value);
                maxPageNumberLabel.Text = "/ " + maxPageNumber;
                dgv3.DataSource         = BillBUS.LoadAllByTime(currentPageNumber, int.Parse(billsPerPageComboBox.Text), tuDateTime.Value, denDateTime.Value);
            }
            else
            {
                maxPageNumber           = BillBUS.GetMaxPageNumber(int.Parse(billsPerPageComboBox.Text));
                maxPageNumberLabel.Text = "/ " + maxPageNumber;
                dgv3.DataSource         = BillBUS.LoadAll(currentPageNumber, int.Parse(billsPerPageComboBox.Text));
            }

            truocTile.Visible = false;

            if (maxPageNumber == 1)
            {
                sauTile.Visible = false;
            }
            else
            {
                sauTile.Visible = true;
            }
        }
Exemplo n.º 5
0
        private void namComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ngayRadioButton.Checked)
            {
                doanhThuChart.Series[0].Name = "Doanh thu ngày";
                doanhThuChart.Series[0].Points.Clear();
                int month       = int.Parse(thangComboBox.Text);
                int year        = int.Parse(namComboBox.Text);
                int daysInMonth = DateTime.DaysInMonth(year, month);

                for (int day = 1; day <= daysInMonth; day++)
                {
                    doanhThuChart.Series["Doanh thu ngày"].Points.AddXY(day, BillBUS.GetTotalByDay(day, month, year));
                }
            }

            if (thangRadioButton.Checked)
            {
                doanhThuChart.Series[0].Name = "Doanh thu tháng";
                doanhThuChart.Series[0].Points.Clear();
                int year = int.Parse(namComboBox.Text);

                for (int month = 1; month <= 12; month++)
                {
                    doanhThuChart.Series["Doanh thu tháng"].Points.AddXY(month, BillBUS.GetTotalByMonth(month, year));
                }
            }
        }
Exemplo n.º 6
0
        private void btnInHoaDon_Click_1(object sender, EventArgs e)
        {
            FrmReport frmReport = new FrmReport();

            FrmReport.dt = BillBUS.LayMaHDCuoiCung().Value;
            frmReport.ShowDialog();
        }
Exemplo n.º 7
0
        private void btnThanhToan_Click(object sender, EventArgs e)
        {
            try
            {
                TableDTO      table         = lstBill.Tag as TableDTO;
                int           idBill        = BillBUS.GetIDBillNoPaymentByIDTable(table.ID);
                frm_ThanhToan frm_ThanhToan = new frm_ThanhToan("HÓA ĐƠN THANH TOÁN", table.ID, idBill, txttotalPrice.Text);
                //this.Hide();
                frm_ThanhToan.ShowDialog();
                if (frm_ThanhToan._KetQua)
                {
                    ShowBill(table.ID);

                    LoadTable();
                    LoadTypeDrink();
                    btnThanhToan.Enabled   = false;
                    btnTamTinh.Enabled     = false;
                    cbLoaiThucUong.Enabled = false;
                    lstSanPham.Enabled     = false;
                    txttotalPrice.Text     = "0";
                }
            }
            catch
            {
                MessageBox.Show("Hệ thống đang bảo trì, vui lòng thử lại sau.");
            }
        }
Exemplo n.º 8
0
        private void thanhToanTile_Click(object sender, EventArgs e)
        {
            DialogResult dialog = MetroMessageBox.Show(this, "Bạn muốn thanh toán hóa đơn cho bàn " + (selectedIndex + 1) + " ?", "Pay", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dialog == DialogResult.Yes)
            {
                metroTileList[selectedIndex].Style = MetroColorStyle.Green;
                tableList[selectedIndex].TinhTrang = "Còn trống";
                TableBUS.UpdateStatus(tableList[selectedIndex]);
                thanhToanTile.Visible = false;
                themMonTile.Visible   = false;
                tongTienLabel.Visible = false;
                label.Visible         = false;
                dgv.DataSource        = BillDetailBUS.LoadAll(0);
                BillBUS.UpdateInvoicingTime(currentBill);
                Refresh();
                DialogResult dialog2 = MetroMessageBox.Show(this, "Thanh toán thành công, bạn có muốn in hóa đơn ?", "Print receipt", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (dialog2 == DialogResult.Yes)
                {
                    frmThanhToan form = new frmThanhToan(currentBill.MaHoaDon, selectedIndex + 1, login.MaNhanVien);
                    form.Show();
                }
            }
        }
Exemplo n.º 9
0
 private void btnDeleteAccount_Click(object sender, EventArgs e)
 {
     try
     {
         if (this.lstAccount.SelectedItems.Count > 0)
         {
             ListViewItem lvw = lstAccount.SelectedItems[0];
             AccountDTO   sp  = (AccountDTO)lvw.Tag;
             if (sp.ID == Program.sAccount.ID)
             {
                 MessageBox.Show("Bạn không thể sử dụng chức năng này với chính bạn.", "Thông báo", MessageBoxButtons.OK);
             }
             else
             {
                 frm_XacNhan frm_XN = new frm_XacNhan("Bạn vui lòng nhập mật khẩu để xác nhận thao tác này!", Program.sAccount);
                 if (frm_XN.ShowDialog() == DialogResult.OK)
                 {
                     if (AccountBUS.IsLogin(Program.sAccount.ID, frm_XN.txtXacNhap.Text))
                     {
                         if (!BillBUS.IsExistAccountInBill(sp.ID))
                         {
                             if (AccountBUS.DeleteAccount(sp) == true)
                             {
                                 MessageBox.Show("Bạn đã xóa thành công", "Thông báo", MessageBoxButtons.OK);
                                 ShowAccout();
                                 DeleteTextAccount();
                                 txtNameAcount.ReadOnly      = false;
                                 this.btnEditAccount.Visible = false;
                                 this.btnAddAccount.Visible  = true;
                                 btnDeleteAccount.Enabled    = false;
                             }
                             else
                             {
                                 MessageBox.Show("Xóa tài khoản thất bại.", "Thông báo", MessageBoxButtons.OK);
                             }
                         }
                         else
                         {
                             MessageBox.Show("Tài khoản này đang hoạt động với hệ thống. Nên bạn không thể xóa tài khoản này khỏi hệ thống.", "Thông báo", MessageBoxButtons.OK);
                         }
                     }
                     else
                     {
                         MessageBox.Show("Bạn đã nhập sai mật khẩu, vui lòng quay lại sau.", "Thông báo", MessageBoxButtons.OK);
                     }
                 }
             }
         }
         else
         {
             MessageBox.Show("Bạn chưa chọn được tài khoản nào.", "Thông báo", MessageBoxButtons.OK);
         }
     }
     catch
     {
         MessageBox.Show("Hệ thống đang bảo trì, bạn vui lòng thử lại.", "Thông báo", MessageBoxButtons.OK);
     }
 }
Exemplo n.º 10
0
 private void frmTraPhong_Load(object sender, EventArgs e)
 {
     ThietLapButton(false);
     cmbMaPhong.DataSource = BillBUS.LayMaPhongDaThue();
     if (cmbMaPhong.SelectedValue == null)
     {
         btnThemHoaDon.Enabled = false;
     }
 }
Exemplo n.º 11
0
 private void lstSanPham_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (lstSanPham.SelectedItems.Count > 0)
     {
         DrinkDTO drink = lstSanPham.SelectedItems[0].Tag as DrinkDTO;
         // Them qua ListView
         //kiểm tra đã chọn bàn hay chưa
         try
         {
             if (choseTable != null)
             {
                 if ((objTable as Button).Tag != null)
                 {
                     Button btnTable = (objTable as Button);
                     //tag cái bàn đang chọn vào
                     TableDTO table   = (objTable as Button).Tag as TableDTO;
                     int      idTable = table.ID;
                     if (TableBUS.GetStatusByIDTable(idTable) == 0)
                     {
                         DialogResult kq = MessageBox.Show("Bạn đang chọn bàn mới.\n Bạn có muốn tạo hóa đơn mới cho bàn này chứ?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                         if (kq == DialogResult.OK)
                         {
                             btnThanhToan.Enabled = true;
                             btnTamTinh.Enabled   = true;
                             lstBill.Tag          = (choseTable as Button).Tag;
                             //ShowBill(idTable);
                             // Cap nhat trang thai bàn
                             TableBUS.UpdateStatusTable(1, idTable);
                             // Tao hóa đơn mới ở đây.
                             BillBUS.InsertBill(DateTime.Now, 0, Program.sAccount.ID, idTable);
                             txtHD.Text    = "HD00" + (string)BillBUS.GetIDBillNoPaymentByIDTable((int)idTable).ToString();
                             btnTable.Text = table.NameTable + Environment.NewLine + "Có";
                         }
                         else
                         {
                             lstBill.Items.Clear();
                             btnThanhToan.Enabled   = false;
                             btnTamTinh.Enabled     = false;
                             cbLoaiThucUong.Enabled = false;
                             txtHD.Text             = "";
                         }
                     }
                     table = CreateAddBillByIDTable(drink);
                     ShowBill(table.ID);
                 }
             }
             else
             {
                 MessageBox.Show("Bạn chưa chọn bàn để thêm thức uống. Vui lòng chọn bàn để tiếp tục!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Question);
             }
         }
         catch
         {
             MessageBox.Show("Hệ thống đang bảo trì, bạn quay lại sau nhé!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Question);
         }
     }
 }
Exemplo n.º 12
0
        private void btnCreateBill_Click(object sender, EventArgs e)
        {
            currentBillId = BillBUS.InsertBill(DateTime.Now, 0, Program.sAccount.ID);
            txtHD.Text    = "HD00" + currentBillId;
            //btnCreateBill.Enabled = false;
            btnLamMoi.Enabled = false;

            LoadListBillNoPayment();
        }
Exemplo n.º 13
0
        private BillDTO LayThongTinKhachHangThanhToan()
        {
            BillDTO infor = new BillDTO();

            infor.MaHoaDon     = BillBUS.LayMaHDCuoiCung();
            infor.MaHoaDon     = infor.MaHoaDon + 1;
            infor.TenKhachHang = txtTenKhachHang.Text;
            infor.TongTien     = Convert.ToDecimal(txtTongTien.Text.Replace(" VNĐ", String.Empty));
            //infor.MaPhong
            return(infor);
        }
Exemplo n.º 14
0
        private void pageNumberTextBox_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
                if (pageNumberTextBox.Text == string.Empty || !pageNumberTextBox.Text.All(char.IsDigit))
                {
                    pageNumberTextBox.Text = currentPageNumber.ToString();
                }
                else
                {
                    truocTile.Visible = true;
                    sauTile.Visible   = true;
                    int result;

                    if (int.TryParse(pageNumberTextBox.Text, out result))
                    {
                        if (result < 1)
                        {
                            pageNumberTextBox.Text = 1.ToString();
                        }

                        if (result > maxPageNumber)
                        {
                            pageNumberTextBox.Text = maxPageNumber.ToString();
                        }
                    }
                    else
                    {
                        pageNumberTextBox.Text = currentPageNumber.ToString();
                    }

                    currentPageNumber = int.Parse(pageNumberTextBox.Text);

                    if (currentPageNumber == 1)
                    {
                        truocTile.Visible = false;
                    }

                    if (currentPageNumber == maxPageNumber)
                    {
                        sauTile.Visible = false;
                    }

                    if (filterByTime.Checked)
                    {
                        dgv3.DataSource = BillBUS.LoadAllByTime(currentPageNumber, int.Parse(billsPerPageComboBox.Text), tuDateTime.Value, denDateTime.Value);
                    }
                    else
                    {
                        dgv3.DataSource = BillBUS.LoadAll(currentPageNumber, int.Parse(billsPerPageComboBox.Text));
                    }
                }
            }
        }
Exemplo n.º 15
0
        private void btnCancelBill_Click(object sender, EventArgs e)
        {
            if (currentBillId <= 0)
            {
                return;
            }

            BillBUS.DeleteBill(currentBillId);

            currentBillId         = -1;
            btnCreateBill.Enabled = true;
            btnLamMoi.Enabled     = true;
            btnLamMoi_Click(sender, e);
        }
Exemplo n.º 16
0
        private void lstBill_MouseClick(object sender, MouseEventArgs e)
        {
            TableDTO table = ((Button)objTable).Tag as TableDTO;

            int idBill = BillBUS.GetIDBillNoPaymentByIDTable(table.ID);

            if (lstBill.SelectedItems.Count > 0)
            {
                MenuDTO order = (MenuDTO)lstBill.SelectedItems[0].Tag as MenuDTO;

                frm_ThongTinChiTietSanPham de = new frm_ThongTinChiTietSanPham(table.ID, idBill, order.IdDrink, Convert.ToInt32(order.Quantity) + 1);
                de.lblDrinkName.Text = order.NameDrink;
                if (order.PriceBasic == 0)
                {
                    de.lblPrice.Text = "Miễn phí";
                }
                else
                {
                    de.lblPrice.Text = String.Format("{0:0,0}", order.PriceBasic);
                }
                de.cbQuantity.SelectedIndex = Convert.ToInt32(order.Quantity) - 1;
                if (order.TotalPrice == 0)
                {
                    de.lblTotal.Text = "Miễn phí";
                }
                else
                {
                    de.lblTotal.Text = String.Format("{0:0,0}", order.TotalPrice);
                }
                DialogResult kq = de.ShowDialog();
                if (kq == DialogResult.OK)
                {
                    DetailBillBUS.InsertDetailBill(idBill, order.ID, de.cbQuantity.SelectedIndex + 1);
                    ShowBill(table.ID);
                }
                else if (kq == DialogResult.Yes)
                {
                    ShowBill(table.ID);
                    Button btnTable = ((Button)objTable);
                    btnTable.Text = table.NameTable + Environment.NewLine + "Trống";
                    if (!BUS.DetailBillBUS.IsEmpty(idBill))
                    {
                        btnTamTinh.Enabled   = false;
                        btnThanhToan.Enabled = false;
                        txttotalPrice.Text   = "";
                        txtHD.Text           = "";
                    }
                }
            }
        }
Exemplo n.º 17
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult kq = MessageBox.Show("Bạn có muốn xóa sản phẩm này không?", "Thông báo", MessageBoxButtons.OKCancel);

            if (kq != DialogResult.Cancel)
            {
                DetailBillBUS.DeleteOneProduct(idBill, idProduct);

                if (DetailBillBUS.IsEmpty(idBill))
                {
                    return;
                }

                BillBUS.DeleteBill(idBill);
            }
        }
Exemplo n.º 18
0
        public Manage()
        {
            InitializeComponent();
            sorter = new ListViewColumnSorter();
            lvCatalog.ListViewItemSorter = sorter;
            lvCombo.ListViewItemSorter   = sorter;
            lvProduct.ListViewItemSorter = sorter;
            lvBill.ListViewItemSorter    = sorter;

            accountBUS     = new AccountBUS();
            billBUS        = new BillBUS();
            billDetailBUS  = new BillDetailBUS();
            catalogBUS     = new CatalogBUS();
            comboBUS       = new ComboBUS();
            comboDetailBUS = new ComboDetailBUS();
            productBUS     = new ProductBUS();
        }
Exemplo n.º 19
0
        private void namRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            if (namRadioButton.Checked)
            {
                thangComboBox.Visible        = false;
                thangLabel.Visible           = false;
                namComboBox.Visible          = false;
                namLabel.Visible             = false;
                doanhThuChart.Series[0].Name = "Doanh thu năm";
                doanhThuChart.Series[0].Points.Clear();

                for (int year = minYear; year <= maxYear; year++)
                {
                    doanhThuChart.Series["Doanh thu năm"].Points.AddXY(year, BillBUS.GetTotalByYear(year));
                }
            }
        }
Exemplo n.º 20
0
        private void thangRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            if (thangRadioButton.Checked)
            {
                thangComboBox.Visible        = false;
                thangLabel.Visible           = false;
                namComboBox.Visible          = true;
                namLabel.Visible             = true;
                doanhThuChart.Series[0].Name = "Doanh thu tháng";
                doanhThuChart.Series[0].Points.Clear();
                int year = int.Parse(namComboBox.Text);

                for (int month = 1; month <= 12; month++)
                {
                    doanhThuChart.Series["Doanh thu tháng"].Points.AddXY(month, BillBUS.GetTotalByMonth(month, year));
                }
            }
        }
Exemplo n.º 21
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                TableDTO table  = lstBill.Tag as TableDTO;
                int      idBill = BillBUS.GetIDBillNoPaymentByIDTable(table.ID);

                rptThanhToan frm_TToan = new rptThanhToan();
                DateTime     Time      = DateTime.Now;
                frm_TToan.XuatHoaDon(idBill, "HÓA ĐƠN TẠM TÍNH", "Bàn số " + table.ID, Program.sAccount.Name, Time, string.Format("{0:0,0}", txttotalPrice.Text), "0", "0", true);
                //
                frm_TToan.ShowDialog();
            }
            catch
            {
                MessageBox.Show("Hệ thống đang bảo trì, thử lại.");
            }
        }
        private void btnXuatHD_Click(object sender, EventArgs e)
        {
            var promotion = string.IsNullOrEmpty(txtPromotion.Text) ? 0 : Convert.ToDouble(txtPromotion.Text);
            var tongtien  = string.IsNullOrEmpty(_tongTien) ? 0 : Convert.ToDouble(_tongTien);
            var thanhtien = tongtien - promotion;

            if (!txtSTK.Text.Equals(""))
            {
                if (promotion > tongtien)
                {
                    MessageBox.Show("Vui lòng nhập số tiền giảm thấp hơn tổng giá trị hóa đơn.");
                    return;
                }

                if (Convert.ToDouble(txtSTK.Text) < thanhtien)
                {
                    MessageBox.Show("Hệ thống không cho phép khách hàng nợ, mong bạn thông cảm nhắc khách hàng thanh toán đúng số tiền trong hóa đơn.");
                }
                else
                {
                    DialogResult kq = MessageBox.Show("Bạn có muốn thanh toán hay không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (kq != DialogResult.No)
                    {
                        rpt_ThanhToan rptThanhToan = new rpt_ThanhToan();
                        DateTime      Time         = DateTime.Now;
                        rptThanhToan.XuatHoaDon(_maHD, _tenHD, _maHD.ToString(), Program.sAccount.Name, Time, _tongTien, txtPromotion.Text, txtSTK.Text, txtTienTon.Text, thanhtien.ToString(), true);

                        rptThanhToan.ShowDialog();
                        BillBUS.UpdatetBill(_maHD, tongtien, promotion, Convert.ToDouble(txtSTK.Text), Convert.ToDouble(txtTienTon.Text), thanhtien, Time, Program.sAccount.ID);

                        _ketQua = true;
                        Close();
                    }
                    else
                    {
                        _ketQua = false;
                    }
                }
            }
            else
            {
                MessageBox.Show("Nhập tiền khách cần thanh toán cho hóa đơn này!");
            }
        }
Exemplo n.º 23
0
        private BillDTO ThongTinHoaDonThanhToan(int i)
        {
            BillDTO infor   = new BillDTO();
            int     maphong = int.Parse(dgvHoaDon.Rows[i].Cells["colMaPhong"].Value.ToString());

            //tai sao la null
            //int maphong = int.Parse(cmbMaPhong.SelectedIndex.ToString());

            infor.MaPhong = maphong;
            List <BillDTO> lst = new List <BillDTO>();

            lst = BillBUS.LayMaPhieuThue(maphong);
            infor.MaPhieuThue   = lst[0].MaPhieuThue.Value;
            infor.SoNgayDaThue  = int.Parse(dgvHoaDon.Rows[i].Cells["colSoNgayThue"].Value.ToString());
            infor.DonGia        = Convert.ToDecimal(dgvHoaDon.Rows[i].Cells["colDonGia"].Value.ToString());
            infor.ThanhTien     = Convert.ToDecimal(dgvHoaDon.Rows[i].Cells["colThanhTien"].Value.ToString());
            infor.NgayThanhToan = Convert.ToDateTime(dtpNgayThanhToan.Text);
            return(infor);
        }
Exemplo n.º 24
0
        private void denDateTime_ValueChanged(object sender, EventArgs e)
        {
            currentPageNumber       = 1;
            pageNumberTextBox.Text  = currentPageNumber.ToString();
            maxPageNumber           = BillBUS.GetMaxPageNumberByTime(int.Parse(billsPerPageComboBox.Text), tuDateTime.Value, denDateTime.Value);
            maxPageNumberLabel.Text = "/ " + maxPageNumber;
            dgv3.DataSource         = BillBUS.LoadAllByTime(currentPageNumber, int.Parse(billsPerPageComboBox.Text), tuDateTime.Value, denDateTime.Value);

            truocTile.Visible = false;

            if (maxPageNumber == 1)
            {
                sauTile.Visible = false;
            }
            else
            {
                sauTile.Visible = true;
            }
        }
Exemplo n.º 25
0
        private void LoadListBillNoPayment()
        {
            var list = BillBUS.GetAllBillNoPament();

            lstBillNoPayment.Items.Clear();
            int i = 0;

            foreach (var item in list)
            {
                ListViewItem listitem = new ListViewItem
                {
                    Text = "#" + (i + 1).ToString()
                };

                listitem.SubItems.Add(item.ToString());
                listitem.Tag = item;
                lstBillNoPayment.Items.Add(listitem);
                i++;
            }
        }
Exemplo n.º 26
0
        private void ngayRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            if (ngayRadioButton.Checked)
            {
                thangComboBox.Visible        = true;
                thangLabel.Visible           = true;
                namComboBox.Visible          = true;
                namLabel.Visible             = true;
                doanhThuChart.Series[0].Name = "Doanh thu ngày";
                doanhThuChart.Series[0].Points.Clear();
                int month       = int.Parse(thangComboBox.Text);
                int year        = int.Parse(namComboBox.Text);
                int daysInMonth = DateTime.DaysInMonth(year, month);

                for (int day = 1; day <= daysInMonth; day++)
                {
                    doanhThuChart.Series["Doanh thu ngày"].Points.AddXY(day, BillBUS.GetTotalByDay(day, month, year));
                }
            }
        }
Exemplo n.º 27
0
        private void sauTile_Click(object sender, EventArgs e)
        {
            truocTile.Visible = true;
            currentPageNumber++;
            pageNumberTextBox.Text = currentPageNumber.ToString();

            if (filterByTime.Checked)
            {
                dgv3.DataSource = BillBUS.LoadAllByTime(currentPageNumber, int.Parse(billsPerPageComboBox.Text), tuDateTime.Value, denDateTime.Value);
            }
            else
            {
                dgv3.DataSource = BillBUS.LoadAll(currentPageNumber, int.Parse(billsPerPageComboBox.Text));
            }

            if (currentPageNumber == maxPageNumber)
            {
                sauTile.Visible = false;
            }
        }
        //
        //---- EVENTS
        //
        #region Events
        private void BtCheckIn_Click(object sender, EventArgs e)
        {
            TimeSpan a = dtCheckOut.Value.Subtract(dtCheckIn.Value);
            decimal  x = a.Days + 1;
            decimal  y = Decimal.Parse(lbCost.Text) * x;

            bllBUS = new BillBUS();
            BillDTO bll = new BillDTO();

            bll.IDB      = lbNameCustomer.Text + "/" + dtCheckIn.Text + "/" + dtCheckOut.Text + "@" + lbNameCustomer.Text;
            bll.IDC      = lbNameCustomer.Text;
            bll.IDR      = lbNameRoom.Text;
            bll.CheckIn  = DateTime.Parse(dtCheckIn.Text);
            bll.CheckOut = DateTime.Parse(dtCheckOut.Text);
            bll.COST     = Decimal.Parse(lbCost.Text) * x;
            bool kq = bllBUS.add(bll);

            if (kq == false)
            {
                MessageBox.Show("Fail!");
            }
            else
            {
                rmBUS = new RoomBUS();
                RoomDTO rm = new RoomDTO();
                rm.Idr    = lbNameRoom.Text;
                rm.Status = "Có Khách";
                bool kq1 = rmBUS.editStatus(rm);
                if (kq == false)
                {
                    MessageBox.Show("Fail!");
                }
                else
                {
                    MessageBox.Show("Sussces");
                }
            }


            this.Close();
        }
Exemplo n.º 29
0
        private void btCheckOut_Click_1(object sender, EventArgs e)
        {
            srvBUS = new RoomServiceBUS();
            RoomServiceDTO srv = new RoomServiceDTO();

            srv.IDR = lbNameRoom.Text;

            bllBus = new BillBUS();
            BillDTO bll = new BillDTO();

            bll.IDC         = lbNameCustomer.Text;
            bll.IDR         = lbNameRoom.Text;
            bll.CheckIn     = DateTime.Parse(lbCheckIn.Text);
            bll.CheckOut    = DateTime.Parse(lbCheckOut.Text);
            lbCostRoom.Text = bll.COST.ToString();
            bll.COST        = Decimal.Parse(lbCostRoom.Text);
            bool kq = bllBus.editCost(bll);

            if (kq == false)
            {
                MessageBox.Show("Fail!");
            }
            else
            {
                rmBUS = new RoomBUS();
                RoomDTO rm = new RoomDTO();
                rm.Idr    = lbNameRoom.Text;
                rm.Status = "Trống";
                bool kq1 = rmBUS.editStatus(rm);
                if (kq == false)
                {
                    MessageBox.Show("Fail!");
                }
                else
                {
                    MessageBox.Show("Sussces");
                }
            }
            this.Close();
        }
        private void btnXuatHD_Click(object sender, EventArgs e)
        {
            if (txtSTK.Text != "")
            {
                _TongTien = _TongTien.Replace(",", "").ToString();
                if (Convert.ToInt32(txtSTK.Text) < Convert.ToInt32(_TongTien))
                {
                    MessageBox.Show("Hệ thống không cho phép khách hàng nợ, mong bạn thông cảm nhắc khách hàng thanh toán đúng số tiền trong hóa đơn.");
                }
                else
                {
                    DialogResult kq = MessageBox.Show("Bạn có muốn thanh toán hay không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (kq != DialogResult.No)
                    {
                        //
                        // Hiển thị report
                        rptThanhToan rptThanhToan = new rptThanhToan();
                        DateTime     Time         = DateTime.Now;
                        rptThanhToan.XuatHoaDon(_MaHD, _TenHD, "Bàn số " + _MaBan, Program.sAccount.Name, Time, _TongTien, txtSTK.Text, txtTienTon.Text, true);
                        //
                        rptThanhToan.ShowDialog();
                        BillBUS.UpdatetBill(_MaHD, Convert.ToDouble(_TongTien.ToString()), Time, Program.sAccount.ID);
                        TableBUS.UpdateStatusTable(0, _MaBan); // Cập nhật da

                        _KetQua = true;
                        this.Close();
                    }
                    else
                    {
                        _KetQua = false;
                    }
                }
            }
            else
            {
                MessageBox.Show("Nhập tiền khách cần thanh toán cho hóa đơn này!");
            }
        }