示例#1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.NewsManage.NewsReply GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * from T_NewsReply ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;
            Maticsoft.Model.NewsManage.NewsReply model = new Maticsoft.Model.NewsManage.NewsReply();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            model.Id = Id;
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["NewsId"].ToString() != "")
                {
                    model.NewsId = int.Parse(ds.Tables[0].Rows[0]["NewsId"].ToString());
                }
                model.Content = ds.Tables[0].Rows[0]["Content"].ToString();
                if (ds.Tables[0].Rows[0]["IssueDate"].ToString() != "")
                {
                    model.IssueDate = DateTime.Parse(ds.Tables[0].Rows[0]["IssueDate"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
示例#2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.NewsManage.NewsReply GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * from T_NewsReply ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters = {
					new SqlParameter("@Id", SqlDbType.Int,4)};
            parameters[0].Value = Id;
            Maticsoft.Model.NewsManage.NewsReply model = new Maticsoft.Model.NewsManage.NewsReply();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            model.Id = Id;
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["NewsId"].ToString() != "")
                {
                    model.NewsId = int.Parse(ds.Tables[0].Rows[0]["NewsId"].ToString());
                }
                model.Content = ds.Tables[0].Rows[0]["Content"].ToString();
                if (ds.Tables[0].Rows[0]["IssueDate"].ToString() != "")
                {
                    model.IssueDate = DateTime.Parse(ds.Tables[0].Rows[0]["IssueDate"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }
示例#3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(Maticsoft.Model.NewsManage.NewsReply model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into T_NewsReply(");
            strSql.Append("NewsId,Content,IssueDate)");
            strSql.Append(" values (");
            strSql.Append("@NewsId,@Content,@IssueDate)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@NewsId",    SqlDbType.Int,   4),
                new SqlParameter("@Content",   SqlDbType.Text),
                new SqlParameter("@IssueDate", SqlDbType.DateTime)
            };
            parameters[0].Value = model.NewsId;
            parameters[1].Value = model.Content;
            parameters[2].Value = DateTime.Now;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
示例#4
0
文件: News.cs 项目: chinasio/Control
        /// <summary>
        /// �õ�һ������ʵ��(���ӱ��������)
        /// </summary>
        public Maticsoft.Model.NewsManage.News GetModel(int NewsId)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * from T_News ");
            strSql.Append(" where NewsId=@NewsId");
            SqlParameter[] parameters = {
                    new SqlParameter("@NewsId", SqlDbType.Int,4)};
            parameters[0].Value = NewsId;
            Maticsoft.Model.NewsManage.News model = new Maticsoft.Model.NewsManage.News();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            model.NewsId = NewsId;
            if (ds.Tables[0].Rows.Count > 0)
            {
                #region �ֶ���Ϣ
                if (ds.Tables[0].Rows[0]["UserId"].ToString() != "")
                {
                    model.UserId = int.Parse(ds.Tables[0].Rows[0]["UserId"].ToString());
                }
                model.Heading = ds.Tables[0].Rows[0]["Heading"].ToString();
                model.Content = ds.Tables[0].Rows[0]["Content"].ToString();
                if (ds.Tables[0].Rows[0]["Frequency"].ToString() != "")
                {
                    model.Frequency = int.Parse(ds.Tables[0].Rows[0]["Frequency"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IssueDate"].ToString() != "")
                {
                    model.IssueDate = DateTime.Parse(ds.Tables[0].Rows[0]["IssueDate"].ToString());
                }
                model.Dormancy = ds.Tables[0].Rows[0]["Dormancy"].ToString();
                if (ds.Tables[0].Rows[0]["ClassId"].ToString() != "")
                {
                    model.ClassId = int.Parse(ds.Tables[0].Rows[0]["ClassId"].ToString());
                }
                model.Focus = ds.Tables[0].Rows[0]["Focus"].ToString();
                if (ds.Tables[0].Rows[0]["Priority"].ToString() != "")
                {
                    model.Priority = int.Parse(ds.Tables[0].Rows[0]["Priority"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsTop"].ToString() != "")
                {
                    model.IsTop = int.Parse(ds.Tables[0].Rows[0]["IsTop"].ToString());
                }
                #endregion

                #region  ���Żظ���Ϣ
                StringBuilder strSqlR = new StringBuilder();
                strSqlR.Append("select * from T_NewsReply ");
                strSqlR.Append(" where NewsId=@NewsId");
                SqlParameter[] parametersr = {
                    new SqlParameter("@NewsId", SqlDbType.Int,4)};
                parametersr[0].Value = NewsId;
                DataSet dsR = DbHelperSQL.Query(strSqlR.ToString(), parametersr);

                if ((dsR.Tables.Count>0)&&(dsR.Tables[0].Rows.Count > 0))
                {
                    int i = dsR.Tables[0].Rows.Count;
                    List<Maticsoft.Model.NewsManage.NewsReply> newsReplys = new List<Maticsoft.Model.NewsManage.NewsReply>();
                    for (int n = 0; n < i; n++)
                    {
                        newsReplys[n] = new Maticsoft.Model.NewsManage.NewsReply();
                        if (dsR.Tables[0].Rows[0]["Id"].ToString() != "")
                        {
                            newsReplys[n].Id = int.Parse(dsR.Tables[0].Rows[0]["Id"].ToString());
                        }
                        if (dsR.Tables[0].Rows[0]["NewsId"].ToString() != "")
                        {
                            newsReplys[n].NewsId = int.Parse(dsR.Tables[0].Rows[0]["NewsId"].ToString());
                        }
                        newsReplys[n].Content = dsR.Tables[0].Rows[0]["Content"].ToString();
                        if (dsR.Tables[0].Rows[0]["IssueDate"].ToString() != "")
                        {
                            newsReplys[n].IssueDate = DateTime.Parse(dsR.Tables[0].Rows[0]["IssueDate"].ToString());
                        }

                    }
                    model.NewsReplys = newsReplys;
                }

                #endregion

                return model;
            }
            else
            {
                return null;
            }
        }
示例#5
0
        /// <summary>
        /// 得到一个对象实体(父子表,事务处理)
        /// </summary>
        public Maticsoft.Model.NewsManage.News GetModel(int NewsId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * from T_News ");
            strSql.Append(" where NewsId=@NewsId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@NewsId", SqlDbType.Int, 4)
            };
            parameters[0].Value = NewsId;
            Maticsoft.Model.NewsManage.News model = new Maticsoft.Model.NewsManage.News();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            model.NewsId = NewsId;
            if (ds.Tables[0].Rows.Count > 0)
            {
                #region 字段信息
                if (ds.Tables[0].Rows[0]["UserId"].ToString() != "")
                {
                    model.UserId = int.Parse(ds.Tables[0].Rows[0]["UserId"].ToString());
                }
                model.Heading = ds.Tables[0].Rows[0]["Heading"].ToString();
                model.Content = ds.Tables[0].Rows[0]["Content"].ToString();
                if (ds.Tables[0].Rows[0]["Frequency"].ToString() != "")
                {
                    model.Frequency = int.Parse(ds.Tables[0].Rows[0]["Frequency"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IssueDate"].ToString() != "")
                {
                    model.IssueDate = DateTime.Parse(ds.Tables[0].Rows[0]["IssueDate"].ToString());
                }
                model.Dormancy = ds.Tables[0].Rows[0]["Dormancy"].ToString();
                if (ds.Tables[0].Rows[0]["ClassId"].ToString() != "")
                {
                    model.ClassId = int.Parse(ds.Tables[0].Rows[0]["ClassId"].ToString());
                }
                model.Focus = ds.Tables[0].Rows[0]["Focus"].ToString();
                if (ds.Tables[0].Rows[0]["Priority"].ToString() != "")
                {
                    model.Priority = int.Parse(ds.Tables[0].Rows[0]["Priority"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsTop"].ToString() != "")
                {
                    model.IsTop = int.Parse(ds.Tables[0].Rows[0]["IsTop"].ToString());
                }
                #endregion

                #region  新闻回复信息
                StringBuilder strSqlR = new StringBuilder();
                strSqlR.Append("select * from T_NewsReply ");
                strSqlR.Append(" where NewsId=@NewsId");
                SqlParameter[] parametersr =
                {
                    new SqlParameter("@NewsId", SqlDbType.Int, 4)
                };
                parametersr[0].Value = NewsId;
                DataSet dsR = DbHelperSQL.Query(strSqlR.ToString(), parametersr);

                if ((dsR.Tables.Count > 0) && (dsR.Tables[0].Rows.Count > 0))
                {
                    int i = dsR.Tables[0].Rows.Count;
                    List <Maticsoft.Model.NewsManage.NewsReply> newsReplys = new List <Maticsoft.Model.NewsManage.NewsReply>();
                    for (int n = 0; n < i; n++)
                    {
                        newsReplys[n] = new Maticsoft.Model.NewsManage.NewsReply();
                        if (dsR.Tables[0].Rows[0]["Id"].ToString() != "")
                        {
                            newsReplys[n].Id = int.Parse(dsR.Tables[0].Rows[0]["Id"].ToString());
                        }
                        if (dsR.Tables[0].Rows[0]["NewsId"].ToString() != "")
                        {
                            newsReplys[n].NewsId = int.Parse(dsR.Tables[0].Rows[0]["NewsId"].ToString());
                        }
                        newsReplys[n].Content = dsR.Tables[0].Rows[0]["Content"].ToString();
                        if (dsR.Tables[0].Rows[0]["IssueDate"].ToString() != "")
                        {
                            newsReplys[n].IssueDate = DateTime.Parse(dsR.Tables[0].Rows[0]["IssueDate"].ToString());
                        }
                    }
                    model.NewsReplys = newsReplys;
                }

                #endregion

                return(model);
            }
            else
            {
                return(null);
            }
        }
示例#6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public void Add(Maticsoft.Model.NewsManage.NewsReply model)
 {
     dal.Add(model);
 }