예제 #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public LPWeb.Model.PointFieldDesc GetModel(decimal PointFieldId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 PointFieldId,Label,DataType from PointFieldDesc ");
            strSql.Append(" where PointFieldId=@PointFieldId ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@PointFieldId", SqlDbType.Decimal)
            };
            parameters[0].Value = PointFieldId;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["PointFieldId"].ToString() != "")
                {
                    model.PointFieldId = decimal.Parse(ds.Tables[0].Rows[0]["PointFieldId"].ToString());
                }
                model.Label = ds.Tables[0].Rows[0]["Label"].ToString();
                if (ds.Tables[0].Rows[0]["DataType"].ToString() != "")
                {
                    model.DataType = int.Parse(ds.Tables[0].Rows[0]["DataType"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
예제 #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(LPWeb.Model.PointFieldDesc model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into PointFieldDesc(");
            strSql.Append("PointFieldId,Label,DataType)");
            strSql.Append(" values (");
            strSql.Append("@PointFieldId,@Label,@DataType)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@PointFieldId", SqlDbType.Decimal,   5),
                new SqlParameter("@Label",        SqlDbType.NVarChar, 50),
                new SqlParameter("@DataType",     SqlDbType.SmallInt, 2)
            };
            parameters[0].Value = model.PointFieldId;
            parameters[1].Value = model.Label;
            parameters[2].Value = model.DataType;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
예제 #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(LPWeb.Model.PointFieldDesc model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update PointFieldDesc set ");
            strSql.Append("PointFieldId=@PointFieldId,");
            strSql.Append("Label=@Label,");
            strSql.Append("DataType=@DataType");
            strSql.Append(" where PointFieldId=@PointFieldId ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@PointFieldId", SqlDbType.Decimal,   5),
                new SqlParameter("@Label",        SqlDbType.NVarChar, 50),
                new SqlParameter("@DataType",     SqlDbType.SmallInt, 2)
            };
            parameters[0].Value = model.PointFieldId;
            parameters[1].Value = model.Label;
            parameters[2].Value = model.DataType;

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