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

            strSql.Append("update out_warehouse set ");
            strSql.Append("gid=@gid,");
            strSql.Append("imei=@imei,");
            strSql.Append("outtime=@outtime");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@gid",     MySqlDbType.VarChar,   255),
                new MySqlParameter("@imei",    MySqlDbType.VarChar,   255),
                new MySqlParameter("@outtime", MySqlDbType.DateTime),
                new MySqlParameter("@id",      MySqlDbType.Int64, 20)
            };
            parameters[0].Value = model.gid;
            parameters[1].Value = model.imei;
            parameters[2].Value = model.outtime;
            parameters[3].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(ManagePhones.Model.OutWarehouse model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into out_warehouse(");
            strSql.Append("gid,imei,outtime)");
            strSql.Append(" values (");
            strSql.Append("@gid,@imei,@outtime)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@gid",     MySqlDbType.VarChar, 255),
                new MySqlParameter("@imei",    MySqlDbType.VarChar, 255),
                new MySqlParameter("@outtime", MySqlDbType.DateTime)
            };
            parameters[0].Value = model.gid;
            parameters[1].Value = model.imei;
            parameters[2].Value = model.outtime;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public ManagePhones.Model.OutWarehouse DataRowToModel(DataRow row)
 {
     ManagePhones.Model.OutWarehouse model = new ManagePhones.Model.OutWarehouse();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = long.Parse(row["id"].ToString());
         }
         if (row["gid"] != null)
         {
             model.gid = row["gid"].ToString();
         }
         if (row["imei"] != null)
         {
             model.imei = row["imei"].ToString();
         }
         if (row["outtime"] != null && row["outtime"].ToString() != "")
         {
             model.outtime = DateTime.Parse(row["outtime"].ToString());
         }
     }
     return(model);
 }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ManagePhones.Model.OutWarehouse GetModel(long id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,gid,imei,outtime from out_warehouse ");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id", MySqlDbType.Int64)
            };
            parameters[0].Value = id;

            ManagePhones.Model.OutWarehouse model = new ManagePhones.Model.OutWarehouse();
            DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters);

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