Пример #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(TSM.Model.pms_Product_Type model)
        {
            StringBuilder strSql = new StringBuilder();

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

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

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TSM.Model.pms_Product_Type GetModel(int ProductTypeID)
        {
            StringBuilder strSql = new StringBuilder();

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

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ProductTypeID"].ToString() != "")
                {
                    model.ProductTypeID = int.Parse(ds.Tables[0].Rows[0]["ProductTypeID"].ToString());
                }
                model.ProductType = ds.Tables[0].Rows[0]["ProductType"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
Пример #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(TSM.Model.pms_Product_Type model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update pms_Product_Type set ");
            strSql.Append("ProductType=@ProductType");
            strSql.Append(" where ProductTypeID=@ProductTypeID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ProductTypeID", SqlDbType.Int,     4),
                new SqlParameter("@ProductType",   SqlDbType.VarChar, 64)
            };
            parameters[0].Value = model.ProductTypeID;
            parameters[1].Value = model.ProductType;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }