Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.id = DTRequest.GetQueryInt("id");
            if (id == 0)
            {
                JscriptMsg("传输参数不正确!", "back");
                return;
            }
            if (!new BLL.article_comment().Exists(this.id))
            {
                JscriptMsg("记录不存在或已删除!", "back");
                return;
            }
            this.model        = new BLL.article_comment().GetModel(this.id);        //取得评论实体
            this.channel_name = new BLL.channel().GetChannelName(model.channel_id); //取得频道名称
            if (!Page.IsPostBack)
            {
                //浏览权限
                ChkAdminLevel("channel_" + this.channel_name + "_comment", DTEnums.ActionEnum.View.ToString());

                //回复权限
                if (!ChkAuthority("channel_" + this.channel_name + "_comment", DTEnums.ActionEnum.Reply.ToString()))
                {
                    this.btnSubmit.Visible = false;
                }

                ShowInfo();
            }
        }
Example #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.article_comment GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,channel_id,article_id,parent_id,user_id,user_name,user_ip,content,is_lock,add_time,is_reply,reply_content,reply_time");
            strSql.Append(" from " + databaseprefix + "article_comment ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Example #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.article_comment model)
        {
            StringBuilder strSql = new StringBuilder();
            StringBuilder str1   = new StringBuilder();

            //利用反射获得属性的所有公共属性
            PropertyInfo[]      pros  = model.GetType().GetProperties();
            List <SqlParameter> paras = new List <SqlParameter>();

            strSql.Append("update  " + databaseprefix + "article_comment set ");
            foreach (PropertyInfo pi in pros)
            {
                //如果不是主键则追加sql字符串
                if (!pi.Name.Equals("id"))
                {
                    //判断属性值是否为空
                    if (pi.GetValue(model, null) != null)
                    {
                        str1.Append(pi.Name + "=@" + pi.Name + ",");                          //声明参数
                        paras.Add(new SqlParameter("@" + pi.Name, pi.GetValue(model, null))); //对参数赋值
                    }
                }
            }
            strSql.Append(str1.ToString().Trim(','));
            strSql.Append(" where id=@id");
            paras.Add(new SqlParameter("@id", model.id));
            return(DbHelperSQL.ExecuteSql(strSql.ToString(), paras.ToArray()) > 0);
        }
Example #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.article_comment GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            StringBuilder str1   = new StringBuilder();

            Model.article_comment model = new Model.article_comment();
            //利用反射获得属性的所有公共属性
            PropertyInfo[] pros = model.GetType().GetProperties();
            foreach (PropertyInfo p in pros)
            {
                str1.Append(p.Name + ",");//拼接字段
            }
            strSql.Append("select top 1 " + str1.ToString().Trim(','));
            strSql.Append(" from " + databaseprefix + "article_comment");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;
            DataTable dt = DbHelperSQL.Query(strSql.ToString(), parameters).Tables[0];

            if (dt.Rows.Count > 0)
            {
                return(DataRowToModel(dt.Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Example #5
0
        /// 添加留言
        /// </summary>
        public void message(HttpContext context)
        {
            string outmsg       = "{\"status\":1,\"msg\":\"留言成功!\"}";
            string messagename  = _Request.GetString("messagename");
            string messagmodile = _Request.GetString("messagmodile");
            string messageemail = _Request.GetString("messageemail");
            string messageliu   = _Request.GetString("messageliu");

            Model.article_comment model = new Model.article_comment();
            BLL.article_comment   bll   = new BLL.article_comment();
            model.user_name     = messagename;
            model.channel_id    = 1;
            model.user_ip       = messagmodile;
            model.content       = messageemail;
            model.reply_content = messageliu;
            model.add_time      = DateTime.Now;
            int id = bll.Add(model);

            if (id > 0)
            {
                context.Response.Clear();
                context.Response.Write(outmsg);
                context.Response.End();
            }
            else
            {
                context.Response.Clear();
                context.Response.Write("{\"status\":0,\"msg\":\"留言失败请稍候再试!\"}");
                context.Response.End();
            }
        }
Example #6
0
 /// <summary>
 /// �õ�һ������ʵ��
 /// </summary>
 public Model.article_comment DataRowToModel(DataRow row)
 {
     Model.article_comment model = new Model.article_comment();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["channel_id"] != null && row["channel_id"].ToString() != "")
         {
             model.channel_id = int.Parse(row["channel_id"].ToString());
         }
         if (row["article_id"] != null && row["article_id"].ToString() != "")
         {
             model.article_id = int.Parse(row["article_id"].ToString());
         }
         if (row["parent_id"] != null && row["parent_id"].ToString() != "")
         {
             model.parent_id = int.Parse(row["parent_id"].ToString());
         }
         if (row["user_id"] != null && row["user_id"].ToString() != "")
         {
             model.user_id = int.Parse(row["user_id"].ToString());
         }
         if (row["user_name"] != null)
         {
             model.user_name = row["user_name"].ToString();
         }
         if (row["user_ip"] != null)
         {
             model.user_ip = row["user_ip"].ToString();
         }
         if (row["content"] != null)
         {
             model.content = row["content"].ToString();
         }
         if (row["is_lock"] != null && row["is_lock"].ToString() != "")
         {
             model.is_lock = int.Parse(row["is_lock"].ToString());
         }
         if (row["add_time"] != null && row["add_time"].ToString() != "")
         {
             model.add_time = DateTime.Parse(row["add_time"].ToString());
         }
         if (row["is_reply"] != null && row["is_reply"].ToString() != "")
         {
             model.is_reply = int.Parse(row["is_reply"].ToString());
         }
         if (row["reply_content"] != null)
         {
             model.reply_content = row["reply_content"].ToString();
         }
         if (row["reply_time"] != null && row["reply_time"].ToString() != "")
         {
             model.reply_time = DateTime.Parse(row["reply_time"].ToString());
         }
     }
     return model;
 }
Example #7
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Model.article_comment DataRowToModel(DataRow row)
 {
     Model.article_comment model = new Model.article_comment();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["channel_id"] != null && row["channel_id"].ToString() != "")
         {
             model.channel_id = int.Parse(row["channel_id"].ToString());
         }
         if (row["article_id"] != null && row["article_id"].ToString() != "")
         {
             model.article_id = int.Parse(row["article_id"].ToString());
         }
         if (row["parent_id"] != null && row["parent_id"].ToString() != "")
         {
             model.parent_id = int.Parse(row["parent_id"].ToString());
         }
         if (row["user_id"] != null && row["user_id"].ToString() != "")
         {
             model.user_id = int.Parse(row["user_id"].ToString());
         }
         if (row["user_name"] != null)
         {
             model.user_name = row["user_name"].ToString();
         }
         if (row["user_ip"] != null)
         {
             model.user_ip = row["user_ip"].ToString();
         }
         if (row["content"] != null)
         {
             model.content = row["content"].ToString();
         }
         if (row["is_lock"] != null && row["is_lock"].ToString() != "")
         {
             model.is_lock = int.Parse(row["is_lock"].ToString());
         }
         if (row["add_time"] != null && row["add_time"].ToString() != "")
         {
             model.add_time = DateTime.Parse(row["add_time"].ToString());
         }
         if (row["is_reply"] != null && row["is_reply"].ToString() != "")
         {
             model.is_reply = int.Parse(row["is_reply"].ToString());
         }
         if (row["reply_content"] != null)
         {
             model.reply_content = row["reply_content"].ToString();
         }
         if (row["reply_time"] != null && row["reply_time"].ToString() != "")
         {
             model.reply_time = DateTime.Parse(row["reply_time"].ToString());
         }
     }
     return(model);
 }
