Ejemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(UsageEntity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Usage set ");
            strSql.Append("Usage_Name=@Usage_Name,");
            strSql.Append("Usage_Dict=@Usage_Dict");
            strSql.Append(" where Usage_ID=@Usage_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Usage_Name", SqlDbType.NVarChar, 50),
                new SqlParameter("@Usage_Dict", SqlDbType.NVarChar, 50),
                new SqlParameter("@Usage_ID",   SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Usage_Name;
            parameters[1].Value = model.Usage_Dict;
            parameters[2].Value = model.Usage_ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(UsageEntity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Usage(");
            strSql.Append("Usage_Name,Usage_Dict)");
            strSql.Append(" values (");
            strSql.Append("@Usage_Name,@Usage_Dict)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Usage_Name", SqlDbType.NVarChar, 50),
                new SqlParameter("@Usage_Dict", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.Usage_Name;
            parameters[1].Value = model.Usage_Dict;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public UsageEntity DataRowToModel(DataRow row)
        {
            UsageEntity model = new UsageEntity();

            if (row != null)
            {
                if (row["Usage_ID"] != null && row["Usage_ID"].ToString() != "")
                {
                    model.Usage_ID = int.Parse(row["Usage_ID"].ToString());
                }
                if (row["Usage_Name"] != null)
                {
                    model.Usage_Name = row["Usage_Name"].ToString();
                }
                if (row["Usage_Dict"] != null)
                {
                    model.Usage_Dict = row["Usage_Dict"].ToString();
                }
            }
            return(model);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public UsageEntity GetModel(int Usage_ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Usage_ID,Usage_Name,Usage_Dict from Usage ");
            strSql.Append(" where Usage_ID=@Usage_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Usage_ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = Usage_ID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(UsageEntity model)
 {
     return(dal.Update(model));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(UsageEntity model)
 {
     return(dal.Add(model));
 }