RetrievePassViewController.m 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. //
  2. // RetrievePassViewController.m
  3. // RedAnt ERP Mobile
  4. //
  5. // Created by Ray on 9/10/15.
  6. // Copyright (c) 2015 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "RetrievePassViewController.h"
  9. #import "RANetwork.h"
  10. @interface RetrievePassViewController ()
  11. @end
  12. @implementation RetrievePassViewController
  13. - (void)viewDidLoad {
  14. [super viewDidLoad];
  15. // Do any additional setup after loading the view.
  16. }
  17. - (void)didReceiveMemoryWarning {
  18. [super didReceiveMemoryWarning];
  19. // Dispose of any resources that can be recreated.
  20. }
  21. - (IBAction)onRetrieveClicked:(id)sender {
  22. NSString* user = self.editUser.text;
  23. NSString* email = self.editEmail.text;
  24. if(user.length==0||email.length==0)
  25. {
  26. // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Error!" message:@"user or email can not be empty." delegate:nil cancelButtonTitle:NSLocalizedString(@"ok", nil) otherButtonTitles:nil, nil];
  27. // // UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Error!" message:@"User&Password can not be empty!" delegate:nil cancelButtonTitle:NSLocalizedString(@"ok", nil) , nil];
  28. //
  29. //
  30. // //[[UILabel appearanceWhenContainedIn:UIAlertView.class, nil] setAppearanceFont:[UIFont boldSystemFontOfSize:10]];
  31. // [alert show];
  32. [RAUtils alert_view:@"User or email cannot be empty." title:@"Input Error!"];
  33. return;
  34. }
  35. self.buttonRetrieve.enabled = false;
  36. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  37. NSDictionary* json=[RANetwork retrieve_password:user email:email];
  38. dispatch_async(dispatch_get_main_queue(), ^{
  39. self.buttonRetrieve.enabled = true;
  40. if([[json valueForKey:@"result"] intValue]==2)
  41. {
  42. UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Successful!" message:@"Please Check email later." delegate:nil cancelButtonTitle:NSLocalizedString(@"ok", nil) otherButtonTitles:nil, nil];
  43. [alert show];
  44. }
  45. else
  46. {
  47. [RAUtils message_alert:[json valueForKey:@"err_msg"] title:@"Retrieve Password" controller:self] ;
  48. }
  49. });
  50. });
  51. }
  52. /*
  53. #pragma mark - Navigation
  54. // In a storyboard-based application, you will often want to do a little preparation before navigation
  55. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  56. // Get the new view controller using [segue destinationViewController].
  57. // Pass the selected object to the new view controller.
  58. }
  59. */
  60. @end