Example #8
0
        public async Task <StatusModel> CommentAdd(CommentAddModel amodel)
        {
            StringBuilder strTxt = new StringBuilder();

            BLL.article_comment   bll   = new BLL.article_comment();
            Model.article_comment model = new Model.article_comment();

            if (amodel.articleId == 0)
            {
                return(new StatusModel {
                    status = 0, msg = "对不起,参数传输有误!"
                });
            }
            if (string.IsNullOrEmpty(amodel.content))
            {
                return(new StatusModel()
                {
                    status = 0, msg = "对不起,请输入评论的内容!"
                });
            }
            //检查该文章是否存在
            Model.article artModel = new BLL.article().GetModel(amodel.articleId);
            if (artModel == null)
            {
                return(new StatusModel()
                {
                    status = 0, msg = "对不起,主题不存在或已删除!"
                });
            }
            //检查用户是否登录
            int    user_id   = 0;
            string user_name = "匿名用户";
            var    user      = await UserManager.FindByIdAsync(int.Parse(User.Identity.GetUserId()));

            if (user != null)
            {
                user_id   = user.id;
                user_name = user.user_name;
            }
            model.channel_id = artModel.channel_id;
            model.article_id = artModel.id;
            model.content    = Utils.ToHtml(amodel.content);
            model.user_id    = user_id;
            model.user_name  = user_name;
            model.user_ip    = DTRequest.GetIP();
            model.is_lock    = siteConfig.commentstatus; //审核开关
            model.add_time   = DateTime.Now;
            model.is_reply   = 0;
            if (bll.Add(model) > 0)
            {
                return(new StatusModel()
                {
                    status = 1, msg = "留言提交成功!"
                });
            }
            return(new StatusModel()
            {
                status = 0, msg = "对不起,保存过程中发生错误!"
            });
        }
