Example #1
0
 public void Add(GioHang dm)
 {
     //var q = (from p in en.GiaModule select p.Gia_ID).DefaultIfEmpty().Max();
     var q = en.GioHang.Max(i => (int?)i.GioHang_ID) ?? 1;
     dm.GioHang_ID = q + 1;
     en.AddObject("GioHang", dm);
 }
Example #2
0
 public void Delete(GioHang dm)
 {
     en.DeleteObject(dm);
 }
Example #3
0
 public void Add(GioHang dm)
 {
     en.AddObject("GioHang", dm);
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the GioHangs EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToGioHangs(GioHang gioHang)
 {
     base.AddObject("GioHangs", gioHang);
 }
 /// <summary>
 /// Create a new GioHang object.
 /// </summary>
 /// <param name="gH_ID">Initial value of the GH_ID property.</param>
 public static GioHang CreateGioHang(global::System.Decimal gH_ID)
 {
     GioHang gioHang = new GioHang();
     gioHang.GH_ID = gH_ID;
     return gioHang;
 }
        public ActionResult MuaHang(FormCollection collection)
        {
            if (Session["ID"] != null)
            {
                var qlSanPham = QLSPRes.GetquanLySanPham(int.Parse(collection["QLSP_ID"]));
                if (qlSanPham != null)
                {
                    var gh = new GioHang();
                    gh.QLSP_ID = qlSanPham.QLSP_ID;
                    gh.Gia = qlSanPham.giaThamKhao;
                    gh.ThanhTien = qlSanPham.giaThamKhao * float.Parse(collection["Soluong"]);
                    gh.SoLuong = int.Parse(collection["Soluong"]);
                    gh.QLSHOP_ID = 9;
                    gh.account_ID = 1;
                    gh.accountNguoiBan_ID = qlSanPham.account_ID;

                    GHRes.Add(gh);
                    GHRes.Save();
                    return RedirectToAction("XemGioHang");
                }
                else
                {
                    return RedirectToAction("Details", new { id = int.Parse(collection["QLSP_ID"]) });
                }
            }else
            {
                return RedirectToAction("LogOn", "Account");
            }
        }