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

            strSql.Append("update verificationcode set ");
            strSql.Append("mobile=?mobile,");
            strSql.Append("code=?code,");
            strSql.Append("gettime=?gettime,");
            strSql.Append("outtime=?outtime");
            strSql.Append(" where id=?id ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("?mobile",  MySqlDbType.VarChar,   25),
                new MySqlParameter("?code",    MySqlDbType.VarChar,   10),
                new MySqlParameter("?gettime", MySqlDbType.DateTime),
                new MySqlParameter("?outtime", MySqlDbType.DateTime),
                new MySqlParameter("?id",      MySqlDbType.Int32, 11)
            };
            parameters[0].Value = model.mobile;
            parameters[1].Value = model.code;
            parameters[2].Value = model.gettime;
            parameters[3].Value = model.outtime;
            parameters[4].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MultiColorPen.Model.verificationcode DataRowToModel(DataRow row)
 {
     MultiColorPen.Model.verificationcode model = new MultiColorPen.Model.verificationcode();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["mobile"] != null)
         {
             model.mobile = row["mobile"].ToString();
         }
         if (row["code"] != null)
         {
             model.code = row["code"].ToString();
         }
         if (row["gettime"] != null && row["gettime"].ToString() != "")
         {
             model.gettime = DateTime.Parse(row["gettime"].ToString());
         }
         if (row["outtime"] != null && row["outtime"].ToString() != "")
         {
             model.outtime = DateTime.Parse(row["outtime"].ToString());
         }
     }
     return(model);
 }
示例#3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(MultiColorPen.Model.verificationcode model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into verificationcode(");
            strSql.Append("mobile,code,gettime,outtime)");
            strSql.Append(" values (");
            strSql.Append("?mobile,?code,?gettime,?outtime)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("?mobile",  MySqlDbType.VarChar,   25),
                new MySqlParameter("?code",    MySqlDbType.VarChar,   10),
                new MySqlParameter("?gettime", MySqlDbType.DateTime),
                new MySqlParameter("?outtime", MySqlDbType.DateTime)
            };
            parameters[0].Value = model.mobile;
            parameters[1].Value = model.code;
            parameters[2].Value = model.gettime;
            parameters[3].Value = model.outtime;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MultiColorPen.Model.verificationcode GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,mobile,code,gettime,outtime from verificationcode ");
            strSql.Append(" where id=?id ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("?id", MySqlDbType.Int32, 11)
            };
            parameters[0].Value = id;

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

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