Example #9
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.article_comment model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update " + databaseprefix + "article_comment set ");
            strSql.Append("channel_id=@channel_id,");
            strSql.Append("article_id=@article_id,");
            strSql.Append("parent_id=@parent_id,");
            strSql.Append("user_id=@user_id,");
            strSql.Append("user_name=@user_name,");
            strSql.Append("user_ip=@user_ip,");
            strSql.Append("content=@content,");
            strSql.Append("is_lock=@is_lock,");
            strSql.Append("add_time=@add_time,");
            strSql.Append("is_reply=@is_reply,");
            strSql.Append("reply_content=@reply_content,");
            strSql.Append("reply_time=@reply_time");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",            SqlDbType.Int,         4),
                new SqlParameter("@channel_id",    SqlDbType.Int,         4),
                new SqlParameter("@article_id",    SqlDbType.Int,         4),
                new SqlParameter("@parent_id",     SqlDbType.Int,         4),
                new SqlParameter("@user_id",       SqlDbType.Int,         4),
                new SqlParameter("@user_name",     SqlDbType.NVarChar,  100),
                new SqlParameter("@user_ip",       SqlDbType.NVarChar,  255),
                new SqlParameter("@content",       SqlDbType.NText),
                new SqlParameter("@is_lock",       SqlDbType.TinyInt,     1),
                new SqlParameter("@add_time",      SqlDbType.DateTime),
                new SqlParameter("@is_reply",      SqlDbType.TinyInt,     1),
                new SqlParameter("@reply_content", SqlDbType.NText),
                new SqlParameter("@reply_time",    SqlDbType.DateTime)
            };
            parameters[0].Value  = model.id;
            parameters[1].Value  = model.channel_id;
            parameters[2].Value  = model.article_id;
            parameters[3].Value  = model.parent_id;
            parameters[4].Value  = model.user_id;
            parameters[5].Value  = model.user_name;
            parameters[6].Value  = model.user_ip;
            parameters[7].Value  = model.content;
            parameters[8].Value  = model.is_lock;
            parameters[9].Value  = model.add_time;
            parameters[10].Value = model.is_reply;
            parameters[11].Value = model.reply_content;
            parameters[12].Value = model.reply_time;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #10
0
 private void ShowInfo(int _id)
 {
     ChkAdminLevel("sys_comment", DTEnums.ActionEnum.View.ToString()); //检查权限
     BLL.article_comment bll = new BLL.article_comment();
     model                   = bll.GetModel(_id);
     txtReContent.Text       = Utils.ToTxt(model.reply_content);
     rblIsLock.SelectedValue = model.is_lock.ToString();
 }
Example #11
0
 private void ShowInfo(int _id)
 {
     ChkAdminLevel("sys_comment", DTEnums.ActionEnum.View.ToString()); //检查权限
     BLL.article_comment bll = new BLL.article_comment();
     model = bll.GetModel(_id);
     txtReContent.Text = Utils.ToTxt(model.reply_content);
     rblIsLock.SelectedValue = model.is_lock.ToString();
 }
