Пример #1
0
        public void inHoaDon(HoaDonRP hd, List <CTHoaDonReport> cthd)
        {
            ReportHoaDon rp = new ReportHoaDon();

            foreach (DevExpress.XtraReports.Parameters.Parameter p in rp.Parameters)
            {
                p.Visible = false;
            }

            rp.initData(hd.MaBan, hd.TienBan, hd.TienChuyenBan, hd.TongTien, hd.TienThanhToan, hd.ConNo, hd.GioVao.ToString(), hd.GioRa.ToString(), hd.MaHD, hd.MaNV, hd.NgayLap.ToString(), cthd);
            documentViewer1.DocumentSource = rp;
            rp.CreateDocument();
        }
Пример #2
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (btnLuu.Text == "Thanh toán") //lưu hóa đơn
            {
                if (txtThanhToan.Text == "")
                {
                    MessageBox.Show("Hãy nhập số tiền khách thanh toán !!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    txtThanhToan.Focus();
                }
                else //nhập tiền thanh toán mới cho thanh toán
                {
                    string mahd = "";
                    timerDem.Stop();
                    HOADON hd = new HOADON();
                    mahd    = "HD" + XuLy.TaoMaRandom.taoMaRandom();
                    hd.MaHD = mahd;
                    hd.MaNV = hoadon_bll.layMaNV(tendn);
                    //hd.MaKH = makhach; //thêm khách hàng trước

                    hd.TienBan = tienban;
                    hd.MaBan   = maban;
                    hd.NgayLap = DateTime.Now.Date;

                    hd.GioDatBan = giovao;
                    hd.GioTraBan = giora;
                    hd.TGChoi    = String.Format("{0:hh\\:mm\\:ss}", tgchoi);
                    MessageBox.Show("Thời gian khách chơi là: " + tgchoi.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    hoadon_bll.themHoaDon(hd);
                    List <CTHoaDonReport> ds = new List <CTHoaDonReport>();

                    for (int i = 0; i < dtgvCTHD.Rows.Count; i++)
                    {
                        //thêm chi tiết nhiều lần
                        float  sltemp = float.Parse(dtgvCTHD.Rows[i].Cells["SL"].Value.ToString());
                        float  dgtemp = float.Parse(dtgvCTHD.Rows[i].Cells["DG"].Value.ToString());
                        string mahang = dtgvCTHD.Rows[i].Cells["MaHang"].Value.ToString();

                        hanghoa_bll.capNhatSLTonHH(mahang, sltemp); //trừ đi số lượng của mặt hàng đó

                        CT_HOADON cthd = new CT_HOADON();
                        cthd.MaHD       = mahd;
                        cthd.MaHang     = mahang;
                        cthd.DonGiaBan  = dgtemp;
                        cthd.SoLuongBan = sltemp;
                        cthd.ThanhTien  = sltemp * dgtemp;

                        CTHoaDonReport cthdrp = new CTHoaDonReport();
                        cthdrp.TenHang   = hanghoa_bll.layTenHang(mahang);
                        cthdrp.DonGia    = dgtemp;
                        cthdrp.SoLuong   = sltemp;
                        cthdrp.DonViTinh = hanghoa_bll.layDonViTinh(mahang);
                        cthdrp.ThanhTien = sltemp * dgtemp;

                        ds.Add(cthdrp);

                        hoadon_bll.themCTHD(cthd);
                    }

                    float thueVAT   = float.Parse(txtThue.Text);
                    float tiendv    = float.Parse(txtDichVu.Text);
                    float tonggt    = float.Parse(txtChuyenBan.Text) + float.Parse(txtDichVu.Text) + float.Parse(txtTienBan.Text) + tienchuyenban;
                    float thanhtien = float.Parse(txtThanhTien.Text);
                    float tienno    = float.Parse(txtTienNo.Text);

                    if (hoadon_bll.capnhatHDBan(mahd, tienchuyenban, tiendv, thueVAT, tonggt, thanhtien, tienno))
                    {
                        MessageBox.Show("Thanh toán của " + txtTenBan.Text + " thành công !!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        clearDGVGioHang();
                        ban.capNhatTrangThai(maban, "Đang dọn dẹp");
                        loadTheoTen(TenHang);

                        //đã thanh toán rồi thì xóa tạm tính của bàn đó
                        xoaCTTT(matamtinh);
                        tamtinh_bll.xoaTamTinh(matamtinh);

                        check = 1;

                        //in hóa đơn
                        FromInHoaDon frm  = new FromInHoaDon();
                        HoaDonRP     hdrp = new HoaDonRP();
                        hdrp.MaHD          = mahd;
                        hdrp.MaNV          = hoadon_bll.layMaNV(tendn);
                        hdrp.MaBan         = maban;
                        hdrp.GioVao        = giovao;
                        hdrp.GioRa         = giora;
                        hdrp.NgayLap       = String.Format("{0:M/d/yyyy}", DateTime.Now);
                        hdrp.TienBan       = tienban;
                        hdrp.TienChuyenBan = tienchuyenban;
                        hdrp.TongTien      = thanhtien;
                        hdrp.TienThanhToan = float.Parse(txtThanhToan.Text);
                        hdrp.ConNo         = tienno;

                        MessageBox.Show("Hãy chờ hóa đơn được in", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        frm.inHoaDon(hdrp, ds);
                        frm.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Thanh toán thất bại !!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    }
                }
            }
            else //lưu vào tạm tính
            {
                luuTamTinh();
            }
        }