Esempio n. 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(cycms.Model.Article model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update dbo_Article set ");
            strSql.Append("dbo_Title=@dbo_Title,");
            strSql.Append("dbo_Typeid=@dbo_Typeid,");
            strSql.Append("dbo_Content=@dbo_Content,");
            strSql.Append("dbo_Author=@dbo_Author,");
            strSql.Append("dbo_Source=@dbo_Source,");
            strSql.Append("dbo_Click=@dbo_Click,");
            strSql.Append("dbo_Ptime=@dbo_Ptime,");
            strSql.Append("dbo_Fujian=@dbo_Fujian,");
            strSql.Append("dbo_IsLock=@dbo_IsLock,");
            strSql.Append("dbo_IsTop=@dbo_IsTop");
            strSql.Append(" where ID=@ID");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@dbo_Title",   OleDbType.VarChar, 200),
                new OleDbParameter("@dbo_Typeid",  OleDbType.Integer,   4),
                new OleDbParameter("@dbo_Content", OleDbType.VarChar,   0),
                new OleDbParameter("@dbo_Author",  OleDbType.VarChar,  20),
                new OleDbParameter("@dbo_Source",  OleDbType.VarChar, 200),
                new OleDbParameter("@dbo_Click",   OleDbType.Integer,   4),
                new OleDbParameter("@dbo_Ptime",   OleDbType.Date),
                new OleDbParameter("@dbo_Fujian",  OleDbType.VarChar,   0),
                new OleDbParameter("@dbo_IsLock",  OleDbType.Boolean,   1),
                new OleDbParameter("@dbo_IsTop",   OleDbType.Boolean,   1),
                new OleDbParameter("@ID",          OleDbType.Integer, 4)
            };
            parameters[0].Value  = model.dbo_Title;
            parameters[1].Value  = model.dbo_Typeid;
            parameters[2].Value  = model.dbo_Content;
            parameters[3].Value  = model.dbo_Author;
            parameters[4].Value  = model.dbo_Source;
            parameters[5].Value  = model.dbo_Click;
            parameters[6].Value  = model.dbo_Ptime;
            parameters[7].Value  = model.dbo_Fujian;
            parameters[8].Value  = model.dbo_IsLock;
            parameters[9].Value  = model.dbo_IsTop;
            parameters[10].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(cycms.Model.Article model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into dbo_Article(");
            strSql.Append("dbo_Title,dbo_Typeid,dbo_Content,dbo_Author,dbo_Source,dbo_Click,dbo_Ptime,dbo_Fujian,dbo_IsLock,dbo_IsTop)");
            strSql.Append(" values (");
            strSql.Append("@dbo_Title,@dbo_Typeid,@dbo_Content,@dbo_Author,@dbo_Source,@dbo_Click,@dbo_Ptime,@dbo_Fujian,@dbo_IsLock,@dbo_IsTop)");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@dbo_Title",   OleDbType.VarChar, 200),
                new OleDbParameter("@dbo_Typeid",  OleDbType.Integer,   4),
                new OleDbParameter("@dbo_Content", OleDbType.VarChar,   0),
                new OleDbParameter("@dbo_Author",  OleDbType.VarChar,  20),
                new OleDbParameter("@dbo_Source",  OleDbType.VarChar, 200),
                new OleDbParameter("@dbo_Click",   OleDbType.Integer,   4),
                new OleDbParameter("@dbo_Ptime",   OleDbType.Date),
                new OleDbParameter("@dbo_Fujian",  OleDbType.VarChar,   0),
                new OleDbParameter("@dbo_IsLock",  OleDbType.Boolean,   1),
                new OleDbParameter("@dbo_IsTop",   OleDbType.Boolean, 1)
            };
            parameters[0].Value = model.dbo_Title;
            parameters[1].Value = model.dbo_Typeid;
            parameters[2].Value = model.dbo_Content;
            parameters[3].Value = model.dbo_Author;
            parameters[4].Value = model.dbo_Source;
            parameters[5].Value = model.dbo_Click;
            parameters[6].Value = model.dbo_Ptime;
            parameters[7].Value = model.dbo_Fujian;
            parameters[8].Value = model.dbo_IsLock;
            parameters[9].Value = model.dbo_IsTop;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add_ReturnID(cycms.Model.Article model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into dbo_Article(");
            strSql.Append("dbo_Title,dbo_Typeid,dbo_Content,dbo_Author,dbo_Source,dbo_Click,dbo_Ptime,dbo_Fujian,dbo_IsLock,dbo_IsTop)");
            strSql.Append(" values (");
            strSql.Append("@dbo_Title,@dbo_Typeid,@dbo_Content,@dbo_Author,@dbo_Source,@dbo_Click,@dbo_Ptime,@dbo_Fujian,@dbo_IsLock,@dbo_IsTop)");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@dbo_Title",   OleDbType.VarChar, 200),
                new OleDbParameter("@dbo_Typeid",  OleDbType.Integer,   4),
                new OleDbParameter("@dbo_Content", OleDbType.VarChar,   0),
                new OleDbParameter("@dbo_Author",  OleDbType.VarChar,  20),
                new OleDbParameter("@dbo_Source",  OleDbType.VarChar, 200),
                new OleDbParameter("@dbo_Click",   OleDbType.Integer,   4),
                new OleDbParameter("@dbo_Ptime",   OleDbType.Date),
                new OleDbParameter("@dbo_Fujian",  OleDbType.VarChar,   0),
                new OleDbParameter("@dbo_IsLock",  OleDbType.Boolean,   1),
                new OleDbParameter("@dbo_IsTop",   OleDbType.Boolean, 1)
            };
            parameters[0].Value = model.dbo_Title;
            parameters[1].Value = model.dbo_Typeid;
            parameters[2].Value = model.dbo_Content;
            parameters[3].Value = model.dbo_Author;
            parameters[4].Value = model.dbo_Source;
            parameters[5].Value = model.dbo_Click;
            parameters[6].Value = model.dbo_Ptime;
            parameters[7].Value = model.dbo_Fujian;
            parameters[8].Value = model.dbo_IsLock;
            parameters[9].Value = model.dbo_IsTop;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public cycms.Model.Article GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID,dbo_Title,dbo_Typeid,dbo_Content,dbo_Author,dbo_Source,dbo_Click,dbo_Ptime,dbo_Fujian,dbo_IsLock,dbo_IsTop from dbo_Article ");
            strSql.Append(" where ID=@ID");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@ID", OleDbType.Integer, 4)
            };
            parameters[0].Value = ID;

            cycms.Model.Article model = new cycms.Model.Article();
            DataSet             ds    = DbHelperOleDb.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public cycms.Model.Article DataRowToModel(DataRow row)
 {
     cycms.Model.Article model = new cycms.Model.Article();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["dbo_Title"] != null)
         {
             model.dbo_Title = row["dbo_Title"].ToString();
         }
         if (row["dbo_Typeid"] != null && row["dbo_Typeid"].ToString() != "")
         {
             model.dbo_Typeid = int.Parse(row["dbo_Typeid"].ToString());
         }
         if (row["dbo_Content"] != null)
         {
             model.dbo_Content = row["dbo_Content"].ToString();
         }
         if (row["dbo_Author"] != null)
         {
             model.dbo_Author = row["dbo_Author"].ToString();
         }
         if (row["dbo_Source"] != null)
         {
             model.dbo_Source = row["dbo_Source"].ToString();
         }
         if (row["dbo_Click"] != null && row["dbo_Click"].ToString() != "")
         {
             model.dbo_Click = int.Parse(row["dbo_Click"].ToString());
         }
         if (row["dbo_Ptime"] != null && row["dbo_Ptime"].ToString() != "")
         {
             model.dbo_Ptime = DateTime.Parse(row["dbo_Ptime"].ToString());
         }
         if (row["dbo_Fujian"] != null)
         {
             model.dbo_Fujian = row["dbo_Fujian"].ToString();
         }
         if (row["dbo_IsLock"] != null && row["dbo_IsLock"].ToString() != "")
         {
             if ((row["dbo_IsLock"].ToString() == "1") || (row["dbo_IsLock"].ToString().ToLower() == "true"))
             {
                 model.dbo_IsLock = true;
             }
             else
             {
                 model.dbo_IsLock = false;
             }
         }
         if (row["dbo_IsTop"] != null && row["dbo_IsTop"].ToString() != "")
         {
             if ((row["dbo_IsTop"].ToString() == "1") || (row["dbo_IsTop"].ToString().ToLower() == "true"))
             {
                 model.dbo_IsTop = true;
             }
             else
             {
                 model.dbo_IsTop = false;
             }
         }
     }
     return(model);
 }