예제 #1
0
        private void btn_ThanhToan_Click_2(object sender, EventArgs e)
        {
            int     makh     = int.Parse(cb_KhachHang.SelectedValue.ToString());
            int     manv     = int.Parse(cb_NVban.SelectedValue.ToString());
            int     malohang = LoHangModels.chucVu.getMaLoHang(int.Parse(cb_LoaiSanPham.SelectedValue.ToString()));
            DonHang a        = new DonHang();

            a.MaNV     = manv;
            a.MaKH     = makh;
            a.MaLoHang = malohang;
            a.SoLuong  = soluongss;
            bool check = DonHangModels.DonHangCons.ThemDonHang(a);

            if (check == true)
            {
                foreach (CTDonHang item in listCT)
                {
                    item.MaDonHang = DonHangModels.DonHangCons.getLastMa();
                    CTDonHangModels.CTDonHangCons.Them(item);
                }
                MessageBox.Show("Thêm đơn hàng thành công");
                dataGridView1.DataSource = null;
                txt_SoLuong = null;
                string query1 = "SELECT KhachHang.TenKH,SanPham.TenSanPham,DonHang.TongTien,DonHang.SoLuong,DonHang.NgayMua,CTSanPham.ChatLieu,CTSanPham.KichCo,CTSanPham.MaSac,CTDonHang.TongTien,CTDonHang.GiaTien,CTDonHang.SoLuong " +
                                "FROM SanPham, DonHang, CTDonHang, KhachHang, CTSanPham " +
                                "where SanPham.MaSp = CTSanPham.MaSp and KhachHang.MaKH = DonHang.MaKH and CTSanPham.MaCTSp = CTDonHang.MaCTSp and DonHang.MaDonHang = CTDonHang.MaDonHang " +
                                "and DonHang.MaDonHang = '" + DonHangModels.DonHangCons.getLastMa() + "'";
                CRp_DonHang sp = new CRp_DonHang();
                sp.SetDataSource(Dataset.DaTa.report(query1));
                RpForm_DonHang f = new RpForm_DonHang();
                f.crystalReportViewer1.ReportSource = sp;
                f.ShowDialog();
            }
        }
예제 #2
0
        private void btn_XuatEx_Click(object sender, EventArgs e)
        {
            string query = "SELECT DonHang.MaDonHang,DonHang.NgayMua,DonHang.SoLuong,DonHang.TongTien,DonHang.MaLoHang,NhanVien.TenNV,KhachHang.TenKH " +
                           "FROM DonHang,KhachHang,NhanVien " +
                           "WHERE DonHang.MaKH = KhachHang.MaKH and NhanVien.MaNV = DonHang.MaNV";
            CRp_DsDonHang sp = new CRp_DsDonHang();

            sp.SetDataSource(Dataset.DaTa.report(query));
            RpForm_DonHang f = new RpForm_DonHang();

            f.crystalReportViewer1.ReportSource = sp;
            f.ShowDialog();
        }