public chatboxInfo GetInfo(int id) { chatboxInfo info = null; SqlParameter[] param = { new SqlParameter("@ID", id) }; var r = DataHelper.ExecuteReader(Config.ConnectString, "usp_chatbox_GetById", param); if (r != null) { info = new chatboxInfo(); while (r.Read()) { info.id = Int32.Parse(r["ID"].ToString()); info.name = r["name"].ToString(); info.comment = r["comment"].ToString(); info.CreateDate = Convert.ToDateTime(r["CreateDate"]); } r.Close(); r.Dispose(); } return(info); }
public List <chatboxInfo> GetAll(int top) { List <chatboxInfo> list = null; var t = 0; SqlParameter[] param = { new SqlParameter("@top", top) }; SqlCommand comx; var r = DataHelper.ExecuteReader(Config.ConnectString, "tuan_chatbox_selectop_desc", param); if (r != null) { list = new List <chatboxInfo>(); while (r.Read()) { var info = new chatboxInfo(); info.name = r["name"].ToString(); info.comment = r["comment"].ToString(); info.isAdmin = r.GetBoolean(r.GetOrdinal("isadmin")); list.Add(info); } r.Close(); r.Dispose(); } return(list); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; var times = 0; var username = context.Request.Form["username"]; var comment = Emotify(context.Request.Form["comment"]); var ip = context.Request.ServerVariables["REMOTE_ADDR"]; var cach = context.Cache[cachcomment + ip]; if (cach != null) { times = int.Parse(cach.ToString()); } if (times >= 0 && times < 15) { //Insert var info = new chatboxInfo(); info.isAdmin = false; info.active = true; info.name = username; info.comment = comment; ServiceFactory.GetInstanceChatbox().Add(info); //Recache //context.Cache.Add(cachcomment + ip.Replace(".", "_"), ++times, null, DateTime.Now.AddDays(1),Cache.NoSlidingExpiration, CacheItemPriority.Normal, null); context.Response.Write(1); } else { context.Response.Write(2); } context.Response.End(); }
public int Update(chatboxInfo info) { SqlParameter[] param = { new SqlParameter("@ID", info.id) , new SqlParameter("@name",info.name), new SqlParameter("@comment", info.comment), }; return(DataHelper.ExecuteNonQuery(Config.ConnectString, "usp_chatbox_Update", param)); }
public int Add(chatboxInfo info) { SqlParameter[] param = { new SqlParameter("@name", info.name), new SqlParameter("@comment", info.comment), new SqlParameter("@CreateDate", info.CreateDate) }; return(int.Parse(DataHelper.ExecuteScalar(Config.ConnectString, "usp_chatbox_Add", param).ToString())); }
protected void BT_Save_Click(object sender, EventArgs e) { chatboxInfo info = new chatboxInfo(); info.comment = TB_Comment.Text; info.name = "Admin"; info.isAdmin = true; info.active = CB_Active.Checked; ServiceFactory.GetInstanceChatbox().Add(info); Response.Redirect("list-chatbox-other.aspx"); }
public List <chatboxInfo> GetList(int pageIndex, int pageSize, out int total) { List <chatboxInfo> list = null; var t = 0; SqlParameter[] param = { new SqlParameter("@pageIndex", pageIndex), new SqlParameter("@pageSize", pageSize), new SqlParameter("@totalrow", DbType.Int32) { Direction = ParameterDirection.Output } }; SqlCommand comx; var r = DataHelper.ExecuteReader(Config.ConnectString, "usp_chatbox_GetList", param, out comx); if (r != null) { list = new List <chatboxInfo>(); while (r.Read()) { var info = new chatboxInfo(); info.id = Int32.Parse(r["ID"].ToString()); info.name = r["name"].ToString(); info.comment = r["comment"].ToString(); info.CreateDate = Convert.ToDateTime(r["CreateDate"]); list.Add(info); } r.Close(); r.Dispose(); t = int.Parse(comx.Parameters[2].Value.ToString()); } total = t; return(list); }