/// <summary> /// 更新一条数据 /// </summary> public bool Update(objMsg model) { string str = "UPDATE p_objmsg SET SpecificTypeID=@SpecificTypeID,Title=@Title,Msg=@Msg,CreatDateTime=@CreatDateTime,Remake=@Remake where ID=@ID;"; MySqlParameter[] parameters = { new MySqlParameter("@ID", MySqlDbType.Int32, 11), new MySqlParameter("@SpecificTypeID", MySqlDbType.Int32), new MySqlParameter("@Title", MySqlDbType.VarChar, 255), new MySqlParameter("@Msg", MySqlDbType.VarChar, 255), new MySqlParameter("@CreatDateTime", MySqlDbType.DateTime), new MySqlParameter("@Remake", MySqlDbType.VarChar, 255) }; parameters[0].Value = model.ID; parameters[1].Value = model.SpecificTypeID; parameters[2].Value = model.Title; parameters[3].Value = model.Msg; parameters[4].Value = model.CreatDateTime; parameters[5].Value = model.Remake; if (DBHelper.ExecuteSql(str, parameters) >= 0) { return(true); } return(false); }
/// <summary> ///// 是否存在该记录 ///// </summary> //public bool Exists(int ID) //{ // int rowsAffected; // MySqlParameter[] parameters = { // new MySqlParameter("@ID", MySqlDbType.Int32) // }; // parameters[0].Value = ID; // int result = DbHelper.RunProcedure("p_objmsg_Exists", parameters, out rowsAffected); // if (result == 1) // { // return true; // } // else // { // return false; // } //} /// <summary> /// 增加一条数据 /// </summary> public bool Add(objMsg model) { string str = "INSERT INTO p_objmsg(SpecificTypeID, Title, Msg, CreatDateTime, Remake) VALUE(@SpecificTypeID,@Title, @Msg, @CreatDateTime, @Remake);"; MySqlParameter[] parameters = { // new MySqlParameter("@ID", MySqlDbType.Int32,11), new MySqlParameter("@SpecificTypeID", MySqlDbType.Int32), new MySqlParameter("@Title", MySqlDbType.VarChar, 255), new MySqlParameter("@Msg", MySqlDbType.VarChar, 255), new MySqlParameter("@CreatDateTime", MySqlDbType.DateTime), new MySqlParameter("@Remake", MySqlDbType.VarChar, 255) }; // parameters[0].Value = model.ID; parameters[0].Value = model.SpecificTypeID; parameters[1].Value = model.Title; parameters[2].Value = model.Msg; parameters[3].Value = model.CreatDateTime; parameters[4].Value = model.Remake; if (DBHelper.ExecuteSql(str, parameters) >= 0) { return(true); } return(false); }
/// <summary> /// 得到一个对象实体 /// </summary> public objMsg DataRowToModel(DataRow row) { objMsg model = new objMsg(); if (row != null) { if (row["ID"] != null && row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["SpecificTypeID"] != null) { model.SpecificTypeID = int.Parse(row["SpecificTypeID"].ToString()); } if (row["Title"] != null) { model.Title = row["Title"].ToString(); } if (row["Msg"] != null) { model.Msg = row["Msg"].ToString(); } if (row["CreatDateTime"] != null && row["CreatDateTime"].ToString() != "") { model.CreatDateTime = DateTime.Parse(row["CreatDateTime"].ToString()); } if (row["Remake"] != null) { model.Remake = row["Remake"].ToString(); } } return(model); }
/// <summary> /// 内容页 /// </summary> /// <param name="ID"></param> /// <returns></returns> public ActionResult Content(string ID) { List <objSpecificType> ListBook = bllSpecificType.GetModelList(" TypeID=1 "); ViewData["book"] = ListBook; objMsg msg = bll.GetModel(int.Parse(ID)); if (msg != null) { msg.Title = FromUnicodeString(msg.Title); msg.Msg = FromUnicodeString(msg.Msg); } ViewData["msg"] = msg; return(View()); }
/// <summary> /// 得到一个对象实体 /// </summary> public objMsg GetModel(int ID) { string str = "SELECT * FROM p_objmsg WHERE ID=@ID; "; MySqlParameter[] parameters = { new MySqlParameter("@ID", MySqlDbType.Int32) }; parameters[0].Value = ID; objMsg model = new objMsg(); DataSet ds = DBHelper.Query(str, parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
public ActionResult SaveContent(string username, string password, string tbTilie, string tbMsg, string tbType) { if (username == "tanzhenyu" && password == "liuyang") { objMsg obj = new objMsg(); obj.CreatDateTime = DateTime.Now; obj.Msg = ToUnicodeString(tbMsg); //Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(tbMsg)); obj.SpecificTypeID = int.Parse(tbType); obj.Title = ToUnicodeString(tbTilie); //Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(tbTilie)); ; bll.Add(obj); } List <objMsg> listMsgs = bll.GetModelList(" 1=1 order by CreatDateTime LIMIT 10 "); List <objSpecificType> listSpecificType = bllSpecificType.GetModelList(" TypeID=1 "); List <objMsg> list = listMsgs; List <objSpecificType> ListBook = listSpecificType; ViewData["NewMsg"] = objMsgBase64ToString(list); ViewData["book"] = ListBook; return(View("Index")); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(objMsg model) { return(dal.Update(model)); }
///// <summary> ///// 是否存在该记录 ///// </summary> ////public bool Exists(int ID) ////{ //// return dal.Exists(ID); ////} /// <summary> /// 增加一条数据 /// </summary> public bool Add(objMsg model) { return(dal.Add(model)); }