Example #12
0
 private void ShowInfo(int _id)
 {
     BLL.article_comment bll = new BLL.article_comment();
     model = bll.GetModel(_id);
     txtReContent.Text = Utils.ToTxt(model.reply_content);
     rblIsLock.SelectedValue = model.is_lock.ToString();
     this.channel_name = new BLL.channel().GetChannelName(model.channel_id); //取得频道名称
 }
Example #13
0
 private void ShowInfo(int _id)
 {
     BLL.article_comment bll = new BLL.article_comment();
     model                   = bll.GetModel(_id);
     txtReContent.Text       = Vincent._DTcms.Utils.ToTxt(model.reply_content);
     rblIsLock.SelectedValue = model.is_lock.ToString();
     this.channel_name       = new BLL.channel().GetChannelName(model.channel_id); //取得频道名称
 }
Example #14
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.article_comment model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + databaseprefix + "article_comment(");
            strSql.Append("channel_id,article_id,parent_id,user_id,user_name,user_ip,content,is_lock,add_time,is_reply,reply_content,reply_time,data_type,comment_type,order_id)");
            strSql.Append(" values (");
            strSql.Append("@channel_id,@article_id,@parent_id,@user_id,@user_name,@user_ip,@content,@is_lock,@add_time,@is_reply,@reply_content,@reply_time,@data_type,@comment_type,@order_id)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@channel_id",    SqlDbType.Int,         4),
                new SqlParameter("@article_id",    SqlDbType.Int,         4),
                new SqlParameter("@parent_id",     SqlDbType.Int,         4),
                new SqlParameter("@user_id",       SqlDbType.Int,         4),
                new SqlParameter("@user_name",     SqlDbType.NVarChar,  100),
                new SqlParameter("@user_ip",       SqlDbType.NVarChar,  255),
                new SqlParameter("@content",       SqlDbType.NText),
                new SqlParameter("@is_lock",       SqlDbType.TinyInt,     1),
                new SqlParameter("@add_time",      SqlDbType.DateTime),
                new SqlParameter("@is_reply",      SqlDbType.TinyInt,     1),
                new SqlParameter("@reply_content", SqlDbType.NText),
                new SqlParameter("@reply_time",    SqlDbType.DateTime),
                new SqlParameter("@data_type",     SqlDbType.TinyInt,     1),
                new SqlParameter("@comment_type",  SqlDbType.TinyInt,     1),
                new SqlParameter("@order_id",      SqlDbType.NVarChar, 100)
            };
            parameters[0].Value  = model.channel_id;
            parameters[1].Value  = model.article_id;
            parameters[2].Value  = model.parent_id;
            parameters[3].Value  = model.user_id;
            parameters[4].Value  = model.user_name;
            parameters[5].Value  = model.user_ip;
            parameters[6].Value  = model.content;
            parameters[7].Value  = model.is_lock;
            parameters[8].Value  = model.add_time;
            parameters[9].Value  = model.is_reply;
            parameters[10].Value = model.reply_content;
            parameters[11].Value = model.reply_time;
            parameters[12].Value = model.data_type;
            parameters[13].Value = model.comment_type;
            parameters[14].Value = model.order_id;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Example #15
0
 //保存
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     ChkAdminLevel("sys_comment", DTEnums.ActionEnum.Reply.ToString()); //检查权限
     BLL.article_comment bll = new BLL.article_comment();
     model = bll.GetModel(this.id);
     model.is_reply = 1;
     model.reply_content = Utils.ToHtml(txtReContent.Text);
     model.is_lock = int.Parse(rblIsLock.SelectedValue);
     model.reply_time = DateTime.Now;
     bll.Update(model);
     JscriptMsg("评论回复成功啦!", "list.aspx", "Success");
 }
