public override void BindControl() { FooterDAL dal = new FooterDAL(); var result = dal.GetFooterBySource(SourceNo, SourceType); Utility.BindDataToRepeater(rpItems, result); }
protected void rpItems_ItemCommand(object source, RepeaterCommandEventArgs e) { FooterDAL dal = new FooterDAL(); if (e.CommandName == "Add") { DropDownList ddlIntro = e.Item.FindControl("ddlIntro") as DropDownList; Footer footer = new Footer(); footer.Intro = ddlIntro.SelectedValue; footer.SourceType = SourceType; footer.SourceNo = SourceNo; dal.AddFooter(footer); dal.Save(); } if (e.CommandName == "Save") { HiddenField hdId = e.Item.FindControl("hdId") as HiddenField; TextBox txtIntro = e.Item.FindControl("txtIntro") as TextBox; var item = dal.GetFooterById(int.Parse(hdId.Value)); item.Intro = txtIntro.Text; dal.Save(); } if (e.CommandName == "Delete") { HiddenField hdId = e.Item.FindControl("hdId") as HiddenField; dal.DeleteFooterItem(int.Parse(hdId.Value)); } BindControl(); SetFocus(rpItems); }
// GET: Admin/Footers/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var footer = new FooterDAL().ViewDetail(id); if (footer == null) { return(HttpNotFound()); } return(View(footer)); }
public static void AddDefault(string sourceNo, string sourceType, string formType) { FooterDAL dal = new FooterDAL(); var defaultItems = Utility.GetLookupList(formType).Where(f => f.IsDefault == true); foreach (var item in defaultItems) { Footer footer = new Footer() { Intro = item.ConfigItem_Value, SourceNo = sourceNo, SourceType = sourceType }; dal.AddFooter(footer); } dal.Save(); }
public ActionResult Edit([Bind(Include = "FooterID,Content,DisplayOrder,IsActive")] Footer footer) { if (ModelState.IsValid) { var _dal = new FooterDAL(); var _result = _dal.Update(footer); if (_result) { return(RedirectToAction("Index", "Footers")); } else { ModelState.AddModelError("", "Cập nhật Footer ko thành công"); } } return(View(footer)); }
public ActionResult Create([Bind(Include = "FooterID,Content,DisplayOrder,IsActive")] Footer footer) { if (ModelState.IsValid) { var _dal = new FooterDAL(); int id = _dal.Insert(footer); if (id > 0) { return(RedirectToAction("Index", "Footers")); } else { ModelState.AddModelError("", "Thêm Footer ko thành công"); } } return(View(footer)); }
public ActionResult Footer() { var model = new FooterDAL().GetFooter(); return(PartialView(model)); }