/// <summary> /// 新闻详细 /// </summary> /// <param name="n_id"></param> /// <returns></returns> public ActionResult NewDetil(int id = 0) { string UserRegister = ConfigurationManager.AppSettings["UserRegister"]; string Userpassword = ConfigurationManager.AppSettings["Userpassword"]; ViewBag.UserRegister = UserRegister; ViewBag.Userpassword = Userpassword; JMP.MDL.newsrelease model = new JMP.MDL.newsrelease(); JMP.BLL.newsrelease bll = new JMP.BLL.newsrelease(); List <JMP.MDL.newsrelease> list = new List <JMP.MDL.newsrelease>(); if (id > 0) { model = bll.SelectId(id); if (model != null) { bll.UpdateCount(id); list = bll.SelectUpDw(id, model.n_category); } } ViewBag.id = id; ViewBag.list = list; ViewBag.UploadUrl = ConfigurationManager.AppSettings["imgurl"]; ViewBag.model = model == null ? new JMP.MDL.newsrelease() : model; return(View()); }
public JsonResult InsertUpdateNewsRelease(JMP.MDL.newsrelease model) { object retJson = new { success = 0, msg = "操作失败" }; JMP.BLL.newsrelease bll = new JMP.BLL.newsrelease(); //string xgzfc = ""; if (model.n_id > 0) { // 修改新闻管理 JMP.MDL.newsrelease modComplaint = new JMP.MDL.newsrelease(); modComplaint = bll.GetModel(model.n_id); var modComplaintClone = modComplaint.Clone(); modComplaint.n_title = model.n_title; modComplaint.n_info = model.n_info; modComplaint.n_picture = model.n_picture; modComplaint.n_category = model.n_category; modComplaint.keywords = model.keywords; modComplaint.description = model.description; //model.n_count = modComplaint.n_count; //model.n_time = modComplaint.n_time; //model.n_user = modComplaint.n_user; if (bll.Update(modComplaint)) { Logger.ModifyLog("修改新闻信息", modComplaintClone, model); retJson = new { success = 1, msg = "修改成功" }; } else { retJson = new { success = 0, msg = "修改失败" }; } } else { model.n_time = DateTime.Now; model.n_user = UserInfo.UserName; model.n_count = 0; int cg = bll.Add(model); if (cg > 0) { Logger.CreateLog("添加新闻", model); retJson = new { success = 1, msg = "添加成功" }; } else { retJson = new { success = 1, msg = "添加失败" }; } } return(Json(retJson)); }
/// <summary> /// 添加/修改新闻 /// </summary> /// <returns></returns> public ActionResult NewsReleaseAdd() { int c_id = string.IsNullOrEmpty(Request["c_id"]) ? 0 : Int32.Parse(Request["c_id"]); JMP.BLL.newsrelease bll = new JMP.BLL.newsrelease(); JMP.MDL.newsrelease model = new JMP.MDL.newsrelease(); if (c_id > 0) { model = bll.SelectId(c_id); } ViewBag.model = model == null ? new JMP.MDL.newsrelease() : model; ViewBag.UploadUrl = ConfigurationManager.AppSettings["imgurl"]; return(View()); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(JMP.MDL.newsrelease model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update newsrelease set "); strSql.Append(" n_category = @n_category , "); strSql.Append(" n_title = @n_title , "); strSql.Append(" n_picture = @n_picture , "); strSql.Append(" n_info = @n_info , "); strSql.Append(" n_user = @n_user , "); strSql.Append(" n_time = @n_time , "); strSql.Append(" n_count = @n_count, "); strSql.Append(" description = @description, "); strSql.Append(" keywords = @keywords "); strSql.Append(" where n_id=@n_id "); SqlParameter[] parameters = { new SqlParameter("@n_id", SqlDbType.Int, 4), new SqlParameter("@n_category", SqlDbType.Int, 4), new SqlParameter("@n_title", SqlDbType.NVarChar, 200), new SqlParameter("@n_picture", SqlDbType.NVarChar, -1), new SqlParameter("@n_info", SqlDbType.Text), new SqlParameter("@n_user", SqlDbType.NVarChar, 50), new SqlParameter("@n_time", SqlDbType.DateTime), new SqlParameter("@n_count", SqlDbType.Int, 4), new SqlParameter("@description", model.description), new SqlParameter("@keywords", model.keywords) }; parameters[0].Value = model.n_id; parameters[1].Value = model.n_category; parameters[2].Value = model.n_title; parameters[3].Value = model.n_picture; parameters[4].Value = model.n_info; parameters[5].Value = model.n_user; parameters[6].Value = model.n_time; parameters[7].Value = model.n_count; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public JMP.MDL.newsrelease DataRowToModel(DataRow row) { JMP.MDL.newsrelease model = new JMP.MDL.newsrelease(); if (row != null) { if (row["n_id"] != null && row["n_id"].ToString() != "") { model.n_id = int.Parse(row["n_id"].ToString()); } if (row["n_category"] != null && row["n_category"].ToString() != "") { model.n_category = int.Parse(row["n_category"].ToString()); } if (row["n_title"] != null) { model.n_title = row["n_title"].ToString(); } if (row["n_picture"] != null) { model.n_picture = row["n_picture"].ToString(); } if (row["n_info"] != null) { model.n_info = row["n_info"].ToString(); } if (row["n_user"] != null) { model.n_user = row["n_user"].ToString(); } if (row["n_count"] != null) { model.n_count = int.Parse(row["n_count"].ToString()); } if (row["n_time"] != null && row["n_time"].ToString() != "") { model.n_time = DateTime.Parse(row["n_time"].ToString()); } if (row["description"] != null) { model.description = row["description"].ToString(); } if (row["keywords"] != null) { model.keywords = row["keywords"].ToString(); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(JMP.MDL.newsrelease model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into newsrelease("); strSql.Append("n_category,n_title,n_picture,n_info,n_user,n_time,n_count,description,keywords"); strSql.Append(") values ("); strSql.Append("@n_category,@n_title,@n_picture,@n_info,@n_user,@n_time,@n_count,@description,@keywords"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@n_category", SqlDbType.Int, 4), new SqlParameter("@n_title", SqlDbType.NVarChar, 200), new SqlParameter("@n_picture", SqlDbType.NVarChar, -1), new SqlParameter("@n_info", SqlDbType.Text), new SqlParameter("@n_user", SqlDbType.NVarChar, 50), new SqlParameter("@n_time", SqlDbType.DateTime), new SqlParameter("@n_count", SqlDbType.Int, 4), new SqlParameter("@description", model.description), new SqlParameter("@keywords", model.keywords) }; parameters[0].Value = model.n_category; parameters[1].Value = model.n_title; parameters[2].Value = model.n_picture; parameters[3].Value = model.n_info; parameters[4].Value = model.n_user; parameters[5].Value = model.n_time; parameters[6].Value = model.n_count; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public JMP.MDL.newsrelease GetModel(int n_id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from newsrelease "); strSql.Append(" where n_id=@n_id"); SqlParameter[] parameters = { new SqlParameter("@n_id", SqlDbType.Int, 4) }; parameters[0].Value = n_id; JMP.MDL.newsrelease model = new JMP.MDL.newsrelease(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }