Exemplo n.º 1
0
        protected void LinkButton1_OnClick(object sender, EventArgs e)
        {
            string comments = TextArea1.Value.Trim();

            if (string.IsNullOrEmpty(comments))
            {
                Label8.Text    = "评论不能为空";
                Label8.Visible = true;
                TextArea1.Attributes.Add("class", "is-invalid form-control mt-3");
                return;
            }

            if (string.IsNullOrEmpty(UserID))
            {
                Label8.Text    = "请登录后再评论";
                Label8.Visible = true;
                TextArea1.Attributes.Add("class", "is-invalid form-control mt-3");
                return;
            }

            Info_Comment_BLL   infoCommentBll   = new Info_Comment_BLL();
            Info_Comment_Model infoCommentModel = new Info_Comment_Model();

            infoCommentModel.CommentID      = Guid.NewGuid();
            infoCommentModel.LogsID         = new Guid(LogsID);
            infoCommentModel.CommentContent = comments;
            infoCommentModel.Commentator    = new Guid(UserID);
            infoCommentModel.CommentTime    = DateTime.Now;
            infoCommentBll.Add(infoCommentModel);
            GetComments();
        }
Exemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Info_Comment_Model DataRowToModel(DataRow row)
        {
            Info_Comment_Model model = new Info_Comment_Model();

            if (row != null)
            {
                if (row["CommentID"] != null && row["CommentID"].ToString() != "")
                {
                    model.CommentID = new Guid(row["CommentID"].ToString());
                }
                if (row["LogsID"] != null && row["LogsID"].ToString() != "")
                {
                    model.LogsID = new Guid(row["LogsID"].ToString());
                }
                if (row["CommentContent"] != null)
                {
                    model.CommentContent = row["CommentContent"].ToString();
                }
                if (row["Commentator"] != null && row["Commentator"].ToString() != "")
                {
                    model.Commentator = new Guid(row["Commentator"].ToString());
                }
                if (row["CommentTime"] != null && row["CommentTime"].ToString() != "")
                {
                    model.CommentTime = DateTime.Parse(row["CommentTime"].ToString());
                }
                if (row["IsDelete"] != null && row["IsDelete"].ToString() != "")
                {
                    if ((row["IsDelete"].ToString() == "1") || (row["IsDelete"].ToString().ToLower() == "true"))
                    {
                        model.IsDelete = true;
                    }
                    else
                    {
                        model.IsDelete = false;
                    }
                }
            }
            return(model);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Info_Comment_Model model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Info_Comment set ");
            strSql.Append("LogsID=@LogsID,");
            strSql.Append("CommentContent=@CommentContent,");
            strSql.Append("Commentator=@Commentator,");
            strSql.Append("CommentTime=@CommentTime,");
            strSql.Append("IsDelete=@IsDelete");
            strSql.Append(" where CommentID=@CommentID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@LogsID",         SqlDbType.UniqueIdentifier,  16),
                new SqlParameter("@CommentContent", SqlDbType.NVarChar,         255),
                new SqlParameter("@Commentator",    SqlDbType.UniqueIdentifier,  16),
                new SqlParameter("@CommentTime",    SqlDbType.DateTime),
                new SqlParameter("@IsDelete",       SqlDbType.Bit,                1),
                new SqlParameter("@CommentID",      SqlDbType.UniqueIdentifier, 16)
            };
            parameters[0].Value = model.LogsID;
            parameters[1].Value = model.CommentContent;
            parameters[2].Value = model.Commentator;
            parameters[3].Value = model.CommentTime;
            parameters[4].Value = model.IsDelete;
            parameters[5].Value = model.CommentID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Info_Comment_Model model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Info_Comment(");
            strSql.Append("CommentID,LogsID,CommentContent,Commentator,CommentTime,IsDelete)");
            strSql.Append(" values (");
            strSql.Append("@CommentID,@LogsID,@CommentContent,@Commentator,@CommentTime,@IsDelete)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CommentID",      SqlDbType.UniqueIdentifier,  16),
                new SqlParameter("@LogsID",         SqlDbType.UniqueIdentifier,  16),
                new SqlParameter("@CommentContent", SqlDbType.NVarChar,         255),
                new SqlParameter("@Commentator",    SqlDbType.UniqueIdentifier,  16),
                new SqlParameter("@CommentTime",    SqlDbType.DateTime),
                new SqlParameter("@IsDelete",       SqlDbType.Bit, 1)
            };
            parameters[0].Value = Guid.NewGuid();
            // parameters[1].Value = Guid.NewGuid();
            parameters[1].Value = model.LogsID;
            parameters[2].Value = model.CommentContent;
            // parameters[3].Value = Guid.NewGuid();
            parameters[3].Value = model.Commentator;

            parameters[4].Value = model.CommentTime;
            parameters[5].Value = model.IsDelete;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Info_Comment_Model GetModel(Guid CommentID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 CommentID,LogsID,CommentContent,Commentator,CommentTime,IsDelete from Info_Comment ");
            strSql.Append(" where CommentID=@CommentID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CommentID", SqlDbType.UniqueIdentifier, 16)
            };
            parameters[0].Value = CommentID;

            Info_Comment_Model model = new Info_Comment_Model();
            DataSet            ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Info_Comment_Model model)
 {
     return(dal.Update(model));
 }
Exemplo n.º 7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(Info_Comment_Model model)
 {
     return(dal.Add(model));
 }