Example #16
0
 //保存
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     ChkAdminLevel("sys_comment", DTEnums.ActionEnum.Reply.ToString()); //检查权限
     BLL.article_comment bll = new BLL.article_comment();
     model               = bll.GetModel(this.id);
     model.is_reply      = 1;
     model.reply_content = Utils.ToHtml(txtReContent.Text);
     model.is_lock       = int.Parse(rblIsLock.SelectedValue);
     model.reply_time    = DateTime.Now;
     bll.Update(model);
     JscriptMsg("评论回复成功啦!", "list.aspx", "Success");
 }
Example #17
0
 //保存
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     ChkAdminLevel("channel_" + this.channel_name + "_comment", MXEnums.ActionEnum.Reply.ToString()); //检查权限
     BLL.article_comment bll = new BLL.article_comment();
     model = bll.GetModel(this.id);
     model.is_reply = 1;
     model.reply_content = Utils.ToHtml(txtReContent.Text);
     model.is_lock = int.Parse(rblIsLock.SelectedValue);
     model.reply_time = DateTime.Now;
     bll.Update(model);
     AddAdminLog(MXEnums.ActionEnum.Reply.ToString(), "回复" + this.channel_name + "频道评论ID:" + model.id); //记录日志
     JscriptMsg("评论回复成功!", "comment_list.aspx?channel_id=" + model.channel_id, "Success");
 }
Example #18
0
 //保存
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     ChkAdminLevel("channel_" + this.channel_name + "_comment", Vincent._DTcms.DTEnums.ActionEnum.Reply.ToString()); //检查权限
     BLL.article_comment bll = new BLL.article_comment();
     model               = bll.GetModel(this.id);
     model.is_reply      = 1;
     model.reply_content = Vincent._DTcms.Utils.ToHtml(txtReContent.Text);
     model.is_lock       = int.Parse(rblIsLock.SelectedValue);
     model.reply_time    = DateTime.Now;
     bll.Update(model);
     AddAdminLog(Vincent._DTcms.DTEnums.ActionEnum.Reply.ToString(), "回复" + this.channel_name + "频道评论ID:" + model.id); //记录日志
     JscriptMsg("评论回复成功!", "comment_list.aspx?channel_id=" + model.channel_id, "Success");
 }
Example #19
0
 /// <summary>
 /// 将对象转换实体
 /// </summary>
 public Model.article_comment DataRowToModel(DataRow row)
 {
     Model.article_comment model = new Model.article_comment();
     if (row != null)
     {
         //利用反射获得属性的所有公共属性
         Type modelType = model.GetType();
         for (int i = 0; i < row.Table.Columns.Count; i++)
         {
             //查找实体是否存在列表相同的公共属性
             PropertyInfo proInfo = modelType.GetProperty(row.Table.Columns[i].ColumnName);
             if (proInfo != null && row[i] != DBNull.Value)
             {
                 proInfo.SetValue(model, row[i], null);//用索引值设置属性值
             }
         }
     }
     return(model);
 }
Example #20
0
 protected void Page_Load(object sender, EventArgs e)
 {
     this.id = DTRequest.GetQueryInt("id");
     if (id == 0)
     {
         JscriptMsg("传输参数不正确!", "back");
         return;
     }
     if (!new BLL.article_comment().Exists(this.id))
     {
         JscriptMsg("记录不存在或已删除!", "back");
         return;
     }
     this.model = new BLL.article_comment().GetModel(this.id); //取得评论实体
     this.channel_name = new BLL.channel().GetChannelName(model.channel_id); //取得频道名称
     if (!Page.IsPostBack)
     {
         ShowInfo();
     }
 }
Example #21
0
 protected void Page_Load(object sender, EventArgs e)
 {
     this.id = DTRequest.GetQueryInt("id");
     if (id == 0)
     {
         JscriptMsg("传输参数不正确!", "back");
         return;
     }
     if (!new BLL.article_comment().Exists(this.id))
     {
         JscriptMsg("记录不存在或已删除!", "back");
         return;
     }
     this.model        = new BLL.article_comment().GetModel(this.id);             //取得评论实体
     this.channel_name = new BLL.site_channel().GetChannelName(model.channel_id); //取得频道名称
     if (!Page.IsPostBack)
     {
         ShowInfo();
     }
 }
