예제 #1
0
 private void ShowInfo(int commentId)
 {
     rr2.BLL.commentInfo   bll   = new rr2.BLL.commentInfo();
     rr2.Model.commentInfo model = bll.GetModel(commentId);
     this.lblcommentId.Text      = model.commentId.ToString();
     this.txtnewsId.Text         = model.newsId.ToString();
     this.txtownUserId.Text      = model.ownUserId.ToString();
     this.txtcheckUserId.Text    = model.checkUserId.ToString();
     this.txtcommentContent.Text = model.commentContent;
     this.txtcommentTime.Text    = model.commentTime.ToString();
     this.txtext1.Text           = model.ext1;
     this.txtext2.Text           = model.ext2;
     this.txtext3.Text           = model.ext3;
 }
예제 #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(rr2.Model.commentInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update commentInfo set ");
            strSql.Append("newsId=@newsId,");
            strSql.Append("ownUserId=@ownUserId,");
            strSql.Append("checkUserId=@checkUserId,");
            strSql.Append("commentContent=@commentContent,");
            strSql.Append("commentTime=@commentTime,");
            strSql.Append("ext1=@ext1,");
            strSql.Append("ext2=@ext2,");
            strSql.Append("ext3=@ext3");
            strSql.Append(" where commentId=@commentId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@newsId",         SqlDbType.Int,          4),
                new SqlParameter("@ownUserId",      SqlDbType.Int,          4),
                new SqlParameter("@checkUserId",    SqlDbType.Int,          4),
                new SqlParameter("@commentContent", SqlDbType.VarChar,   1000),
                new SqlParameter("@commentTime",    SqlDbType.DateTime),
                new SqlParameter("@ext1",           SqlDbType.VarChar,    200),
                new SqlParameter("@ext2",           SqlDbType.VarChar,    200),
                new SqlParameter("@ext3",           SqlDbType.VarChar,    200),
                new SqlParameter("@commentId",      SqlDbType.Int, 4)
            };
            parameters[0].Value = model.newsId;
            parameters[1].Value = model.ownUserId;
            parameters[2].Value = model.checkUserId;
            parameters[3].Value = model.commentContent;
            parameters[4].Value = model.commentTime;
            parameters[5].Value = model.ext1;
            parameters[6].Value = model.ext2;
            parameters[7].Value = model.ext3;
            parameters[8].Value = model.commentId;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public rr2.Model.commentInfo DataRowToModel(DataRow row)
 {
     rr2.Model.commentInfo model = new rr2.Model.commentInfo();
     if (row != null)
     {
         if (row["commentId"] != null && row["commentId"].ToString() != "")
         {
             model.commentId = int.Parse(row["commentId"].ToString());
         }
         if (row["newsId"] != null && row["newsId"].ToString() != "")
         {
             model.newsId = int.Parse(row["newsId"].ToString());
         }
         if (row["ownUserId"] != null && row["ownUserId"].ToString() != "")
         {
             model.ownUserId = int.Parse(row["ownUserId"].ToString());
         }
         if (row["checkUserId"] != null && row["checkUserId"].ToString() != "")
         {
             model.checkUserId = int.Parse(row["checkUserId"].ToString());
         }
         if (row["commentContent"] != null)
         {
             model.commentContent = row["commentContent"].ToString();
         }
         if (row["commentTime"] != null && row["commentTime"].ToString() != "")
         {
             model.commentTime = DateTime.Parse(row["commentTime"].ToString());
         }
         if (row["ext1"] != null)
         {
             model.ext1 = row["ext1"].ToString();
         }
         if (row["ext2"] != null)
         {
             model.ext2 = row["ext2"].ToString();
         }
         if (row["ext3"] != null)
         {
             model.ext3 = row["ext3"].ToString();
         }
     }
     return(model);
 }
예제 #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(rr2.Model.commentInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into commentInfo(");
            strSql.Append("newsId,ownUserId,checkUserId,commentContent,commentTime,ext1,ext2,ext3)");
            strSql.Append(" values (");
            strSql.Append("@newsId,@ownUserId,@checkUserId,@commentContent,@commentTime,@ext1,@ext2,@ext3)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@newsId",         SqlDbType.Int,          4),
                new SqlParameter("@ownUserId",      SqlDbType.Int,          4),
                new SqlParameter("@checkUserId",    SqlDbType.Int,          4),
                new SqlParameter("@commentContent", SqlDbType.VarChar,   1000),
                new SqlParameter("@commentTime",    SqlDbType.DateTime),
                new SqlParameter("@ext1",           SqlDbType.VarChar,    200),
                new SqlParameter("@ext2",           SqlDbType.VarChar,    200),
                new SqlParameter("@ext3",           SqlDbType.VarChar, 200)
            };
            parameters[0].Value = model.newsId;
            parameters[1].Value = model.ownUserId;
            parameters[2].Value = model.checkUserId;
            parameters[3].Value = model.commentContent;
            parameters[4].Value = model.commentTime;
            parameters[5].Value = model.ext1;
            parameters[6].Value = model.ext2;
            parameters[7].Value = model.ext3;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public rr2.Model.commentInfo GetModel(int commentId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 commentId,newsId,ownUserId,checkUserId,commentContent,commentTime,ext1,ext2,ext3 from commentInfo ");
            strSql.Append(" where commentId=@commentId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@commentId", SqlDbType.Int, 4)
            };
            parameters[0].Value = commentId;

            rr2.Model.commentInfo model = new rr2.Model.commentInfo();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
예제 #6
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtnewsId.Text))
            {
                strErr += "newsId格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtownUserId.Text))
            {
                strErr += "ownUserId格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtcheckUserId.Text))
            {
                strErr += "checkUserId格式错误!\\n";
            }
            if (this.txtcommentContent.Text.Trim().Length == 0)
            {
                strErr += "commentContent不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtcommentTime.Text))
            {
                strErr += "commentTime格式错误!\\n";
            }
            if (this.txtext1.Text.Trim().Length == 0)
            {
                strErr += "ext1不能为空!\\n";
            }
            if (this.txtext2.Text.Trim().Length == 0)
            {
                strErr += "ext2不能为空!\\n";
            }
            if (this.txtext3.Text.Trim().Length == 0)
            {
                strErr += "ext3不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      commentId      = int.Parse(this.lblcommentId.Text);
            int      newsId         = int.Parse(this.txtnewsId.Text);
            int      ownUserId      = int.Parse(this.txtownUserId.Text);
            int      checkUserId    = int.Parse(this.txtcheckUserId.Text);
            string   commentContent = this.txtcommentContent.Text;
            DateTime commentTime    = DateTime.Parse(this.txtcommentTime.Text);
            string   ext1           = this.txtext1.Text;
            string   ext2           = this.txtext2.Text;
            string   ext3           = this.txtext3.Text;


            rr2.Model.commentInfo model = new rr2.Model.commentInfo();
            model.commentId      = commentId;
            model.newsId         = newsId;
            model.ownUserId      = ownUserId;
            model.checkUserId    = checkUserId;
            model.commentContent = commentContent;
            model.commentTime    = commentTime;
            model.ext1           = ext1;
            model.ext2           = ext2;
            model.ext3           = ext3;

            rr2.BLL.commentInfo bll = new rr2.BLL.commentInfo();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }