示例#1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(YDIOTSvr.DataLayer.Entity.ValueTypeEntity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ValueType set ");
            strSql.Append("TypeName=@TypeName,");
            strSql.Append("Unit=@Unit");
            strSql.Append(" where VT_ID=@VT_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@TypeName", SqlDbType.NVarChar, 50),
                new SqlParameter("@Unit",     SqlDbType.NVarChar, 50),
                new SqlParameter("@VT_ID",    SqlDbType.Int, 4)
            };
            parameters[0].Value = model.TypeName;
            parameters[1].Value = model.Unit;
            parameters[2].Value = model.VT_ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(YDIOTSvr.DataLayer.Entity.ValueTypeEntity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ValueType(");
            strSql.Append("TypeName,Unit)");
            strSql.Append(" values (");
            strSql.Append("@TypeName,@Unit)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@TypeName", SqlDbType.NVarChar, 50),
                new SqlParameter("@Unit",     SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.TypeName;
            parameters[1].Value = model.Unit;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public YDIOTSvr.DataLayer.Entity.ValueTypeEntity DataRowToModel(DataRow row)
 {
     YDIOTSvr.DataLayer.Entity.ValueTypeEntity model = new YDIOTSvr.DataLayer.Entity.ValueTypeEntity();
     if (row != null)
     {
         if (row["VT_ID"] != null && row["VT_ID"].ToString() != "")
         {
             model.VT_ID = int.Parse(row["VT_ID"].ToString());
         }
         if (row["TypeName"] != null)
         {
             model.TypeName = row["TypeName"].ToString();
         }
         if (row["Unit"] != null)
         {
             model.Unit = row["Unit"].ToString();
         }
     }
     return(model);
 }
示例#4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public YDIOTSvr.DataLayer.Entity.ValueTypeEntity GetModel(int VT_ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 VT_ID,TypeName,Unit from ValueType ");
            strSql.Append(" where VT_ID=@VT_ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@VT_ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = VT_ID;

            YDIOTSvr.DataLayer.Entity.ValueTypeEntity model = new YDIOTSvr.DataLayer.Entity.ValueTypeEntity();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
示例#5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(YDIOTSvr.DataLayer.Entity.ValueTypeEntity model)
 {
     return(dal.Update(model));
 }
示例#6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(YDIOTSvr.DataLayer.Entity.ValueTypeEntity model)
 {
     return(dal.Add(model));
 }