public ActionResult dathang() { var DAO = new DonHangDAO(); var dao1 = new SachDAO(); DonHang newDH = new DonHang(); newDH.masach = donhang.masach; newDH.mataikhoan = donhang.mataikhoan; newDH.ngaygiao = donhang.ngaygiao; newDH.tinhtrang = donhang.tinhtrang; if (donhang == null) { return(View("Index")); } DAO.Insert(newDH); dao1.SaledBook(donhang.masach); TaiKhoan tk = null; UserLogin user = (UserLogin)Session[Common.CommonConstrants.USER_SESSION]; if (user != null) { tk = db.TaiKhoans.SingleOrDefault(x => x.ma == user.ID ? true : false); } return(View("kiemtradonhang", getdonhang(tk))); }
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 + "")); }
public void Insert(DonHangDTO dh) { DonHangDAO.Insert(dh); }