Пример #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(MesWeb.Model.Specification model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Specification set ");
            strSql.Append("productId=SQL2012productId,");
            strSql.Append("procedureId=SQL2012procedureId,");
            strSql.Append("paramTypeId=SQL2012paramTypeId,");
            strSql.Append("upper=SQL2012upper,");
            strSql.Append("lower=SQL2012lower,");
            strSql.Append("suffix=SQL2012suffix");
            strSql.Append(" where id=SQL2012id");
            SqlParameter[] parameters =
            {
                new SqlParameter("SQL2012productId",   SqlDbType.Int,       4),
                new SqlParameter("SQL2012procedureId", SqlDbType.Int,       4),
                new SqlParameter("SQL2012paramTypeId", SqlDbType.Int,       4),
                new SqlParameter("SQL2012upper",       SqlDbType.Float,     8),
                new SqlParameter("SQL2012lower",       SqlDbType.Float,     8),
                new SqlParameter("SQL2012suffix",      SqlDbType.NVarChar, 10),
                new SqlParameter("SQL2012id",          SqlDbType.Int, 4)
            };
            parameters[0].Value = model.productId;
            parameters[1].Value = model.procedureId;
            parameters[2].Value = model.paramTypeId;
            parameters[3].Value = model.upper;
            parameters[4].Value = model.lower;
            parameters[5].Value = model.suffix;
            parameters[6].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(MesWeb.Model.Specification model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Specification(");
            strSql.Append("productId,procedureId,paramTypeId,upper,lower,suffix)");
            strSql.Append(" values (");
            strSql.Append("SQL2012productId,SQL2012procedureId,SQL2012paramTypeId,SQL2012upper,SQL2012lower,SQL2012suffix)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("SQL2012productId",   SqlDbType.Int,      4),
                new SqlParameter("SQL2012procedureId", SqlDbType.Int,      4),
                new SqlParameter("SQL2012paramTypeId", SqlDbType.Int,      4),
                new SqlParameter("SQL2012upper",       SqlDbType.Float,    8),
                new SqlParameter("SQL2012lower",       SqlDbType.Float,    8),
                new SqlParameter("SQL2012suffix",      SqlDbType.NVarChar, 10)
            };
            parameters[0].Value = model.productId;
            parameters[1].Value = model.procedureId;
            parameters[2].Value = model.paramTypeId;
            parameters[3].Value = model.upper;
            parameters[4].Value = model.lower;
            parameters[5].Value = model.suffix;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MesWeb.Model.Specification DataRowToModel(DataRow row)
 {
     MesWeb.Model.Specification model = new MesWeb.Model.Specification();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["productId"] != null && row["productId"].ToString() != "")
         {
             model.productId = int.Parse(row["productId"].ToString());
         }
         if (row["procedureId"] != null && row["procedureId"].ToString() != "")
         {
             model.procedureId = int.Parse(row["procedureId"].ToString());
         }
         if (row["paramTypeId"] != null && row["paramTypeId"].ToString() != "")
         {
             model.paramTypeId = int.Parse(row["paramTypeId"].ToString());
         }
         if (row["upper"] != null && row["upper"].ToString() != "")
         {
             model.upper = decimal.Parse(row["upper"].ToString());
         }
         if (row["lower"] != null && row["lower"].ToString() != "")
         {
             model.lower = decimal.Parse(row["lower"].ToString());
         }
         if (row["suffix"] != null)
         {
             model.suffix = row["suffix"].ToString();
         }
     }
     return(model);
 }
Пример #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MesWeb.Model.Specification GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,productId,procedureId,paramTypeId,upper,lower,suffix from Specification ");
            strSql.Append(" where id=SQL2012id");
            SqlParameter[] parameters =
            {
                new SqlParameter("SQL2012id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }