public ActionResult Create(FormCollection collection)
        {
            Session.Add("ActiveClass", "QuanLyQuangCaoCreate");

            if (Session["ID"] != null)
            {
            try
            {
                var model = new dangQuangCao();
                if (TryUpdateModel(model))
                {
                    // TODO: Add insert logic here
                    model.noiDungQuangCao = collection["noiDungQuangCao"];
                    model.Mobile =  collection["Mobile"];
                    model.website = collection["website"];
                    model.thoiGianDang = int.Parse(collection["thoiGianDang"]);
                    model.ngayTuanThangNam_ID = int.Parse(collection["ngayTuanThangNam_ID"]);

                    IFormatProvider provider = new System.Globalization.CultureInfo("en-CA", true);
                    String datetime = collection["ngayBatDau"];
                    DateTime dt = DateTime.Parse(datetime, provider, System.Globalization.DateTimeStyles.NoCurrentDateDefault);
                    model.ngayBatDau = dt;
                    model.viTri_ID = int.Parse(collection["ViTri_ID"]);
                    model.HinhThuc = collection["HinhThuc"];
                    model.hinhAnh = collection["hinhAnh"];
                    model.IsDeleted = false;
                    model.NgayTao = DateTime.Now;
                    //tinh tong gia
                    viTriBanner tongTien = DQCRes.GetGiaVitriBannerByViTriAndNgay(int.Parse(collection["ViTri_ID"]), int.Parse(collection["ngayTuanThangNam_ID"]));
                    model.trangThai = "ChuaDuyet";
                    model.tongTien = float.Parse(tongTien.gia.ToString()) * float.Parse(collection["thoiGianDang"]);
                    model.account_ID = Session["ID"] == null ? 1 : int.Parse(Session["ID"].ToString());
                    DQCRes.Add(model);
                    DQCRes.Save();
                    return RedirectToAction("Details", new { id = model.ID });
                }
                else
                {
                    ViewData["ViTriDangQuangCao"] = CMRes.FindAllViTriDangQuangCao();
                    ViewData["NgayThangNam"] = GiaModuleRes.FindAllngayTuanThangNam();
                    return View();
                }

            }
            catch
            {
                ViewData["ViTriDangQuangCao"] = CMRes.FindAllViTriDangQuangCao();
                ViewData["NgayThangNam"] = GiaModuleRes.FindAllngayTuanThangNam();
                return View();
            }
            }
            else
            {
                Session.Add("UrlRedirect", Url.AbsoluteAction("Create", "dangQuangCao"));
                return RedirectToAction("LogOn", "Account");
            }
        }
 //
 // GET: /dangQuangCao/Create
 public ActionResult Create()
 {
     if (Session["ID"] != null)
     {
         var model = new dangQuangCao();
        // ViewData["test"] = System.Web.Configuration.WebConfigurationManager
         ViewData["NgayThangNam"] = GiaModuleRes.FindAllngayTuanThangNam();
         ViewData["ViTriDangQuangCao"] = CMRes.FindAllViTriDangQuangCao();
         return View(model);
     }
     else
     {
         Session.Add("UrlRedirect", Url.AbsoluteAction("Create", "dangQuangCao"));
         return RedirectToAction("LogOn", "Account");
     }
 }
Beispiel #3
0
 public void Delete(dangQuangCao dm)
 {
     en.DeleteObject(dm);
 }
Beispiel #4
0
 public void Add(dangQuangCao dm)
 {
     /*  var q = (from p in en.CouPon select p).Max();
       dm.ID = q + 1;*/
     en.AddObject("dangQuangCao", dm);
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the dangQuangCaos EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTodangQuangCaos(dangQuangCao dangQuangCao)
 {
     base.AddObject("dangQuangCaos", dangQuangCao);
 }
 /// <summary>
 /// Create a new dangQuangCao object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="account_ID">Initial value of the account_ID property.</param>
 public static dangQuangCao CreatedangQuangCao(global::System.Decimal id, global::System.Decimal account_ID)
 {
     dangQuangCao dangQuangCao = new dangQuangCao();
     dangQuangCao.ID = id;
     dangQuangCao.account_ID = account_ID;
     return dangQuangCao;
 }