Ejemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(TravelAgency.Model.ProgramVersion model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ProgramVersion set ");
            strSql.Append("version=@version,");
            strSql.Append("update_files=@update_files,");
            strSql.Append("udapte_details=@udapte_details,");
            strSql.Append("version_name=@version_name");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@version",        SqlDbType.Float,    8),
                new SqlParameter("@update_files",   SqlDbType.Text),
                new SqlParameter("@udapte_details", SqlDbType.Text),
                new SqlParameter("@version_name",   SqlDbType.VarChar, 20),
                new SqlParameter("@id",             SqlDbType.Int, 4)
            };
            parameters[0].Value = model.version;
            parameters[1].Value = model.update_files;
            parameters[2].Value = model.udapte_details;
            parameters[3].Value = model.version_name;
            parameters[4].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public TravelAgency.Model.ProgramVersion DataRowToModel(DataRow row)
 {
     TravelAgency.Model.ProgramVersion model = new TravelAgency.Model.ProgramVersion();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["version"] != null && row["version"].ToString() != "")
         {
             model.version = decimal.Parse(row["version"].ToString());
         }
         if (row["update_files"] != null)
         {
             model.update_files = row["update_files"].ToString();
         }
         if (row["udapte_details"] != null)
         {
             model.udapte_details = row["udapte_details"].ToString();
         }
         if (row["version_name"] != null)
         {
             model.version_name = row["version_name"].ToString();
         }
     }
     return(model);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(TravelAgency.Model.ProgramVersion model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ProgramVersion(");
            strSql.Append("version,update_files,udapte_details,version_name)");
            strSql.Append(" values (");
            strSql.Append("@version,@update_files,@udapte_details,@version_name)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@version",        SqlDbType.Float,   8),
                new SqlParameter("@update_files",   SqlDbType.Text),
                new SqlParameter("@udapte_details", SqlDbType.Text),
                new SqlParameter("@version_name",   SqlDbType.VarChar, 20)
            };
            parameters[0].Value = model.version;
            parameters[1].Value = model.update_files;
            parameters[2].Value = model.udapte_details;
            parameters[3].Value = model.version_name;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public TravelAgency.Model.ProgramVersion GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

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

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

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