Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int madn = int.Parse(Session["MaDN"].ToString());
            if (int.Parse(Session["IsLogin"].ToString()) == 1)
            {
                if (!Page.IsPostBack)
                {
                    VoucherDAO vDAO = new VoucherDAO();
                    List<VoucherDTO> lstVoucher = new List<VoucherDTO>();
                    lstVoucher = VoucherBUS.SelectVoucher_DoanhNghiep(madn);

                    ChiTietDonHangDAO ctDAO = new ChiTietDonHangDAO();
                    List<ChiTietDonHangDTO> lstCT = new List<ChiTietDonHangDTO>();
                    lstCT = ctDAO.SelectAllChiTietDonHang();

                    List<VoucherDTO> lstVoucherddl = new List<VoucherDTO>();

                    for (int i = 0; i < lstVoucher.Count; i++)
                        for (int j = 0; j < lstCT.Count; j++)
                            if (lstVoucher[i].MAVOUCHER1 == lstCT[j].VOUCHERDH1)
                                lstVoucherddl.Add(lstVoucher[i]);

                    ddlVoucherList.DataSource = lstVoucherddl;
                    ddlVoucherList.DataTextField = "TENVOUCHER1";
                    ddlVoucherList.DataValueField = "MAVOUCHER1";
                    ddlVoucherList.DataBind();
                }
            }
        }
