Пример #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Matisoft.Model.FollowTable model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update FollowTable set ");
            strSql.Append("CustomerID=@CustomerID,");
            strSql.Append("FansEmail=@FansEmail,");
            strSql.Append("TimeDate=@TimeDate");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CustomerID", SqlDbType.Int,        4),
                new SqlParameter("@FansEmail",  SqlDbType.NVarChar,  50),
                new SqlParameter("@TimeDate",   SqlDbType.DateTime),
                new SqlParameter("@id",         SqlDbType.Int, 4)
            };
            parameters[0].Value = model.CustomerID;
            parameters[1].Value = model.FansEmail;
            parameters[2].Value = model.TimeDate;
            parameters[3].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Matisoft.Model.FollowTable model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into FollowTable(");
            strSql.Append("CustomerID,FansEmail,TimeDate)");
            strSql.Append(" values (");
            strSql.Append("@CustomerID,@FansEmail,@TimeDate)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CustomerID", SqlDbType.Int,       4),
                new SqlParameter("@FansEmail",  SqlDbType.NVarChar, 50),
                new SqlParameter("@TimeDate",   SqlDbType.DateTime)
            };
            parameters[0].Value = model.CustomerID;
            parameters[1].Value = model.FansEmail;
            parameters[2].Value = model.TimeDate;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Matisoft.Model.FollowTable DataRowToModel(DataRow row)
 {
     Matisoft.Model.FollowTable model = new Matisoft.Model.FollowTable();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["CustomerID"] != null && row["CustomerID"].ToString() != "")
         {
             model.CustomerID = int.Parse(row["CustomerID"].ToString());
         }
         if (row["FansEmail"] != null)
         {
             model.FansEmail = row["FansEmail"].ToString();
         }
         if (row["TimeDate"] != null && row["TimeDate"].ToString() != "")
         {
             model.TimeDate = DateTime.Parse(row["TimeDate"].ToString());
         }
     }
     return(model);
 }
Пример #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Matisoft.Model.FollowTable GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,CustomerID,FansEmail,TimeDate from FollowTable ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Пример #5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Matisoft.Model.FollowTable DataRowToModel(DataRow row)
 {
     Matisoft.Model.FollowTable model=new Matisoft.Model.FollowTable();
     if (row != null)
     {
         if(row["id"]!=null && row["id"].ToString()!="")
         {
             model.id=int.Parse(row["id"].ToString());
         }
         if(row["CustomerID"]!=null && row["CustomerID"].ToString()!="")
         {
             model.CustomerID=int.Parse(row["CustomerID"].ToString());
         }
         if(row["FansEmail"]!=null)
         {
             model.FansEmail=row["FansEmail"].ToString();
         }
         if(row["TimeDate"]!=null && row["TimeDate"].ToString()!="")
         {
             model.TimeDate=DateTime.Parse(row["TimeDate"].ToString());
         }
     }
     return model;
 }
Пример #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Matisoft.Model.FollowTable GetModel(int id)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 id,CustomerID,FansEmail,TimeDate from FollowTable ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)
            };
            parameters[0].Value = id;

            Matisoft.Model.FollowTable model=new Matisoft.Model.FollowTable();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }