示例#1
0
		public override void ViewDidLoad()
		{
			try
			{
				LoggingClass.loginview = true;
				nfloat starty = 70;
				nfloat width = UIScreen.MainScreen.Bounds.Width;
				width = width / 2 - 15;
				if (Reachability.IsHostReachable("https://www.apple.com") == false)
				{
					UIAlertView alert = new UIAlertView()
					{
						Title = "Sorry",
						Message = "Not connected to internet,Connect and re try it."
					};

					alert.AddButton("OK");
					alert.Show();
				}
				if (CurrentUser.GetCardNumber() != null)
				{
					PreInfo(CurrentUser.GetCardNumber());
				}
				CGSize sTemp = new CGSize(View.Frame.Width-10, 100);
				try
				{
					EmailVerification(true);
				}
				catch (Exception exe)
				{
					LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
				}
				 CurrentUser.RootTabs = RootTabs;
				CurrentUser.window = _window;
				MobileBarcodeScanner scanner = new MobileBarcodeScanner();
				nfloat h = 31.0f;
				nfloat w = View.Bounds.Width;
				nfloat imageheight = screenheight/5;
				nfloat imagewidth = UIScreen.MainScreen.Bounds.Width;
				var imgLogo = new UIImageView();
				imgLogo.Frame = new CGRect(((imagewidth/2)-(imageheight/2)), starty, imageheight, imageheight);
				imgLogo.Image = UIImage.FromFile("Images/lg.png");
				y = starty + imageheight;
				lblIns = new UILabel();
				lblIns.Text = "Please scan your VIP card barcode by touching below card:";
				lblIns.LineBreakMode = UILineBreakMode.WordWrap;
				lblIns.Lines = 0;
				sTemp = lblIns.SizeThatFits(sTemp);
				lblIns.Frame = new CGRect(0, y, View.Frame.Width-10, sTemp.Height);
				lblIns.TextAlignment = UITextAlignment.Center;
				lblIns.TextColor = UIColor.Black;
				//Console.WriteLine(y+"\n"+sTemp.Height);

				y = y+sTemp.Height;
				lblInfo = new UILabel();
				lblInfo.Frame = new CGRect(20, y, View.Frame.Width-10, h);
				lblInfo.LineBreakMode = UILineBreakMode.WordWrap;
				lblInfo.Lines = 0;
				lblInfo.TextAlignment = UITextAlignment.Center;
				lblInfo.TextColor = UIColor.Black;

				lblContactus = new UILabel();
				lblContactus.TextColor = UIColor.Red;
				lblContactus.TextAlignment = UITextAlignment.Center;
				lblContactus.Hidden = true;

				nfloat hei = 180 + lblIns.Frame.Height + 10;
				btnCardScanner= new UIButton();
				if (screenheight <= 568)
				{
					btnCardScanner.Frame = new CGRect((View.Frame.Width / 2) - 100, y, 200, 122);
				}
				else
				{
					btnCardScanner.Frame = new CGRect((View.Frame.Width / 2) - 100, y, 200, 152);
				}
				btnCardScanner.SetBackgroundImage(new UIImage("card-icon.png"), UIControlState.Normal);

				//height setting for button
				start = hei + btnCardScanner.Frame.Height + 10;
				//Console.WriteLine(hei);
				//Console.WriteLine(btnCardScanner.Frame.Height);
				//Console.WriteLine(start);
				//Console.WriteLine(View.Frame.Height);
				//568
				//Scanning Button Click event
				btnCardScanner.TouchUpInside += async (sender, e) =>
				{
					
					try
					{
						scanner.UseCustomOverlay = false;
						var result = await scanner.Scan();

						if (result != null)
						{
							LoggingClass.LogInfo("User tried to login with" + result.Text, screenid);
							PreInfo(result.Text);
                            //EmailVerification();
						}
					}
					catch (Exception exe)
					{
						LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
					}
				};
				y = y + 200;
				//nfloat strtguest = strtbtn + btnLogin.Frame.Height + 10;
				UILabel lblGuest = new UILabel();
				lblGuest.Frame = new CGRect(20, View.Frame.Height - 50, View.Frame.Width, h);
				lblGuest.Text = "Not a VIP Member?";
				lblGuest.TextAlignment = UITextAlignment.Left;
				lblGuest.Font = UIFont.ItalicSystemFontOfSize(17);
				lblGuest.TextColor = UIColor.Black;

				btnGuestLogin = new UIButton(new CGRect(180, View.Frame.Height - 50, 120, 30));
				btnGuestLogin.SetTitle("Guest Log In", UIControlState.Normal);
				btnGuestLogin.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
				btnGuestLogin.SetTitleColor(UIColor.White, UIControlState.Normal);
				btnGuestLogin.BackgroundColor = UIColor.Purple;
				//btnGuestLogin.SetImage(UIImage.FromFile ("Images/gl.png"), UIControlState.Normal);

				btnLogin = new UIButton(new CGRect(180, strtbtn, 120, 30));
				btnLogin.SetTitle("Log In", UIControlState.Normal);
				btnLogin.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
				btnLogin.SetTitleColor(UIColor.White, UIControlState.Normal);
				btnLogin.BackgroundColor = UIColor.Purple;

				btnResend = new UIButton(new CGRect(30, strtbtn, 120, 30));
				btnResend.SetTitle("Resend Email", UIControlState.Normal);
				btnResend.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
				btnResend.SetTitleColor(UIColor.White, UIControlState.Normal);
				btnResend.BackgroundColor = UIColor.Purple;

				BtnTest1 = new UIButton(new CGRect(200, strtbtn, 100, 30));
				BtnTest1.SetTitle("Continue", UIControlState.Normal);
				BtnTest1.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
				BtnTest1.SetTitleColor(UIColor.White, UIControlState.Normal);
				BtnTest1.BackgroundColor = UIColor.Purple;

				BtnTest2 = new UIButton(new CGRect(30, strtbtn, 140, 30));
				BtnTest2.SetTitle("Update E-Mail Id", UIControlState.Normal);
				BtnTest2.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
				BtnTest2.SetTitleColor(UIColor.White, UIControlState.Normal);
				BtnTest2.BackgroundColor = UIColor.Purple;

				btnVerify = new UIButton(new CGRect(24, imageheight + 270, 240, 20));
				btnVerify.SetTitle("Verify", UIControlState.Normal);
				btnVerify.HorizontalAlignment = UIControlContentHorizontalAlignment.Right;
				btnVerify.SetTitleColor(UIColor.Purple, UIControlState.Normal);
				btnGuestLogin.TouchDown += async (sender, e) =>
				   {
					   CurrentUser.Store("0", "Guest");
					   if (RootTabs == null || _window == null)
					   {
						   _window = CurrentUser.window;
						   RootTabs = CurrentUser.RootTabs;
						   nav = new UINavigationController(RootTabs);
						   //AddNavigationButtons(nav);
						   _window.RootViewController = nav;
						   //nav.DismissViewController(true);
					   }
					   nav = new UINavigationController(RootTabs);
					   AddNavigationButtons(nav);
					   CurrentUser.RootTabs = RootTabs;
					   _window.RootViewController = nav;
					   CurrentUser.window = _window;
					   await svc.InsertUpdateGuest("Didn't get the token");

					   //this.NavigationController.PopToRootViewController (true);

				   };
				View.AddSubview(BtnTest1);
				View.AddSubview(BtnTest2);
				View.AddSubview(btnResend);
				View.AddSubview(btnLogin);
				View.AddSubview(imgLogo);
				View.AddSubview(btnGuestLogin);
				View.AddSubview(lblIns);
				View.AddSubview(btnCardScanner);
				View.AddSubview(lblInfo);
				View.AddSubview(lblGuest);
				View.AddSubview(lblContactus);
				View.BackgroundColor = UIColor.White;

			}
			catch (Exception exe)
			{
				LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
			}

		}
        public override void ViewDidLoad()
        {
            try
            {
                //this.NavCtrl.NavigationBar.BarStyle = UIBarStyle.BlackTranslucent;
                //UINavigationBar.Appearance.BackgroundColor = UIColor.Clear;
                //NavCtrl.NavigationBar.BackgroundColor = UIColor.Clear;
                nfloat ScreenHeight = UIScreen.MainScreen.Bounds.Height;
                ScreenHeight = (ScreenHeight - 100) / 3;
                Boolean internetStatus = Reachability.IsHostReachable("https://www.google.com");
                if (internetStatus == false)
                {
                    UIAlertView alert = new UIAlertView()
                    {
                        Title   = "Sorry",
                        Message = "Not connected to internet.Please connect and retry."
                    };

                    alert.AddButton("OK");
                    alert.Show();
                }
                BTProgressHUD.Dismiss();
                UIImageView backgroud = new UIImageView();
                backgroud.Frame = new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width, ScreenHeight - 20);
                backgroud.Image = new UIImage("proback.png");
                backgroud.UserInteractionEnabled = false;
                btnBack.UserInteractionEnabled   = false;
                //imgProfile.Frame = new CGRect((View.Frame.Width / 2) - 72, 3 * (backgroud.Frame.Height / 3), 144, 152);
                //UITapGestureRecognizer singleTap = new UITapGestureRecognizer();
                //singleTap.CancelsTouchesInView = false;
                //Scroll.AddGestureRecognizer(singleTap);
                //DismissKeyboardOnBackgroundTap();
                NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.WillHideNotification, KeyBoardDownNotification);
                NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.DidShowNotification, KeyBoardUpNotification);
                LoggingClass.LogInfo("Entered into Profile View", screenid);
                pickerDataModel = new StatePickerDataModel();
                pickerDataModel.Items.Add("---Select your state---");
                pickerDataModel.Items.Add("AL");
                pickerDataModel.Items.Add("AK");
                pickerDataModel.Items.Add("AZ");
                pickerDataModel.Items.Add("AR");
                pickerDataModel.Items.Add("CA");
                pickerDataModel.Items.Add("CO");
                pickerDataModel.Items.Add("CT");
                pickerDataModel.Items.Add("DE");
                pickerDataModel.Items.Add("FL");
                pickerDataModel.Items.Add("GA");
                pickerDataModel.Items.Add("HI");
                pickerDataModel.Items.Add("ID");
                pickerDataModel.Items.Add("IL");
                pickerDataModel.Items.Add("IN");
                pickerDataModel.Items.Add("IA");
                pickerDataModel.Items.Add("KS");
                pickerDataModel.Items.Add("KY");
                pickerDataModel.Items.Add("LA");
                pickerDataModel.Items.Add("ME");
                pickerDataModel.Items.Add("MD");
                pickerDataModel.Items.Add("MA");
                pickerDataModel.Items.Add("MI");
                pickerDataModel.Items.Add("MN");
                pickerDataModel.Items.Add("MS");
                pickerDataModel.Items.Add("MO");
                pickerDataModel.Items.Add("MT");
                pickerDataModel.Items.Add("NE");
                pickerDataModel.Items.Add("NV");
                pickerDataModel.Items.Add("NH");
                pickerDataModel.Items.Add("NJ");
                pickerDataModel.Items.Add("NM");
                pickerDataModel.Items.Add("NY");
                pickerDataModel.Items.Add("NC");
                pickerDataModel.Items.Add("ND");
                pickerDataModel.Items.Add("OH");
                pickerDataModel.Items.Add("OK");
                pickerDataModel.Items.Add("OR");
                pickerDataModel.Items.Add("PA");
                pickerDataModel.Items.Add("RI");
                pickerDataModel.Items.Add("SC");
                pickerDataModel.Items.Add("SD");
                pickerDataModel.Items.Add("TN");
                pickerDataModel.Items.Add("TX");
                pickerDataModel.Items.Add("UT");
                pickerDataModel.Items.Add("VT");
                pickerDataModel.Items.Add("VA");
                pickerDataModel.Items.Add("WA");
                pickerDataModel.Items.Add("WV");
                pickerDataModel.Items.Add("WI");
                pickerDataModel.Items.Add("WY");

                statePicker.Model = pickerDataModel;
                //statePicker.BackgroundColor = UIColor.Red;
                //statePicker = new UIPickerView(new CGRect(01,01,UIScreen.MainScreen.Bounds.Width,UIScreen.MainScreen.Bounds.Height));
                //	//UIScreen.MainScreen.Bounds.X-UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height, UIScreen.MainScreen.Bounds.Width, 180));
                StoreDataModel = new StorePickerDataModel();
                StoreDataModel.Items.Add("---Select preffered store---");
                StoreDataModel.Items.Add("Wall");
                StoreDataModel.Items.Add("Pt. Pleasant Beach");
                StoreDataModel.Items.Add("All");
                storePicker.Model = StoreDataModel;
                //statePicker.Select(5, 0, true);
                //LoggingClass.UploadErrorLogs();
                if (CurrentUser.RetreiveUserId() == 0)
                {
                    DownloadAsync();
                    UIAlertView alert = new UIAlertView()
                    {
                        Title = "This feature is allowed only for VIP Card holders",
                        //Message = "Coming Soon..."
                    };

                    alert.AddButton("OK");
                    alert.AddButton("Log in");
                    alert.AddButton("Know more");
                    alert.Clicked += (senderalert, buttonArgs) =>
                    {
                        if (buttonArgs.ButtonIndex == 1)
                        {
                            CurrentUser.Clear();
                            LoginViewController yourController = new LoginViewController();
                            yourController.nav      = NavCtrl;
                            yourController.RootTabs = CurrentUser.RootTabs;
                            NavCtrl.PushViewController(yourController, false);
                            //NavCtrl.PopViewController(false);
                            //NavCtrl.PopViewController(false);
                        }
                    };
                    alert.Clicked += (senderalert, buttonArgs) =>
                    {
                        if (buttonArgs.ButtonIndex == 2)
                        {
                            UIApplication.SharedApplication.OpenUrl(new NSUrl("https://hangoutz.azurewebsites.net/index.html"));
                        }
                    };
                    alert.Show();
                    btnUpdate.UserInteractionEnabled   = false;
                    txtLastName.UserInteractionEnabled = false;
                    txtPhone.UserInteractionEnabled    = false;
                    txtAddress.UserInteractionEnabled  = false;
                    txtZipCode.UserInteractionEnabled  = false;
                    txtEmail.UserInteractionEnabled    = false;
                    statePicker.UserInteractionEnabled = false;
                    storePicker.UserInteractionEnabled = false;
                    imgProfile.UserInteractionEnabled  = false;
                    btnPicEdit.UserInteractionEnabled  = false;
                }
                else
                {
                    DownloadAsync();
                    cRes = svc.GetCustomerDetails(CurrentUser.RetreiveUserId()).Result;
                    //txtFirstName.Text = cRes.customer.FirstName;
                    name             = cRes.customer.FirstName + " " + cRes.customer.LastName;
                    name             = name.Trim();
                    txtLastName.Text = name;                    //cRes.customer.FirstName+" "+cRes.customer.LastName;
                    //txtCity.Text = cRes.customer.City;
                    txtEmail.Text = cRes.customer.Email;
                    if (cRes.customer.PhoneNumber.Length != 10)
                    {
                        //cRes.customer.PhoneNumber
                        txtPhone.Text = cRes.customer.PhoneNumber;
                    }
                    txtCardnumber.Text = cRes.customer.CardNumber;
                    txtExpirydate.Text = cRes.customer.ExpireDate.ToString("MM-dd-yyyy");
                    txtZipCode.Text    = cRes.customer.Zip;
                    string state = cRes.customer.State;
                    if (pickerDataModel.Items.Contains(state))
                    {
                        int i = pickerDataModel.Items.FindIndex(x => x == state);
                        statePicker.Select(i, 0, false);
                    }
                    int prefStore = cRes.customer.PreferredStore;
                    storePicker.Select(prefStore, 0, false);
                    txtAddress.Text = cRes.customer.Address1 + cRes.customer.Address2 + cRes.customer.City;
                    //txtFirstName.ShouldReturn += (TextField) =>
                    // {
                    //  ((UITextField)TextField).ResignFirstResponder();
                    //  return true;
                    // };
                    txtLastName.ShouldReturn += (TextField) =>
                    {
                        ((UITextField)TextField).ResignFirstResponder();
                        return(true);
                    };
                    txtEmail.ShouldReturn += (TextField) =>
                    {
                        ((UITextField)TextField).ResignFirstResponder();
                        return(true);
                    };
                    txtPhone.ShouldReturn += (TextField) =>
                    {
                        ((UITextField)TextField).ResignFirstResponder();
                        return(true);
                    };
                    txtAddress.ShouldReturn += (TextField) =>
                    {
                        ((UITextField)TextField).ResignFirstResponder();
                        return(true);
                    };
                    txtZipCode.ShouldReturn += (TextField) =>
                    {
                        ((UITextField)TextField).ResignFirstResponder();
                        return(true);
                    };
                    txtZipCode.AccessibilityScroll(UIAccessibilityScrollDirection.Up);
                    btnUpdate.SetTitleColor(UIColor.Purple, UIControlState.Normal);
                    //btnEdit.SetTitleColor(UIColor.Purple, UIControlState.Normal);
                    //btnUpdate.TouchDown += (sender, e) =>
                    //{
                    //	BTProgressHUD.Show("Updating profile..."); //show spinner + text
                    //};
                    //btnUpdate.TouchUpInside += async (sender, e) =>
                    //{
                    //	if (txtPhone.Text.Length > 10 || txtPhone.Text.Length < 10)
                    //	{
                    //		BTProgressHUD.ShowErrorWithStatus("Phone number is invalid");
                    //	}
                    //	else if ((txtEmail.Text.Contains("@")) == false || (txtEmail.Text.Contains(".")) == false)
                    //	{
                    //		BTProgressHUD.ShowErrorWithStatus("Email is invalid");
                    //	}
                    //	else if ((txtZipCode.Text.Length!=5))
                    //	{
                    //		BTProgressHUD.ShowErrorWithStatus("Zipcode is invalid");
                    //	}
                    //	else
                    //	{
                    //		LoggingClass.LogInfo("Update button into Profile View", screenid);
                    //		Customer cust = new Customer();
                    //		cust.CustomerID = CurrentUser.RetreiveUserId();
                    //		cust.Address1 = txtAddress.Text;
                    //		name = txtLastName.Text;
                    //	name = name.Trim();
                    //	try
                    //	{
                    //		string[] str1 = name.Split(' ');
                    //		if (str1.Length == 2)
                    //		{
                    //			cust.FirstName = str1[0];
                    //			cust.LastName = str1[1];
                    //		}
                    //		else
                    //		{
                    //			cust.FirstName = str1[0] + str1[1];
                    //			cust.LastName = str1[2];
                    //		}
                    //	}
                    //	catch (Exception exe)
                    //	{
                    //		LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
                    //	}
                    //		cust.Email = txtEmail.Text;
                    //		cust.PhoneNumber = txtPhone.Text;
                    //		cust.State = pickerDataModel.SelectedItem;
                    //		cust.Zip = txtZipCode.Text;
                    //		cust.PreferredStore = StoreDataModel.SelectedItem;
                    //		CurrentUser.PutStore(StoreDataModel.SelectedItem);
                    //		await svc.UpdateCustomer(cust);
                    //		BTProgressHUD.ShowSuccessWithStatus("Profile Updated.");
                    //		//try
                    //		//{
                    //		//	NavCtrl.PopViewController(true);
                    //		//	//NavCtrl.PushViewController(new FirstViewController(handle), false);
                    //		//}
                    //		//catch (Exception exe)
                    //		//{
                    //		//	LoggingClass.LogError(exe.Message, screenid, exe.StackTrace.ToString());
                    //		//}
                    //	}
                    //};
                    btnUpdate.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
                    UIImage imgbtnCam = UIImage.FromFile("cam.png");
                    imgbtnCam = ResizeImage(imgbtnCam, 25, 25);
                    btnPicEdit.SetImage(imgbtnCam, UIControlState.Normal);
                    btnBack.UserInteractionEnabled = false;
                    //btnPicEdit.SetTitle("Edit", UIControlState.Normal);
                    //try
                    //{
                    btnPicEdit.TouchUpInside += (sender, e) =>
                    {
                        try
                        {
                            UIAlertView alert = new UIAlertView()
                            {
                                Title = "Please choose an option to upload profile picture",
                                //Message = "Coming Soon..."
                            };
                            alert.AddButton("Cancel");
                            alert.AddButton("Camera");
                            alert.AddButton("Gallery");
                            alert.Clicked += (senderalert, buttonArgs) =>
                            {
                                if (buttonArgs.ButtonIndex == 1)
                                {
                                    try
                                    {
                                        IsCameraAuthorized();
                                        TweetStation.Camera.TakePicture(this, (obj) =>
                                        {
                                            var photo = obj.ValueForKey(new NSString("UIImagePickerControllerOriginalImage")) as UIImage;
                                            var meta  = obj.ValueForKey(new NSString("UIImagePickerControllerMediaMetadata")) as NSDictionary;
                                            UploadProfilePic(photo);
                                            //ALAssetsLibrary library = new ALAssetsLibrary();
                                            //library.WriteImageToSavedPhotosAlbum(photo.CGImage, meta, (assetUrl, error) =>
                                            //{
                                            //	UploadProfilePic(assetUrl.ToString());
                                            //	Console.WriteLine("assetUrl:" + assetUrl);
                                            //});
                                            //var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                                        });
                                    }
                                    catch (Exception exe)
                                    {
                                        LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
                                    }
                                }
                            };
                            alert.Clicked += (senderalert, buttonArgs) =>
                            {
                                if (buttonArgs.ButtonIndex == 2)
                                {
                                    imagePicker                       = new UIImagePickerController();
                                    imagePicker.SourceType            = UIImagePickerControllerSourceType.PhotoLibrary;
                                    imagePicker.MediaTypes            = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.PhotoLibrary);
                                    imagePicker.FinishedPickingMedia += Handle_FinishedPickingMedia;
                                    imagePicker.Canceled             += Handle_Canceled;
                                    NavCtrl.PresentModalViewController(imagePicker, true);
                                }
                            };
                            alert.Show();
                            //imagePicker = new UIImagePickerController();
                            //imagePicker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary;
                            //imagePicker.MediaTypes = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.PhotoLibrary);
                            //imagePicker.FinishedPickingMedia += Handle_FinishedPickingMedia;
                            //imagePicker.Canceled += Handle_Canceled;
                            //NavCtrl.PresentModalViewController(imagePicker, true);
                        }
                        catch (Exception exe)
                        {
                            LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
                        }
                    };
                }
                //imgEmail.Image = new UIImage("mail.png");
                //imgAddr.Image = new UIImage("add.png");
                //imgPhone.Image = new UIImage("phone1.png");
                Scroll = new UIScrollView
                {
                    Frame            = new CGRect(0, 0, View.Frame.Width, View.Frame.Height),
                    ContentSize      = new CGSize(View.Frame.Width, View.Frame.Height),
                    BackgroundColor  = UIColor.White,
                    AutoresizingMask = UIViewAutoresizing.FlexibleHeight,
                };

                UIToolbar toolbar = new UIToolbar(new RectangleF(0.0f, 0.0f, Convert.ToSingle(this.View.Frame.Size.Width), 44.0f));
                toolbar.TintColor   = UIColor.White;
                toolbar.BarStyle    = UIBarStyle.Default;
                toolbar.Translucent = true;
                UITapGestureRecognizer taps = new UITapGestureRecognizer();
                taps.CancelsTouchesInView = false;
                taps.AddTarget(() => Scroll.EndEditing(true));
                Scroll.AddGestureRecognizer(taps);
                UIImage imgbtnUpdate = UIImage.FromFile("tick.png");
                imgbtnUpdate = ResizeImage(imgbtnUpdate, 25, 25);
                //var topBtn = new UIBarButtonItem(imgbtnUpdate, UIBarButtonItemStyle.Plain, async delegate
                //{
                btnUpdate.TouchUpInside += async delegate
                {
                    //if (txtPhone.Text.Length!=12)
                    //{
                    //	BTProgressHUD.ShowErrorWithStatus("Phone number is invalid");
                    //}
                    if ((txtEmail.Text.Contains("@")) == false || (txtEmail.Text.Contains(".")) == false)
                    {
                        BTProgressHUD.ShowErrorWithStatus("Email is invalid");
                    }
                    else if ((txtZipCode.Text.Length != 5))
                    {
                        BTProgressHUD.ShowErrorWithStatus("Zipcode is invalid");
                    }
                    else
                    {
                        BTProgressHUD.Show("Updating Profile...");
                        LoggingClass.LogInfo("Update button into Profile View", screenid);
                        Customer cust = new Customer();
                        cust.CustomerID = CurrentUser.RetreiveUserId();
                        cust.Address1   = txtAddress.Text;
                        //cust.FirstName = txtFirstName.Text;
                        name = txtLastName.Text;
                        name = name.Trim();
                        try
                        {
                            string[] str1 = name.Split(' ');
                            if (str1.Length == 2)
                            {
                                cust.FirstName = str1[0];
                                cust.LastName  = str1[1];
                            }
                            else
                            {
                                cust.FirstName = str1[0] + str1[1];
                                cust.LastName  = str1[2];
                            }
                        }
                        catch (Exception exe)
                        {
                            LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
                        }
                        cust.Email       = txtEmail.Text;
                        cust.PhoneNumber = txtPhone.Text;

                        if (pickerDataModel.SelectedItem == "---Select your state---")
                        {
                            if (pickerDataModel.Items.Contains(cRes.customer.State))
                            {
                                int i = pickerDataModel.Items.FindIndex(x => x == cRes.customer.State);
                                statePicker.Select(i, 0, false);
                            }
                            cust.State = cRes.customer.State;
                        }
                        else
                        {
                            cust.State = pickerDataModel.SelectedItem;
                        }
                        cust.Zip = txtZipCode.Text;
                        if (StoreDataModel.SelectedItem == 0)
                        {
                            cust.PreferredStore = cRes.customer.PreferredStore;
                            storePicker.Select(cRes.customer.PreferredStore, 0, false);
                            CurrentUser.PutStore(cust.PreferredStore);
                        }
                        else
                        {
                            cust.PreferredStore = StoreDataModel.SelectedItem;
                            CurrentUser.PutStore(cust.PreferredStore);
                        }
                        await svc.UpdateCustomer(cust);

                        BTProgressHUD.ShowSuccessWithStatus("Profile Updated.");
                    }
                };
                imgProfile.ClipsToBounds   = true;
                imgProfile.BackgroundColor = UIColor.White;
                //NavigationController.NavigationBar.TopItem.SetRightBarButtonItem(topBtn, true);
                btnBack.BackgroundColor = UIColor.FromRGB(93, 93, 93);
                Scroll.AddSubview(backgroud);
                Scroll.AddSubview(btnBack);
                //Scroll.AddSubview(imgAddr);
                //Scroll.AddSubview(imgPhone);
                //Scroll.AddSubview(imgEmail);
                Scroll.AddSubview(txtEmail);
                Scroll.AddSubview(statePicker);
                Scroll.AddSubview(storePicker);
                Scroll.AddSubview(txtPhone);
                Scroll.AddSubview(txtZipCode);
                //Scroll.AddSubview(txtFirstName);
                Scroll.AddSubview(txtLastName);
                Scroll.AddSubview(txtAddress);
                Scroll.AddSubview(imgProfile);
                Scroll.AddSubview(btnPicEdit);
                Scroll.AddSubview(lblEmail);
                Scroll.AddSubview(lblState);
                Scroll.AddSubview(lblMobile);
                Scroll.AddSubview(lblAddress);
                Scroll.AddSubview(lblZipcode);
                //Scroll.AddSubview(lblFirstname);
                Scroll.AddSubview(lblLastname);
                Scroll.AddSubview(btnUpdate);
                Scroll.AddSubview(lblStorePi);
                Scroll.AddSubview(lblExpiryDate);
                Scroll.AddSubview(txtExpirydate);
                Scroll.AddSubview(lblcardnumber);
                Scroll.AddSubview(txtCardnumber);

                //View.AddSubview(Scroll);

                for (int i = 0; i < Scroll.Subviews.Length; i++)
                {
                    nfloat n = Scroll.Subviews[i].Frame.Size.Height;
                    h = h + n;
                }
                //Console.WriteLine(h);
                Scroll.ContentSize = new CGSize(UIScreen.MainScreen.Bounds.Width, h - 200);
                View = (Scroll);
            }
            catch (Exception ex)
            {
                LoggingClass.LogError(ex.ToString(), screenid, ex.StackTrace);
            }
        }