示例#1
0
        /// <summary>
        /// 增加一条记录
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static bool Add(EtNet_Models.AusItemInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into AusItemInfo(");
            strSql.Append("itemname)");
            strSql.Append(" values (");
            strSql.Append("@itemname)");

            SqlParameter[] parameters =
            {
                new SqlParameter("@itemname", SqlDbType.VarChar, 20)
            };
            parameters[0].Value = model.itemname;
            int result = DBHelper.ExecuteCommand(strSql.ToString(), parameters);

            if (result >= 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
        /// <summary>
        /// 更新一条记录
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static bool Update(EtNet_Models.AusItemInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update AusItemInfo set ");
            strSql.Append(" itemname=@itemname");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@itemname", SqlDbType.VarChar, 20),
                new SqlParameter("@id",       SqlDbType.Int, 4)
            };
            parameters[0].Value = model.itemname;
            parameters[1].Value = model.id;

            int result = DBHelper.ExecuteCommand(strSql.ToString(), parameters);

            if (result >= 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#3
0
        public static EtNet_Models.AusItemInfo GetModelByName(string name)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * from AusItemInfo ");
            strSql.Append(" where itemname=@itemname");
            SqlParameter[] parameters =
            {
                new SqlParameter("@itemname", SqlDbType.VarChar, 20)
            };
            parameters[0].Value = name;

            EtNet_Models.AusItemInfo model = null;

            SqlDataReader rad = DBHelper.ExecuteReader(strSql.ToString(), parameters);

            if (rad.Read())
            {
                model          = new EtNet_Models.AusItemInfo();
                model.id       = rad.GetInt32(0);
                model.itemname = rad.GetString(1);
                rad.Close();
                return(model);
            }
            else
            {
                return(model);
            }
        }