/// <summary> /// 增加一条数据 /// </summary> public int Add(NewsTypeModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into tbNewsType("); strSql.Append("ftypename,fsort,CreateBy,CreateTime,UpdateBy,UpdateTime"); strSql.Append(") values ("); strSql.Append("@ftypename,@fsort,@CreateBy,@CreateTime,@UpdateBy,@UpdateTime"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@ftypename", SqlDbType.NVarChar, 50), new SqlParameter("@CreateBy", SqlDbType.NVarChar, 50), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@UpdateBy", SqlDbType.NVarChar, 50), new SqlParameter("@UpdateTime", SqlDbType.DateTime), new SqlParameter("@fsort", SqlDbType.Int) }; parameters[0].Value = model.ftypename; parameters[1].Value = model.CreateBy; parameters[2].Value = model.CreateTime; parameters[3].Value = model.UpdateBy; parameters[4].Value = model.UpdateTime; parameters[5].Value = model.fsort; object obj = Convert.ToInt32(SqlHelper.ExecuteScalar(SqlHelper.connStr, CommandType.Text, strSql.ToString(), parameters)); return(Convert.ToInt32(obj)); }
public static List <NewsTypeModel> GetNewsList() { string sqlText = "SELECT * FROM NewsType where NewsType_isdelete = 0"; SqlDataReader sdr = SQLHelper.ExecuteReader(sqlText); List <NewsTypeModel> newsTypeList = new List <NewsTypeModel>(); if (sdr != null) { if (sdr.HasRows) { while (sdr.Read()) { NewsTypeModel newsType = new NewsTypeModel(); newsType.NewsTypeid = Convert.ToInt32(sdr["NewsType_id"]); newsType.NewsTypename = sdr["NewsType_name"].ToString(); newsTypeList.Add(newsType); } sdr.Close(); return(newsTypeList); } else { return(null); } } else { return(null); } }
public ActionResult AddNewsType() { NewsTypeModel model = new NewsTypeModel(); ViewData["referer"] = MallUtils.GetMallAdminRefererCookie(); return(View(model)); }
/// <summary> /// 顯示最新消息 /// </summary> /// <param name="NewsNo"></param> /// <returns></returns> public ActionResult ShowNews(string NewsNo) { //SQL Select all type var sqlTypes = string.Format("SELECT NewsTypeNo, TypeName FROM [dbo].[NewsType]"); var dataTypes = _DB_GetData(sqlTypes); NewsTypes = new List <NewsTypeModel>(); foreach (DataRow row in dataTypes.Rows) { NewsTypeModel model = new NewsTypeModel(); model.NewsTypeNo = row.ItemArray.GetValue(0).ToString(); model.TypeName = row.ItemArray.GetValue(1).ToString(); NewsTypes.Add(model); } ViewData["NewsTypes"] = NewsTypes; //目前登入權限 var StatusNo = getUserStatusNo(); //權限 ViewData["StatusNo"] = StatusNo; //任何人都可進來查看 最新消息 if (StatusNo == "1" || StatusNo == "0" || StatusNo == null) { return(View(GetNews(NewsNo))); } else { //導致Error頁面 return(Redirect("~/Home/Error")); //return StatusCode(403); } }
public ActionResult EditNewsType(NewsTypeModel model, int newsTypeId = -1) { NewsTypeInfo newsTypeInfo = AdminNews.GetNewsTypeById(newsTypeId); if (newsTypeInfo == null) { return(PromptView("新闻类型不存在")); } NewsTypeInfo newsTypeInfo2 = AdminNews.GetNewsTypeByName(model.NewsTypeName); if (newsTypeInfo2 != null && newsTypeInfo2.NewsTypeId != newsTypeId) { ModelState.AddModelError("NewsTypeName", "名称已经存在"); } if (ModelState.IsValid) { newsTypeInfo.Name = model.NewsTypeName; newsTypeInfo.DisplayOrder = model.DisplayOrder; AdminNews.UpdateNewsType(newsTypeInfo); AddMallAdminLog("修改新闻类型", "修改新闻类型,新闻类型ID为:" + newsTypeId); return(PromptView("新闻类型修改成功")); } ViewData["referer"] = MallUtils.GetMallAdminRefererCookie(); return(View(model)); }
public ActionResult Create() { var result = new NewsTypeModel { Name = "new message type" }; return(View(result)); }
public ActionResult Create(NewsTypeModel type) { if (ModelState.IsValid) { type.Save(_messageDao); return(RedirectToAction("Index")); } return(View(type)); }
public ActionResult EditNewsType(int newsTypeId = -1) { NewsTypeInfo newsTypeInfo = AdminNews.GetNewsTypeById(newsTypeId); if (newsTypeInfo == null) { return(PromptView("新闻类型不存在")); } NewsTypeModel model = new NewsTypeModel(); model.NewsTypeName = newsTypeInfo.Name; model.DisplayOrder = newsTypeInfo.DisplayOrder; ViewData["referer"] = MallUtils.GetMallAdminRefererCookie(); return(View(model)); }
/// <summary> /// 得到一个对象实体 /// </summary> public NewsTypeModel GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select id, ftypename, fsort, CreateTime,CreateBy,UpdateTime,UpdateBy "); strSql.Append(" from tbNewsType "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; NewsTypeModel model = new NewsTypeModel(); DataTable dt = SqlHelper.GetDataTable(SqlHelper.connStr, CommandType.Text, strSql.ToString(), parameters); if (dt.Rows.Count > 0) { if (dt.Rows[0]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[0]["id"].ToString()); } model.ftypename = dt.Rows[0]["ftypename"].ToString(); if (dt.Rows[0]["fsort"].ToString() != "") { model.fsort = int.Parse(dt.Rows[0]["fsort"].ToString()); } model.CreateBy = dt.Rows[0]["CreateBy"].ToString(); if (dt.Rows[0]["CreateTime"].ToString() != "") { model.CreateTime = DateTime.Parse(dt.Rows[0]["CreateTime"].ToString()); } model.UpdateBy = dt.Rows[0]["UpdateBy"].ToString(); if (dt.Rows[0]["UpdateTime"].ToString() != "") { model.UpdateTime = DateTime.Parse(dt.Rows[0]["UpdateTime"].ToString()); } return(model); } else { return(null); } }
public ActionResult NewNews() { //SQL Select all type var sqlStr = string.Format("SELECT NewsTypeNo, TypeName FROM [dbo].[NewsType]"); var data = _DB_GetData(sqlStr); NewsTypes = new List <NewsTypeModel>(); foreach (DataRow row in data.Rows) { NewsTypeModel model = new NewsTypeModel(); model.NewsTypeNo = row.ItemArray.GetValue(0).ToString(); model.TypeName = row.ItemArray.GetValue(1).ToString(); NewsTypes.Add(model); } ViewData["NewsTypes"] = NewsTypes; return(View()); }
public ActionResult AddNewsType(NewsTypeModel model) { if (AdminNews.GetNewsTypeByName(model.NewsTypeName) != null) { ModelState.AddModelError("NewsTypeName", "名称已经存在"); } if (ModelState.IsValid) { NewsTypeInfo newsTypeInfo = new NewsTypeInfo() { Name = model.NewsTypeName, DisplayOrder = model.DisplayOrder }; AdminNews.CreateNewsType(newsTypeInfo); AddMallAdminLog("添加新闻类型", "添加新闻类型,新闻类型为:" + model.NewsTypeName); return(PromptView("新闻类型添加成功")); } ViewData["referer"] = MallUtils.GetMallAdminRefererCookie(); return(View(model)); }
/// <summary> /// 更新一条数据 /// </summary> public int Update(NewsTypeModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tbNewsType set "); strSql.Append(" ftypename = @ftypename , "); strSql.Append(" fsort = @fsort , "); strSql.Append(" CreateBy = @CreateBy , "); strSql.Append(" CreateTime = @CreateTime , "); strSql.Append(" UpdateBy = @UpdateBy , "); strSql.Append(" UpdateTime = @UpdateTime "); strSql.Append(" where id=@id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4), new SqlParameter("@ftypename", SqlDbType.NVarChar, 50), new SqlParameter("@CreateBy", SqlDbType.NVarChar, 50), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@UpdateBy", SqlDbType.NVarChar, 50), new SqlParameter("@UpdateTime", SqlDbType.DateTime), new SqlParameter("@fsort", SqlDbType.Int) }; parameters[0].Value = model.id; parameters[1].Value = model.ftypename; parameters[2].Value = model.CreateBy; parameters[3].Value = model.CreateTime; parameters[4].Value = model.UpdateBy; parameters[5].Value = model.UpdateTime; parameters[6].Value = model.fsort; object obj = SqlHelper.ExecuteNonQuery(SqlHelper.connStr, CommandType.Text, strSql.ToString(), parameters); return(Convert.ToInt32(obj)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(NewsTypeModel model) { return(dal.Add(model)); }
public ActionResult Create(NewsTypeModel model, string cdts) { GetConditions(cdts); model.Insert(); return(View("AdminIndex")); }
public ActionResult Edit(string id) { var result = new NewsTypeModel(_messageDao.NewsTypeDao.Get(id)); return(View(result)); }
public ActionResult Edit(NewsTypeModel model, string cdts) { GetConditions(cdts); model.Update(); return(View("AdminIndex")); }
/// <summary> /// 更新一条数据 /// </summary> public int Update(NewsTypeModel model) { return(dal.Update(model)); }