Example #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(System.Model.ispush model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ispush(");
            strSql.Append("ispushvalue,device,clientType,customId");
            strSql.Append(") values (");
            strSql.Append("@ispushvalue,@device,@clientType,@customId");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ispushvalue", SqlDbType.Int,       4),
                new SqlParameter("@device",      SqlDbType.NVarChar, 50),
                new SqlParameter("@clientType",  SqlDbType.Int,       4),
                new SqlParameter("@customId",    SqlDbType.NVarChar, 50)
            };

            parameters[0].Value = model.ispushvalue;
            parameters[1].Value = model.device;
            parameters[2].Value = model.clientType;
            parameters[3].Value = model.customId;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Example #2
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <System.Model.ispush> DataTableToList(DataTable dt)
        {
            List <System.Model.ispush> modelList = new List <System.Model.ispush>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                System.Model.ispush model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new System.Model.ispush();
                    if (dt.Rows[n]["id"].ToString() != "")
                    {
                        model.id = int.Parse(dt.Rows[n]["id"].ToString());
                    }
                    if (dt.Rows[n]["ispushvalue"].ToString() != "")
                    {
                        model.ispushvalue = int.Parse(dt.Rows[n]["ispushvalue"].ToString());
                    }
                    model.device = dt.Rows[n]["device"].ToString();
                    if (dt.Rows[n]["clientType"].ToString() != "")
                    {
                        model.clientType = int.Parse(dt.Rows[n]["clientType"].ToString());
                    }
                    model.customId = dt.Rows[n]["customId"].ToString();


                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Example #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public System.Model.ispush GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id, ispushvalue, device, clientType, customId  ");
            strSql.Append("  from ispush ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;


            System.Model.ispush model = new System.Model.ispush();
            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]["ispushvalue"].ToString() != "")
                {
                    model.ispushvalue = int.Parse(ds.Tables[0].Rows[0]["ispushvalue"].ToString());
                }
                model.device = ds.Tables[0].Rows[0]["device"].ToString();
                if (ds.Tables[0].Rows[0]["clientType"].ToString() != "")
                {
                    model.clientType = int.Parse(ds.Tables[0].Rows[0]["clientType"].ToString());
                }
                model.customId = ds.Tables[0].Rows[0]["customId"].ToString();

                return(model);
            }
            else
            {
                return(null);
            }
        }
Example #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(System.Model.ispush model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ispush set ");

            strSql.Append(" ispushvalue = @ispushvalue , ");
            strSql.Append(" device = @device , ");
            strSql.Append(" clientType = @clientType , ");
            strSql.Append(" customId = @customId  ");
            strSql.Append(" where id=@id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@id",          SqlDbType.Int,       4),
                new SqlParameter("@ispushvalue", SqlDbType.Int,       4),
                new SqlParameter("@device",      SqlDbType.NVarChar, 50),
                new SqlParameter("@clientType",  SqlDbType.Int,       4),
                new SqlParameter("@customId",    SqlDbType.NVarChar, 50)
            };

            parameters[0].Value = model.id;
            parameters[1].Value = model.ispushvalue;
            parameters[2].Value = model.device;
            parameters[3].Value = model.clientType;
            parameters[4].Value = model.customId;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(System.Model.ispush model)
 {
     return(dal.Update(model));
 }
Example #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(System.Model.ispush model)
 {
     return(dal.Add(model));
 }