public ActionResult AjaxForm() { var cityModel = new System_City { IsShow = true }; if (DoAction == ActionType.Edit) { cityModel = _cityDa.GetById(ArrId.FirstOrDefault()); } ViewData.Model = cityModel; ViewBag.Action = DoAction; ViewBag.ActionText = ActionText; return(View()); }
public ActionResult Add(string key, string code) { var msg = new JsonMessage(false, "Thêm mới dữ liệu thành công."); var model = new System_City(); try { if (key != Keyapi) { return(Json(0, JsonRequestBehavior.AllowGet)); } UpdateModel(model); model.IsShow = true; model.IsDeleted = false; _da.Add(model); _da.Save(); } catch (Exception ex) { msg.Erros = true; msg.Message = "Dữ liệu Chưa được thêm mới."; } return(Json(msg, JsonRequestBehavior.AllowGet)); }
public void Delete(System_City systemCity) { FDIDB.System_City.Remove(systemCity); }
public void Add(System_City systemCity) { FDIDB.System_City.Add(systemCity); }
public ActionResult Actions() { var msg = new JsonMessage(); var city = new System_City(); List <System_City> ltsCityItems; StringBuilder stbMessage; switch (DoAction) { case ActionType.Add: UpdateModel(city); _cityDa.Add(city); city.LanguageID = Fdisystem.LanguageId; _cityDa.Save(); msg = new JsonMessage { Erros = false, ID = city.ID.ToString(), Message = string.Format("Đã thêm mới thành phố: <b>{0}</b>", Server.HtmlEncode(city.Name)) }; break; case ActionType.Edit: city = _cityDa.GetById(ArrId.FirstOrDefault()); UpdateModel(city); //city.LanguageID = Fdisystem.LanguageId; _cityDa.Save(); msg = new JsonMessage { Erros = false, ID = city.ID.ToString(), Message = string.Format("Đã cập nhật thành phố: <b>{0}</b>", Server.HtmlEncode(city.Name)) }; break; case ActionType.Delete: ltsCityItems = _cityDa.GetByListArrId(ArrId.ToString()); stbMessage = new StringBuilder(); foreach (var item in ltsCityItems) { if (item.System_District.Any()) { stbMessage.AppendFormat("Thành phố <b>{0}</b> đang được sử dụng, không được phép xóa.<br />", Server.HtmlEncode(item.Name)); } else { _cityDa.Delete(item); stbMessage.AppendFormat("Đã xóa thành phố <b>{0}</b>.<br />", Server.HtmlEncode(item.Name)); } } msg.ID = string.Join(",", ArrId); _cityDa.Save(); msg.Message = stbMessage.ToString(); break; case ActionType.Show: ltsCityItems = _cityDa.GetByListArrId(ArrId.ToString()).Where(o => !o.IsShow).ToList(); stbMessage = new StringBuilder(); foreach (var item in ltsCityItems) { item.IsShow = true; stbMessage.AppendFormat("Đã hiển thị thành phố <b>{0}</b>.<br />", Server.HtmlEncode(item.Name)); } _cityDa.Save(); msg.ID = string.Join(",", ltsCityItems.Select(o => o.ID)); msg.Message = stbMessage.ToString(); break; case ActionType.Hide: ltsCityItems = _cityDa.GetByListArrId(ArrId.ToString()).Where(o => o.IsShow).ToList(); stbMessage = new StringBuilder(); foreach (var item in ltsCityItems) { item.IsShow = false; stbMessage.AppendFormat("Đã ẩn thành phố <b>{0}</b>.<br />", Server.HtmlEncode(item.Name)); } _cityDa.Save(); msg.ID = string.Join(",", ltsCityItems.Select(o => o.ID)); msg.Message = stbMessage.ToString(); break; } if (string.IsNullOrEmpty(msg.Message)) { msg.Message = "Không có hành động nào được thực hiện."; msg.Erros = true; } return(Json(msg, JsonRequestBehavior.AllowGet)); }
public void Add(System_City City) { FDIDB.System_City.Add(City); }