Beispiel #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Tz888.Model.wyzs.WyzsType model)
        {
            StringBuilder strSql = new StringBuilder();

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

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Tz888.Model.wyzs.WyzsType model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into WyzsType(");
            strSql.Append("typeName)");
            strSql.Append(" values (");
            strSql.Append("@typeName)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@typeName", SqlDbType.VarChar, 50)
            };
            parameters[0].Value = model.typeName;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Tz888.Model.wyzs.WyzsType GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

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

            Tz888.Model.wyzs.WyzsType model = new  Tz888.Model.wyzs.WyzsType();
            DataSet ds = DBHelper.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());
                }
                model.typeName = ds.Tables[0].Rows[0]["typeName"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
Beispiel #4
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <Tz888.Model.wyzs.WyzsType> DataTableToList(DataTable dt)
        {
            List <Tz888.Model.wyzs.WyzsType> modelList = new List <Tz888.Model.wyzs.WyzsType>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                Tz888.Model.wyzs.WyzsType model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Tz888.Model.wyzs.WyzsType();
                    if (dt.Rows[n]["id"].ToString() != "")
                    {
                        model.id = int.Parse(dt.Rows[n]["id"].ToString());
                    }
                    model.typeName = dt.Rows[n]["typeName"].ToString();
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Beispiel #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Tz888.Model.wyzs.WyzsType model)
 {
     return(dal.Update(model));
 }
Beispiel #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(Tz888.Model.wyzs.WyzsType model)
 {
     return(dal.Add(model));
 }