Example #22
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.article_comment model)
        {
            StringBuilder strSql = new StringBuilder();
            StringBuilder str1   = new StringBuilder(); //数据字段
            StringBuilder str2   = new StringBuilder(); //数据参数

            //利用反射获得属性的所有公共属性
            PropertyInfo[]      pros  = model.GetType().GetProperties();
            List <SqlParameter> paras = new List <SqlParameter>();

            strSql.Append("insert into  " + databaseprefix + "article_comment(");
            foreach (PropertyInfo pi in pros)
            {
                //如果不是主键则追加sql字符串
                if (!pi.Name.Equals("id"))
                {
                    //判断属性值是否为空
                    if (pi.GetValue(model, null) != null)
                    {
                        str1.Append(pi.Name + ",");                                           //拼接字段
                        str2.Append("@" + pi.Name + ",");                                     //声明参数
                        paras.Add(new SqlParameter("@" + pi.Name, pi.GetValue(model, null))); //对参数赋值
                    }
                }
            }
            strSql.Append(str1.ToString().Trim(','));
            strSql.Append(") values (");
            strSql.Append(str2.ToString().Trim(','));
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY;");
            object obj = DbHelperSQL.GetSingle(strSql.ToString(), paras.ToArray());

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Example #23
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.article_comment model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into dt_article_comment(");
            strSql.Append("article_id,user_id,user_name,user_ip,content,is_lock,add_time)");
            strSql.Append(" values (");
            strSql.Append("@article_id,@user_id,@user_name,@user_ip,@content,@is_lock,@add_time)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@article_id", SqlDbType.Int,        4),
                new SqlParameter("@user_id",    SqlDbType.Int,        4),
                new SqlParameter("@user_name",  SqlDbType.NVarChar, 100),
                new SqlParameter("@user_ip",    SqlDbType.NVarChar, 255),
                new SqlParameter("@content",    SqlDbType.NText),
                new SqlParameter("@is_lock",    SqlDbType.TinyInt,    1),
                new SqlParameter("@add_time",   SqlDbType.DateTime)
            };
            parameters[0].Value = model.article_id;
            parameters[1].Value = model.user_id;
            parameters[2].Value = model.user_name;
            parameters[3].Value = model.user_ip;
            parameters[4].Value = model.content;
            parameters[5].Value = model.is_lock;
            parameters[6].Value = model.add_time;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Example #24
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Model.article_comment model = new Model.article_comment();
            //HttpCookie cook = Request.Cookies["WEBUSERID"];
            string cook = Utils.GetCookie("WEBUSERID").ToString();

            if (cook == null)
            {
                this.Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('請先登入');window.location.href='login_vip.aspx'</script>");
            }
            else
            {
                //ids = cook.Value;
            }
            string Content = Request.Form["txtContent"];

            model.content    = DTcms.Common.Utils.ToHtml(Content);
            model.article_id = id;
            model.user_ip    = DTcms.Common.DTRequest.GetIP();
            BLL.article_comment bll = new BLL.article_comment();
            bll.Add(model);
            this.Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('送出成功');window.location.href='productview.aspx?id=" + id + "&mid=2'</script>");
        }
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(Model.article_comment model)
 {
     return(dal.Add(model));
 }
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.article_comment model)
 {
     return(dal.Update(model));
 }