Exemplo n.º 2
0
        public ActionResult ThongTinKhachHang(string txtName, string txtPhone, string txtAddress, string txtEmail)
        {
            //Tạo và lấy thông tin của order
            var        od   = new DONHANG();
            DonHangDAO ODAO = new DonHangDAO();

            long idorder = 0;

            od.NgayTao            = DateTime.Now;
            od.TenKhachHang       = txtName;
            od.DiaChiKhachHang    = txtAddress;
            od.DienThoaiKhachHang = txtPhone;
            od.EmailKhachHang     = txtEmail;
            od.TrangThai          = 0;
            try
            {
                idorder = ODAO.Insert(od);
                //Thêm order vào chi tiết
                var list = (List <CartItem>)Session[CartSession];;
                if (list != null)
                {
                    foreach (var item in list)
                    {
                        CHITIETDONHANG od1 = new CHITIETDONHANG();
                        CoDAO          ccc = new CoDAO();



                        od1.IDDonHang = idorder;
                        od1.IDCo      = ccc.LayIDCoGiayTheoIDSPVaCo(item.Product.ID, item.CoGiay);
                        od1.SoLuong   = item.Quantity;
                        int giatien = 0;
                        if (item.Product.GiaKhuyenMai != null && item.Product.GiaKhuyenMai > 0)
                        {
                            giatien = (int.Parse(item.Product.GiaKhuyenMai.Value.ToString()) * item.Quantity);
                        }
                        else
                        {
                            giatien = (int.Parse(item.Product.Gia.Value.ToString()) * item.Quantity);
                        }
                        od1.Gia = giatien;
                        ChiTietDonHangDAO ODDAO = new ChiTietDonHangDAO();
                        ODDAO.Add(od1);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(Redirect("/GioHang/XemLaiDonHang?idorder=" + idorder + ""));
        }
Exemplo n.º 3
0
        public ActionResult XuatDonHang(long id)
        {
            var dao  = new DonHangDAO();
            var dao1 = new ChiTietDonHangDAO();

            //Thay đổi trạng thái đơn hàng thành 1 - Xuất đơn hàng
            dao.XuatDongHang(id);
            //Trừ số lượng các sản phẩm trong đơn hàng được xuất

            //Lấy danh sách chi tiết đơn hàng trong chi tiết theo ID của đơn hàng
            var listOrder = dao1.GetListByIDOrder(id);

            //Với mỗi chi tiết đơn hàng, trừ số lượng bảng cỡ theo ID SP và cỡ
            foreach (var item in listOrder)
            {
                var xdao = new ChiTietDonHangDAO();
                xdao.TruSoLuongCoGiayDonHangXuat(long.Parse(item.IDCo.ToString()), int.Parse(item.SoLuong.ToString()));
            }

            return(RedirectToAction("DonHangDaXuat", "QuanLyDonHang"));
        }
Exemplo n.º 4
0
        public ActionResult ChiTiet(long id)
        {
            var dao      = new ChiTietDonHangDAO();
            var dao1     = new DonHangDAO();
            int?tongtien = 0;
            //Lấy danh sách chi tiết đơn hàng trong chi tiết theo ID của đơn hàng
            var listOrder = dao.GetListByIDOrder(id);

            //Lấy ra thông tin khách hàng
            ViewBag.vbcs = dao1.ViewByID(id);


            //lấy danh sách sản phẩm trong đơn hàng đó
            List <OrderViewModel> lpr = new List <OrderViewModel>();

            foreach (var item in listOrder)
            {
                var od = new OrderViewModel();
                var pr = new SanPhamDAO().getInfoByIDCo(long.Parse(item.IDCo.ToString()));

                //LẤy cỡ giày của bản ghi theo ID cỡ
                string cogiayxxx = new CoDAO().ViewByID(long.Parse(item.IDCo.ToString())).Co.ToString();
                od.productAvatar    = pr.AnhDaiDien;
                od.productID        = pr.ID;
                od.productMetatitle = pr.Metatitle;
                od.productName      = pr.TenSP;
                od.cogiay           = int.Parse(cogiayxxx);
                od.productPrice     = int.Parse(item.Gia.Value.ToString()) / item.SoLuong;
                od.productQuantity  = item.SoLuong;
                tongtien            = int.Parse(item.Gia.Value.ToString());
                lpr.Add(od);
            }
            ViewBag.vb_tongtien = tongtien;

            return(View(lpr));
        }
Exemplo n.º 5
0
 public static List <ChiTietDonHangDTO> SelectChiTietDonHangAll()
 {
     return(ChiTietDonHangDAO.SelectChiTietDonHangAll());
 }
Exemplo n.º 6
0
 public DataTable LaySanPham(int maDh, string maSp)
 {
     return(ChiTietDonHangDAO.LaySanPham(maDh, maSp));
 }
Exemplo n.º 7
0
 public bool Delete(int maCtdh)
 {
     return(ChiTietDonHangDAO.Delete(maCtdh));
 }
Exemplo n.º 8
0
 public ChiTietDonHangDTO KiemTraTonTai(int maDH, string maSP)
 {
     return(ChiTietDonHangDAO.KiemTraTonTai(maDH, maSP));
 }
Exemplo n.º 9
0
 public void Update(ChiTietDonHangDTO ctdhDTO)
 {
     ChiTietDonHangDAO.Update(ctdhDTO);
 }
Exemplo n.º 10
0
 public DataTable LayDanhSachSanPham(int maDh)
 {
     return(ChiTietDonHangDAO.LayDanhSachSanPham(maDh));
 }
Exemplo n.º 11
0
 public DataTable TimKiemTheoMaDonHang(int maDh)
 {
     return(ChiTietDonHangDAO.TimKiemTheoMaDonHang(maDh));
 }
Exemplo n.º 12
0
 public void Insert(ChiTietDonHangDTO ctdh)
 {
     ChiTietDonHangDAO.Insert(ctdh);
 }
Exemplo n.º 13
0
 public static ChiTietDonHangDTO SelectChiTietDonHangById(string MaChiTietDonHang)
 {
     return(ChiTietDonHangDAO.SelectChiTietDonHangById(MaChiTietDonHang));
 }
Exemplo n.º 14
0
 public static List <ChiTietDonHangDTO> SelectChiTietDonHangByMaDonHang(string MaDonHang)
 {
     return(ChiTietDonHangDAO.SelectChiTietDonHangByMaDonHang(MaDonHang));
 }
Exemplo n.º 15
0
 public static bool DeleteChiTietDonHangById(string MaChiTietDonHang)
 {
     return(ChiTietDonHangDAO.DeleteChiTietDonHangById(MaChiTietDonHang));
 }
Exemplo n.º 16
0
 public static bool UpdateChiTietDonHangById(ChiTietDonHangDTO ctdhDTO)
 {
     return(ChiTietDonHangDAO.UpdateChiTietDonHangById(ctdhDTO));
 }
Exemplo n.º 17
0
 public static bool InsertChiTietDonHang(ChiTietDonHangDTO ctdhDTO)
 {
     return(ChiTietDonHangDAO.InsertChiTietDonHang(ctdhDTO));
 }