/// <summary> /// 绑定cmd参数 /// </summary> /// <param name="cmd"></param> private void BindParameters(Database db, DbCommand cmd, AdminModel model) { db.AddInParameter(cmd, "@CreateTime", DbType.String, model.CreateTime); db.AddInParameter(cmd, "@Email", DbType.String, model.Email); db.AddInParameter(cmd, "@LastLoginTime", DbType.String, model.LastLoginTime); db.AddInParameter(cmd, "@Password", DbType.String, model.Password); db.AddInParameter(cmd, "@Phone", DbType.String, model.Phone); db.AddInParameter(cmd, "@QQ", DbType.String, model.QQ); db.AddInParameter(cmd, "@RealName", DbType.String, model.RealName); db.AddInParameter(cmd, "@Remark", DbType.String, model.Remark); db.AddInParameter(cmd, "@Status", DbType.Int32, model.Status); db.AddInParameter(cmd, "@Tel", DbType.String, model.Tel); db.AddInParameter(cmd, "@UpdateTime", DbType.String, model.UpdateTime); db.AddInParameter(cmd, "@UserName", DbType.String, model.UserName); db.AddInParameter(cmd, "@ID", DbType.Int32, model.ID); }
/// <summary> /// 绑定实体 /// </summary> /// <param name="reader"></param> /// <returns></returns> private AdminModel BindModel(IDataReader reader) { var model = new AdminModel(); model.CreateTime = reader["CreateTime"].ToString(); model.Email = reader["Email"].ToString(); model.ID = Convert.ToInt32(reader["ID"]); model.LastLoginTime = reader["LastLoginTime"].ToString(); model.Password = reader["Password"].ToString(); model.Phone = reader["Phone"].ToString(); model.QQ = reader["QQ"].ToString(); model.RealName = reader["RealName"].ToString(); model.Remark = reader["Remark"].ToString(); model.Status = Convert.ToInt32(reader["Status"]); model.Tel = reader["Tel"].ToString(); model.UpdateTime = reader["UpdateTime"].ToString(); model.UserName = reader["UserName"].ToString(); return model; }
/// <summary> /// 更新数据 /// </summary> /// <param name="model">实体</param> /// <returns></returns> public bool Update(AdminModel model) { return dal.Update(model); }
/// <summary> /// 更新数据 /// </summary> /// <param name="model">数据实体</param> /// <returns></returns> public bool Update(AdminModel model) { var db = base.DB; var cmd = db.GetSqlStringCommand(UpdateSql); BindParameters(db, cmd, model); return db.ExecuteNonQuery(cmd) > 0 ? true : false; }
/// <summary> /// 插入数据 /// </summary> /// <param name="model">实体</param> /// <returns></returns> public bool Insert(AdminModel model) { return dal.Insert(model); }