Example #27
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.article_comment model)
        {
            int newId;

            using (OleDbConnection conn = new OleDbConnection(DbHelperOleDb.connectionString))
            {
                conn.Open();
                using (OleDbTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("insert into " + databaseprefix + "article_comment(");
                        strSql.Append("channel_id,article_id,parent_id,user_id,user_name,user_ip,content,is_lock,add_time,is_reply,reply_content,reply_time)");
                        strSql.Append(" values (");
                        strSql.Append("@channel_id,@article_id,@parent_id,@user_id,@user_name,@user_ip,@content,@is_lock,@add_time,@is_reply,@reply_content,@reply_time)");
                        OleDbParameter[] parameters =
                        {
                            new OleDbParameter("@channel_id",    OleDbType.Integer,    4),
                            new OleDbParameter("@article_id",    OleDbType.Integer,    4),
                            new OleDbParameter("@parent_id",     OleDbType.Integer,    4),
                            new OleDbParameter("@user_id",       OleDbType.Integer,    4),
                            new OleDbParameter("@user_name",     OleDbType.VarChar,  100),
                            new OleDbParameter("@user_ip",       OleDbType.VarChar,  255),
                            new OleDbParameter("@content",       OleDbType.VarChar),
                            new OleDbParameter("@is_lock",       OleDbType.Integer,    4),
                            new OleDbParameter("@add_time",      OleDbType.Date),
                            new OleDbParameter("@is_reply",      OleDbType.Integer,    4),
                            new OleDbParameter("@reply_content", OleDbType.VarChar),
                            new OleDbParameter("@reply_time",    OleDbType.Date)
                        };
                        parameters[0].Value = model.channel_id;
                        parameters[1].Value = model.article_id;
                        parameters[2].Value = model.parent_id;
                        parameters[3].Value = model.user_id;
                        parameters[4].Value = model.user_name;
                        parameters[5].Value = model.user_ip;
                        parameters[6].Value = model.content;
                        parameters[7].Value = model.is_lock;
                        parameters[8].Value = model.add_time;
                        parameters[9].Value = model.is_reply;
                        if (model.reply_content != null)
                        {
                            parameters[10].Value = model.reply_content;
                        }
                        else
                        {
                            parameters[10].Value = DBNull.Value;
                        }
                        if (model.reply_time != null)
                        {
                            parameters[11].Value = model.reply_time;
                        }
                        else
                        {
                            parameters[11].Value = DBNull.Value;
                        }

                        DbHelperOleDb.ExecuteSql(conn, trans, strSql.ToString(), parameters);
                        //取得新插入的ID
                        newId = GetMaxId(conn, trans);
                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        return(-1);
                    }
                }
            }
            return(newId);
        }
Example #28
0
        /// <summary>
        /// �õ�һ������ʵ��
        /// </summary>
        public Model.article_comment GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 id,channel_id,article_id,parent_id,user_id,user_name,user_ip,content,is_lock,add_time,is_reply,reply_content,reply_time");
            strSql.Append(" from " + databaseprefix + "article_comment ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters[0].Value = id;

            Model.article_comment model = new Model.article_comment();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }
Example #29
0
        /// <summary>
        /// �õ�һ������ʵ��
        /// </summary>
        public Model.article_comment GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 id,article_id,user_id,user_name,user_ip,content,is_lock,add_time,is_reply,reply_content,reply_time from dt_article_comment ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters[0].Value = id;

            Model.article_comment model = new Model.article_comment();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["article_id"] != null && ds.Tables[0].Rows[0]["article_id"].ToString() != "")
                {
                    model.article_id = int.Parse(ds.Tables[0].Rows[0]["article_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["user_id"] != null && ds.Tables[0].Rows[0]["user_id"].ToString() != "")
                {
                    model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["user_name"] != null && ds.Tables[0].Rows[0]["user_name"].ToString() != "")
                {
                    model.user_name = ds.Tables[0].Rows[0]["user_name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["user_ip"] != null && ds.Tables[0].Rows[0]["user_ip"].ToString() != "")
                {
                    model.user_ip = ds.Tables[0].Rows[0]["user_ip"].ToString();
                }
                if (ds.Tables[0].Rows[0]["content"] != null && ds.Tables[0].Rows[0]["content"].ToString() != "")
                {
                    model.content = ds.Tables[0].Rows[0]["content"].ToString();
                }
                if (ds.Tables[0].Rows[0]["is_lock"] != null && ds.Tables[0].Rows[0]["is_lock"].ToString() != "")
                {
                    model.is_lock = int.Parse(ds.Tables[0].Rows[0]["is_lock"].ToString());
                }
                if (ds.Tables[0].Rows[0]["add_time"] != null && ds.Tables[0].Rows[0]["add_time"].ToString() != "")
                {
                    model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
                }
                if (ds.Tables[0].Rows[0]["is_reply"] != null && ds.Tables[0].Rows[0]["is_reply"].ToString() != "")
                {
                    model.is_reply = int.Parse(ds.Tables[0].Rows[0]["is_reply"].ToString());
                }
                if (ds.Tables[0].Rows[0]["reply_content"] != null && ds.Tables[0].Rows[0]["reply_content"].ToString() != "")
                {
                    model.reply_content = ds.Tables[0].Rows[0]["reply_content"].ToString();
                }
                if (ds.Tables[0].Rows[0]["reply_time"] != null && ds.Tables[0].Rows[0]["reply_time"].ToString() != "")
                {
                    model.reply_time = DateTime.Parse(ds.Tables[0].Rows[0]["reply_time"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }
Example #30
0
        private void comment_add(HttpContext context)
        {
            StringBuilder strTxt = new StringBuilder();
            BLL.article_comment bll = new BLL.article_comment();
            Model.article_comment model = new Model.article_comment();

            string code = DTRequest.GetFormString("txtCode");
            int article_id = DTRequest.GetQueryInt("article_id");
            string _content = DTRequest.GetFormString("txtContent");
            //校检验证码
            string result =verify_code(context, code);
            if (result != "success")
            {
                context.Response.Write(result);
                return;
            }
            if (article_id == 0)
            {
                context.Response.Write("{\"msg\": 0, \"msgbox\": \"对不起,参数传输有误!\"}");
                return;
            }
            if (string.IsNullOrEmpty(_content))
            {
                context.Response.Write("{\"msg\": 0, \"msgbox\": \"对不起,请输入评论的内容!\"}");
                return;
            }
            //检查用户是否登录
            int user_id = 0;
            string user_name = "匿名用户";
            Model.users userModel = new Web.UI.BasePage().GetUserInfo();
            if (userModel != null)
            {
                user_id = userModel.id;
                user_name = userModel.user_name;
            }
            model.article_id = article_id;
            model.content = Utils.ToHtml(_content);
            model.user_id = user_id;
            model.user_name = user_name;
            model.user_ip = DTRequest.GetIP();
            model.is_lock = siteConfig.commentstatus; //审核开关
            model.add_time = DateTime.Now;
            model.is_reply = 0;
            if (bll.Add(model) > 0)
            {
                context.Response.Write("{\"msg\": 1, \"msgbox\": \"恭喜您,留言提交成功啦!\"}");
                return;
            }
            context.Response.Write("{\"msg\": 0, \"msgbox\": \"对不起,保存过程中发生错误!\"}");
            return;
        }
Example #31
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.article_comment GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,channel_id,article_id,parent_id,user_id,user_name,user_ip,content,is_lock,add_time,is_reply,reply_content,reply_time");
            strSql.Append(" from " + databaseprefix + "article_comment ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["channel_id"].ToString() != "")
                {
                    model.channel_id = int.Parse(ds.Tables[0].Rows[0]["channel_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["article_id"].ToString() != "")
                {
                    model.article_id = int.Parse(ds.Tables[0].Rows[0]["article_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["parent_id"].ToString() != "")
                {
                    model.parent_id = int.Parse(ds.Tables[0].Rows[0]["parent_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["user_id"].ToString() != "")
                {
                    model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
                }
                model.user_name = ds.Tables[0].Rows[0]["user_name"].ToString();
                model.user_ip   = ds.Tables[0].Rows[0]["user_ip"].ToString();
                model.content   = ds.Tables[0].Rows[0]["content"].ToString();
                if (ds.Tables[0].Rows[0]["is_lock"].ToString() != "")
                {
                    model.is_lock = int.Parse(ds.Tables[0].Rows[0]["is_lock"].ToString());
                }
                if (ds.Tables[0].Rows[0]["add_time"].ToString() != "")
                {
                    model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
                }
                if (ds.Tables[0].Rows[0]["is_reply"].ToString() != "")
                {
                    model.is_reply = int.Parse(ds.Tables[0].Rows[0]["is_reply"].ToString());
                }
                model.reply_content = ds.Tables[0].Rows[0]["reply_content"].ToString();
                if (ds.Tables[0].Rows[0]["reply_time"].ToString() != "")
                {
                    model.reply_time = DateTime.Parse(ds.Tables[0].Rows[0]["reply_time"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }