public bool AddGuestbook(GuestbookEntity guestbookEntity) { bool flag = false; StringBuilder sqlCommandText = new StringBuilder(); sqlCommandText.Append(" @JournalID"); sqlCommandText.Append(", @UserName"); sqlCommandText.Append(", @Email"); sqlCommandText.Append(", @Tel"); sqlCommandText.Append(", @Title"); sqlCommandText.Append(", @MessageContent"); sqlCommandText.Append(", @IP"); DbCommand cmd = db.GetSqlStringCommand(String.Format("INSERT INTO dbo.Guestbook ({0}) VALUES ({1})", sqlCommandText.ToString().Replace("@", ""), sqlCommandText.ToString())); db.AddInParameter(cmd, "@JournalID", DbType.Int64, guestbookEntity.JournalID); db.AddInParameter(cmd, "@UserName", DbType.AnsiString, guestbookEntity.UserName.TextFilter()); db.AddInParameter(cmd, "@Email", DbType.AnsiString, guestbookEntity.Email.TextFilter()); db.AddInParameter(cmd, "@Tel", DbType.AnsiString, guestbookEntity.Tel.TextFilter()); db.AddInParameter(cmd, "@Title", DbType.AnsiString, guestbookEntity.Title.TextFilter()); db.AddInParameter(cmd, "@MessageContent", DbType.AnsiString, guestbookEntity.MessageContent.TextFilter()); db.AddInParameter(cmd, "@IP", DbType.AnsiString, guestbookEntity.IP); try { db.ExecuteNonQuery(cmd); flag = true; } catch (SqlException sqlEx) { throw sqlEx; } return(flag); }
public bool AddGuestbook(GuestbookEntity guestbookEntity) { bool flag = false; StringBuilder sqlCommandText = new StringBuilder(); sqlCommandText.Append(" @JournalID"); sqlCommandText.Append(", @UserName"); sqlCommandText.Append(", @Email"); sqlCommandText.Append(", @Tel"); sqlCommandText.Append(", @Title"); sqlCommandText.Append(", @MessageContent"); sqlCommandText.Append(", @IP"); DbCommand cmd = db.GetSqlStringCommand(String.Format("INSERT INTO dbo.Guestbook ({0}) VALUES ({1})",sqlCommandText.ToString().Replace("@", ""),sqlCommandText.ToString())); db.AddInParameter(cmd,"@JournalID",DbType.Int64,guestbookEntity.JournalID); db.AddInParameter(cmd, "@UserName", DbType.AnsiString, guestbookEntity.UserName.TextFilter()); db.AddInParameter(cmd, "@Email", DbType.AnsiString, guestbookEntity.Email.TextFilter()); db.AddInParameter(cmd, "@Tel", DbType.AnsiString, guestbookEntity.Tel.TextFilter()); db.AddInParameter(cmd, "@Title", DbType.AnsiString, guestbookEntity.Title.TextFilter()); db.AddInParameter(cmd,"@MessageContent",DbType.AnsiString,guestbookEntity.MessageContent.TextFilter()); db.AddInParameter(cmd,"@IP",DbType.AnsiString,guestbookEntity.IP); try { db.ExecuteNonQuery(cmd); flag = true; } catch(SqlException sqlEx) { throw sqlEx; } return flag; }
public List <GuestbookEntity> MakeGuestbookList(DataTable dt) { List <GuestbookEntity> list = new List <GuestbookEntity>(); if (dt != null) { for (int i = 0; i < dt.Rows.Count; i++) { GuestbookEntity guestbookEntity = MakeGuestbook(dt.Rows[i]); list.Add(guestbookEntity); } } return(list); }
public GuestbookEntity GetGuestbook(Int64 messageID) { GuestbookEntity guestbookEntity = null; StringBuilder sqlCommandText = new StringBuilder(); sqlCommandText.Append("SELECT TOP 1 MessageID,JournalID,PMessageID,UserName,Email,Tel,Title,MessageContent,IP,AddDate FROM dbo.Guestbook WITH(NOLOCK)"); sqlCommandText.Append(" WHERE MessageID=@MessageID"); DbCommand cmd = db.GetSqlStringCommand(sqlCommandText.ToString()); db.AddInParameter(cmd, "@MessageID", DbType.Int64, messageID); using (IDataReader dr = db.ExecuteReader(cmd)) { guestbookEntity = MakeGuestbook(dr); } return(guestbookEntity); }
public bool UpdateGuestbook(GuestbookEntity guestbookEntity) { bool flag = false; StringBuilder whereCommandText = new StringBuilder(); whereCommandText.Append(" MessageID=@MessageID"); StringBuilder sqlCommandText = new StringBuilder(); sqlCommandText.Append(" JournalID=@JournalID"); sqlCommandText.Append(", PMessageID=@PMessageID"); sqlCommandText.Append(", UserName=@UserName"); sqlCommandText.Append(", Email=@Email"); sqlCommandText.Append(", Tel=@Tel"); sqlCommandText.Append(", Title=@Title"); sqlCommandText.Append(", MessageContent=@MessageContent"); sqlCommandText.Append(", ReplyContent=@ReplyContent"); sqlCommandText.Append(", IP=@IP"); sqlCommandText.Append(", AddDate=@AddDate"); DbCommand cmd = db.GetSqlStringCommand(String.Format("UPDATE dbo.Guestbook SET {0} WHERE {1}", sqlCommandText.ToString(), whereCommandText.ToString())); db.AddInParameter(cmd, "@MessageID", DbType.Int64, guestbookEntity.MessageID); db.AddInParameter(cmd, "@JournalID", DbType.Int64, guestbookEntity.JournalID); db.AddInParameter(cmd, "@PMessageID", DbType.Int64, guestbookEntity.PMessageID); db.AddInParameter(cmd, "@UserName", DbType.AnsiString, guestbookEntity.UserName); db.AddInParameter(cmd, "@Email", DbType.AnsiString, guestbookEntity.Email); db.AddInParameter(cmd, "@Tel", DbType.AnsiString, guestbookEntity.Tel); db.AddInParameter(cmd, "@Title", DbType.AnsiString, guestbookEntity.Title); db.AddInParameter(cmd, "@MessageContent", DbType.AnsiString, guestbookEntity.MessageContent); db.AddInParameter(cmd, "@ReplyContent", DbType.AnsiString, guestbookEntity.ReplyContent); db.AddInParameter(cmd, "@IP", DbType.AnsiString, guestbookEntity.IP); db.AddInParameter(cmd, "@AddDate", DbType.DateTime, guestbookEntity.AddDate); try { db.ExecuteNonQuery(cmd); flag = true; } catch (SqlException sqlEx) { throw sqlEx; } return(flag); }
public GuestbookEntity MakeGuestbook(DataRow dr) { GuestbookEntity guestbookEntity = null; if (dr != null) { guestbookEntity = new GuestbookEntity(); guestbookEntity.MessageID = (Int64)dr["MessageID"]; guestbookEntity.JournalID = (Int64)dr["JournalID"]; guestbookEntity.PMessageID = (Int64)dr["PMessageID"]; guestbookEntity.UserName = (String)dr["UserName"]; guestbookEntity.Email = (String)dr["Email"]; guestbookEntity.Tel = (String)dr["Tel"]; guestbookEntity.Title = (String)dr["Title"]; guestbookEntity.MessageContent = (String)dr["MessageContent"]; guestbookEntity.IP = (String)dr["IP"]; guestbookEntity.AddDate = (DateTime)dr["AddDate"]; } return(guestbookEntity); }
public List <GuestbookEntity> MakeGuestbookList(IDataReader dr) { List <GuestbookEntity> list = new List <GuestbookEntity>(); while (dr.Read()) { GuestbookEntity guestbookEntity = new GuestbookEntity(); guestbookEntity.MessageID = (Int64)dr["MessageID"]; guestbookEntity.JournalID = (Int64)dr["JournalID"]; guestbookEntity.PMessageID = (Int64)dr["PMessageID"]; guestbookEntity.UserName = (String)dr["UserName"]; guestbookEntity.Email = (String)dr["Email"]; guestbookEntity.Tel = (String)dr["Tel"]; guestbookEntity.Title = (String)dr["Title"]; guestbookEntity.MessageContent = (String)dr["MessageContent"]; guestbookEntity.IP = (String)dr["IP"]; guestbookEntity.AddDate = (DateTime)dr["AddDate"]; list.Add(guestbookEntity); } dr.Close(); return(list); }
public GuestbookEntity MakeGuestbook(IDataReader dr) { GuestbookEntity guestbookEntity = null; if (dr.Read()) { guestbookEntity = new GuestbookEntity(); guestbookEntity.MessageID = (Int64)dr["MessageID"]; guestbookEntity.JournalID = (Int64)dr["JournalID"]; guestbookEntity.PMessageID = (Int64)dr["PMessageID"]; guestbookEntity.UserName = (String)dr["UserName"]; guestbookEntity.Email = (String)dr["Email"]; guestbookEntity.Tel = (String)dr["Tel"]; guestbookEntity.Title = (String)dr["Title"]; guestbookEntity.MessageContent = (String)dr["MessageContent"]; guestbookEntity.ReplyContent = Convert.IsDBNull(dr["ReplyContent"]) ? null : (String)dr["ReplyContent"]; guestbookEntity.IP = (String)dr["IP"]; guestbookEntity.AddDate = (DateTime)dr["AddDate"]; } dr.Close(); return(guestbookEntity); }
public bool DeleteGuestbook(GuestbookEntity guestbookEntity) { bool flag = false; StringBuilder sqlCommandText = new StringBuilder(); sqlCommandText.Append("DELETE FROM dbo.Guestbook"); sqlCommandText.Append(" WHERE MessageID=@MessageID"); DbCommand cmd = db.GetSqlStringCommand(sqlCommandText.ToString()); db.AddInParameter(cmd, "@MessageID", DbType.Int64, guestbookEntity.MessageID); try { db.ExecuteNonQuery(cmd); flag = true; } catch (SqlException sqlEx) { throw sqlEx; } return(flag); }
public ActionResult AddMessage(GuestbookEntity guestBookEntit) { ExecResult execResult = new ExecResult(); try { if (guestBookEntit != null) { guestBookEntit.JournalID = JournalID; guestBookEntit.IP = WKT.Common.Utils.Utils.GetRealIP(); ISiteConfigFacadeService guestService = ServiceContainer.Instance.Container.Resolve <ISiteConfigFacadeService>(); execResult = guestService.SaveSiteGuestBook(guestBookEntit); } } catch (Exception ex) { execResult.result = EnumJsonResult.error.ToString(); execResult.msg = "在线留言出现异常:" + ex.Message; WKT.Log.LogProvider.Instance.Error("在线留言出现异常:" + ex.Message); } return(Content(JsonConvert.SerializeObject(execResult))); }
public ActionResult AddMessage(GuestbookEntity guestBookEntit) { ExecResult execResult = new ExecResult(); try { if (guestBookEntit != null) { guestBookEntit.JournalID = JournalID; guestBookEntit.IP = WKT.Common.Utils.Utils.GetRealIP(); ISiteConfigFacadeService guestService = ServiceContainer.Instance.Container.Resolve<ISiteConfigFacadeService>(); execResult = guestService.SaveSiteGuestBook(guestBookEntit); } } catch (Exception ex) { execResult.result = EnumJsonResult.error.ToString(); execResult.msg = "在线留言出现异常:" + ex.Message; WKT.Log.LogProvider.Instance.Error("在线留言出现异常:" + ex.Message); } return Content(JsonConvert.SerializeObject(execResult)); }
/// <summary> /// 更新存储媒介中的实体数据 /// </summary> /// <param name="guestbook">GuestbookEntity实体对象</param> /// <returns>true:更新成功 false:更新失败</returns> public bool UpdateGuestbook(GuestbookEntity guestbook) { return(GuestbookBusProvider.UpdateGuestbook(guestbook)); }
/// <summary> /// 将实体数据存入存储媒介(持久化一个对象) /// </summary> /// <param name="guestbook">GuestbookEntity实体对象</param> /// <returns>true:存储成功 false:存储失败</returns> public bool AddGuestbook(GuestbookEntity guestbook) { return GuestbookDataAccess.Instance.AddGuestbook(guestbook); }
/// <summary> /// 将实体数据存入存储媒介(持久化一个对象) /// </summary> /// <param name="guestbook">GuestbookEntity实体对象</param> /// <returns>true:存储成功 false:存储失败</returns> public bool AddGuestbook(GuestbookEntity guestbook) { return(GuestbookDataAccess.Instance.AddGuestbook(guestbook)); }
public ExecResult SaveGuestBook(GuestbookEntity model) { ExecResult exeResult = new ExecResult(); try { IGuestbookService service = ServiceContainer.Instance.Container.Resolve<IGuestbookService>(); bool flag = service.AddGuestbook(model); if (flag) { exeResult.result = EnumJsonResult.success.ToString(); } else { exeResult.result = EnumJsonResult.failure.ToString(); } } catch (Exception ex) { exeResult.result = EnumJsonResult.error.ToString(); exeResult.msg = "保存留言出现异常:" + ex.Message; } return exeResult; }
public bool UpdateGuestbook(GuestbookEntity guestbookEntity) { bool flag = false; StringBuilder whereCommandText = new StringBuilder(); whereCommandText.Append(" MessageID=@MessageID"); StringBuilder sqlCommandText = new StringBuilder(); sqlCommandText.Append(" JournalID=@JournalID"); sqlCommandText.Append(", PMessageID=@PMessageID"); sqlCommandText.Append(", UserName=@UserName"); sqlCommandText.Append(", Email=@Email"); sqlCommandText.Append(", Tel=@Tel"); sqlCommandText.Append(", Title=@Title"); sqlCommandText.Append(", MessageContent=@MessageContent"); sqlCommandText.Append(", IP=@IP"); sqlCommandText.Append(", AddDate=@AddDate"); DbCommand cmd = db.GetSqlStringCommand(String.Format("UPDATE dbo.Guestbook SET {0} WHERE {1}",sqlCommandText.ToString(),whereCommandText.ToString())); db.AddInParameter(cmd,"@MessageID",DbType.Int64,guestbookEntity.MessageID); db.AddInParameter(cmd,"@JournalID",DbType.Int64,guestbookEntity.JournalID); db.AddInParameter(cmd,"@PMessageID",DbType.Int64,guestbookEntity.PMessageID); db.AddInParameter(cmd,"@UserName",DbType.AnsiString,guestbookEntity.UserName); db.AddInParameter(cmd,"@Email",DbType.AnsiString,guestbookEntity.Email); db.AddInParameter(cmd,"@Tel",DbType.AnsiString,guestbookEntity.Tel); db.AddInParameter(cmd,"@Title",DbType.AnsiString,guestbookEntity.Title); db.AddInParameter(cmd,"@MessageContent",DbType.AnsiString,guestbookEntity.MessageContent); db.AddInParameter(cmd,"@IP",DbType.AnsiString,guestbookEntity.IP); db.AddInParameter(cmd,"@AddDate",DbType.DateTime,guestbookEntity.AddDate); try { db.ExecuteNonQuery(cmd); flag = true; } catch(SqlException sqlEx) { throw sqlEx; } return flag; }
public List<GuestbookEntity> MakeGuestbookList(IDataReader dr) { List<GuestbookEntity> list=new List<GuestbookEntity>(); while(dr.Read()) { GuestbookEntity guestbookEntity=new GuestbookEntity(); guestbookEntity.MessageID = (Int64)dr["MessageID"]; guestbookEntity.JournalID = (Int64)dr["JournalID"]; guestbookEntity.PMessageID = (Int64)dr["PMessageID"]; guestbookEntity.UserName = (String)dr["UserName"]; guestbookEntity.Email = (String)dr["Email"]; guestbookEntity.Tel = (String)dr["Tel"]; guestbookEntity.Title = (String)dr["Title"]; guestbookEntity.MessageContent = (String)dr["MessageContent"]; guestbookEntity.IP = (String)dr["IP"]; guestbookEntity.AddDate = (DateTime)dr["AddDate"]; list.Add(guestbookEntity); } dr.Close(); return list; }
public GuestbookEntity MakeGuestbook(DataRow dr) { GuestbookEntity guestbookEntity=null; if(dr!=null) { guestbookEntity=new GuestbookEntity(); guestbookEntity.MessageID = (Int64)dr["MessageID"]; guestbookEntity.JournalID = (Int64)dr["JournalID"]; guestbookEntity.PMessageID = (Int64)dr["PMessageID"]; guestbookEntity.UserName = (String)dr["UserName"]; guestbookEntity.Email = (String)dr["Email"]; guestbookEntity.Tel = (String)dr["Tel"]; guestbookEntity.Title = (String)dr["Title"]; guestbookEntity.MessageContent = (String)dr["MessageContent"]; guestbookEntity.IP = (String)dr["IP"]; guestbookEntity.AddDate = (DateTime)dr["AddDate"]; } return guestbookEntity; }
public bool DeleteGuestbook(GuestbookEntity guestbookEntity) { bool flag = false; StringBuilder sqlCommandText = new StringBuilder(); sqlCommandText.Append("DELETE FROM dbo.Guestbook"); sqlCommandText.Append(" WHERE MessageID=@MessageID"); DbCommand cmd = db.GetSqlStringCommand(sqlCommandText.ToString()); db.AddInParameter(cmd,"@MessageID",DbType.Int64,guestbookEntity.MessageID); try { db.ExecuteNonQuery(cmd); flag = true; } catch(SqlException sqlEx) { throw sqlEx; } return flag; }
/// <summary> /// 更新存储媒介中的实体数据 /// </summary> /// <param name="guestbook">GuestbookEntity实体对象</param> /// <returns>true:更新成功 false:更新失败</returns> public bool UpdateGuestbook(GuestbookEntity guestbook) { return GuestbookDataAccess.Instance.UpdateGuestbook(guestbook); }
/// <summary> /// 从存储媒介删除实体数据 /// </summary> /// <param name="guestbook">GuestbookEntity实体对象</param> /// <returns>true:删除成功 false:删除失败</returns> public bool DeleteGuestbook(GuestbookEntity guestbook) { return(GuestbookDataAccess.Instance.DeleteGuestbook(guestbook)); }
/// <summary> /// 更新存储媒介中的实体数据 /// </summary> /// <param name="guestbook">GuestbookEntity实体对象</param> /// <returns>true:更新成功 false:更新失败</returns> public bool UpdateGuestbook(GuestbookEntity guestbook) { return(GuestbookDataAccess.Instance.UpdateGuestbook(guestbook)); }
/// <summary> /// 从存储媒介删除实体数据 /// </summary> /// <param name="guestbook">GuestbookEntity实体对象</param> /// <returns>true:删除成功 false:删除失败</returns> public bool DeleteGuestbook(GuestbookEntity guestbook) { return GuestbookBusProvider.DeleteGuestbook(guestbook); }
/// <summary> /// 将实体数据存入存储媒介(持久化一个对象) /// </summary> /// <param name="guestbook">GuestbookEntity实体对象</param> /// <returns>true:存储成功 false:存储失败</returns> public bool AddGuestbook(GuestbookEntity guestbook) { return GuestbookBusProvider.AddGuestbook(guestbook); }
/// <summary> /// 更新存储媒介中的实体数据 /// </summary> /// <param name="guestbook">GuestbookEntity实体对象</param> /// <returns>true:更新成功 false:更新失败</returns> public bool UpdateGuestbook(GuestbookEntity guestbook) { return GuestbookBusProvider.UpdateGuestbook(guestbook); }
/// <summary> /// 从存储媒介删除实体数据 /// </summary> /// <param name="guestbook">GuestbookEntity实体对象</param> /// <returns>true:删除成功 false:删除失败</returns> public bool DeleteGuestbook(GuestbookEntity guestbook) { return GuestbookDataAccess.Instance.DeleteGuestbook(guestbook); }
/// <summary> /// 从存储媒介删除实体数据 /// </summary> /// <param name="guestbook">GuestbookEntity实体对象</param> /// <returns>true:删除成功 false:删除失败</returns> public bool DeleteGuestbook(GuestbookEntity guestbook) { return(GuestbookBusProvider.DeleteGuestbook(guestbook)); }
public GuestbookEntity MakeGuestbook(IDataReader dr) { GuestbookEntity guestbookEntity = null; if(dr.Read()) { guestbookEntity=new GuestbookEntity(); guestbookEntity.MessageID = (Int64)dr["MessageID"]; guestbookEntity.JournalID = (Int64)dr["JournalID"]; guestbookEntity.PMessageID = (Int64)dr["PMessageID"]; guestbookEntity.UserName = (String)dr["UserName"]; guestbookEntity.Email = (String)dr["Email"]; guestbookEntity.Tel = (String)dr["Tel"]; guestbookEntity.Title = (String)dr["Title"]; guestbookEntity.MessageContent = (String)dr["MessageContent"]; guestbookEntity.ReplyContent = Convert.IsDBNull(dr["ReplyContent"]) ? null : (String)dr["ReplyContent"]; guestbookEntity.IP = (String)dr["IP"]; guestbookEntity.AddDate = (DateTime)dr["AddDate"]; } dr.Close(); return guestbookEntity; }
/// <summary> /// 将实体数据存入存储媒介(持久化一个对象) /// </summary> /// <param name="guestbook">GuestbookEntity实体对象</param> /// <returns>true:存储成功 false:存储失败</returns> public bool AddGuestbook(GuestbookEntity guestbook) { return(GuestbookBusProvider.AddGuestbook(guestbook)); }
/// <summary> /// 保存留言 /// </summary> /// <param name="model"></param> /// <returns></returns> public ExecResult SaveSiteGuestBook(GuestbookEntity model) { HttpClientHelper clientHelper = new HttpClientHelper(); ExecResult result = clientHelper.Post<ExecResult, GuestbookEntity>(GetAPIUrl(APIConstant.SITE_GUESTBOOKE_SAVE), model); return result; }