コード例 #1
0
        public ActionResult ThanhToan(string Ten, string diachi, string sdt, string email, string ghichu)
        {
            var hoadon = new HoaDon();

            hoadon.TenKhachHang = Ten;
            hoadon.DiaChi       = diachi;
            hoadon.SDT          = sdt;
            hoadon.Gmail        = email;
            hoadon.GhiChu       = ghichu;
            hoadon.NgayTao      = DateTime.Now;
            hoadon.TrangThai    = true;
            decimal?gia     = 0;
            int     id      = new HoaDonDAO().Insert(hoadon);
            var     giohang = (List <Giohang>)Session[GioHangSession];
            var     dao     = new ChiTietHoaDonDAO();

            foreach (var item in giohang)
            {
                var cthoadon = new ChiTietHoaDon();
                cthoadon.ID        = id;
                cthoadon.IDSanPham = item.SanPham.ID;
                cthoadon.SoLuong   = item.SoLuong;
                if (item.SanPham.GiaKhuyenMai != null)
                {
                    cthoadon.Gia = item.SanPham.GiaKhuyenMai;
                }
                else
                {
                    cthoadon.Gia = item.SanPham.Gia;
                }
                dao.Insert(cthoadon);
            }
            string content = System.IO.File.ReadAllText(Server.MapPath("~/assets/client/template/neworder.html"));

            content = content.Replace("{{CustomerName}}", Ten);
            content = content.Replace("{{Phone}}", sdt);
            content = content.Replace("{{Email}}", email);
            content = content.Replace("{{Address}}", diachi);

            var toEmail = ConfigurationManager.AppSettings["ToEmailAddress"].ToString();

            new GuiMail().SendMail(email, "MobileShop đã nhận đơn hàng của bạn", content);
            new GuiMail().SendMail(toEmail, " Đơn hàng mới từ MobileShop ", content);

            Session.Remove("GioHangSession");

            return(View("Success"));
        }
コード例 #2
0
 public void Insert(ChiTietHoaDon info)
 {
     data.Insert(info);
 }
コード例 #3
0
 public int Insert(ChiTietHoaDon obj)
 {
     return(dao.Insert(obj));
 }