Exemplo n.º 1
0
        public override global::Android.Views.View OnCreateView(global::Android.Views.LayoutInflater inflater,  global::Android.Views.ViewGroup container,  global::Android.OS.Bundle savedInstanceState)
        {
            var view = (RelativeLayout)inflater.Inflate (Resource.Layout.signup_fragment, container, false);

            rootlayout = (RelativeLayout)view.FindViewById (Resource.Id.rootlayout);
            loadingcontainer = new RelativeLayout (nn_activity);
            loadingcontainer.LayoutParameters = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.MatchParent);
            loadingcontainer.SetBackgroundColor(Color.White);

            var detailcontainer = new LinearLayout (nn_activity);

            detailcontainer.Orientation = Orientation.Vertical;
            RelativeLayout.LayoutParams param=new RelativeLayout.LayoutParams((int)TapUtil.dptodx(100), RelativeLayout.LayoutParams.WrapContent);
            param.AddRule (LayoutRules.CenterInParent);
            detailcontainer.LayoutParameters = param;

            LinearLayout.LayoutParams linearlayoutparm=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent);
            linearlayoutparm.Gravity=GravityFlags.CenterHorizontal;

            ProgressBar progressbar = new ProgressBar (nn_activity);
            progressbar.LayoutParameters =  linearlayoutparm;

            TextView tectview = new TextView (nn_activity);
            tectview.LayoutParameters = linearlayoutparm;
            tectview.Text = RaffleBuyerSignUpScreenData.LoadingScreenTextInit;
            tectview.Gravity = GravityFlags.CenterHorizontal;

            detailcontainer.AddView (progressbar);
            detailcontainer.AddView (tectview);

            loadingcontainer.AddView (detailcontainer);
            rootlayout.AddView (loadingcontainer);

            picktimebutton = view.FindViewById<Button> (Resource.Id.signup_birthday_button);
            picktimebutton.Hint=RaffleBuyerSignUpScreenData.BirthDateTextFieldPlaceholder;
            picktimebutton.Click += (object sender, EventArgs e) => {
                showDatePickerDialog ();
            };
            countryspinner = view.FindViewById<Spinner> (Resource.Id.signup_country_spinner);
            countryspinner.ItemSelected+= (object sender, AdapterView.ItemSelectedEventArgs e) => {
                if(stateandprovincespinneradapter!=null){
                    stateandprovincespinneradapter.ChangeShowList(provincespinner,listcountry[e.Position].country_code);
                    stateandprovincespinneradapter.NotifyDataSetChanged ();
                }
                countryspinner.Tag=e.Position;
            };
            provincespinner= view.FindViewById<Spinner> (Resource.Id.signup_province_spinner);
            provincespinner.ItemSelected+= (object sender, AdapterView.ItemSelectedEventArgs e) => {
                provincespinner.Tag=e.Position;
            };

            raffleresultspinner= view.FindViewById<Spinner> (Resource.Id.signup_raffleresult_spinner);
            resultadapter = new CustomResultAndMessageSpinnerAdapter (nn_activity, GlobalVariable.ResultAndMessageList);
            raffleresultspinner.Adapter = resultadapter;
            resultadapter.NotifyDataSetChanged ();
            raffleresultspinner.ItemSelected+= (object sender, AdapterView.ItemSelectedEventArgs e) => {
                raffleresultspinner.Tag=e.Position;
            };

            marketmesagespinner= view.FindViewById<Spinner> (Resource.Id.signup_marketingmessage_spinner);

            messaegadapter = new CustomResultAndMessageSpinnerAdapter (nn_activity, GlobalVariable.ResultAndMessageList);
            marketmesagespinner.Adapter = messaegadapter;
            messaegadapter.NotifyDataSetChanged ();

            marketmesagespinner.ItemSelected+= (object sender, AdapterView.ItemSelectedEventArgs e) => {
                marketmesagespinner.Tag=e.Position;
            };

            firstname_edittext = view.FindViewById<EditText> (Resource.Id.signup_firstname_edittext);
            SetEditTextMaximumLength (firstname_edittext,100);
            firstname_edittext.Hint = RaffleBuyerSignUpScreenData.FirstNameTextFieldPlaceholder;

            lastname_edittext = view.FindViewById<EditText> (Resource.Id.signup_lastname_edittext);
            SetEditTextMaximumLength (lastname_edittext,100);
            lastname_edittext.Hint = RaffleBuyerSignUpScreenData.LastNameTextFieldPlaceholder;

            mobilephone_edittext = view.FindViewById<EditText> (Resource.Id.signup_mobilephone_edittext);
            SetEditTextMaximumLength (mobilephone_edittext,20);
            mobilephone_edittext.InputType = global::Android.Text.InputTypes.ClassPhone;
            mobilephone_edittext.Hint = RaffleBuyerSignUpScreenData.MobilePhoneTextFieldPlaceholder;

            email_edittext = view.FindViewById<EditText> (Resource.Id.signup_email_edittext);
            SetEditTextMaximumLength (email_edittext,60);
            if(!string.IsNullOrEmpty(nn_email)){
                email_edittext.Text = nn_email;
            }
            email_edittext.Hint = RaffleBuyerSignUpScreenData.EmailTextFieldPlaceholder;

            confirmemail_edittext = view.FindViewById<EditText> (Resource.Id.signup_reemail_edittext);
            SetEditTextMaximumLength (confirmemail_edittext,60);
            confirmemail_edittext.Hint=RaffleBuyerSignUpScreenData.EmailConfirmTextFieldPlaceholder;

            address1_edittext = view.FindViewById<EditText> (Resource.Id.signup_address1_edittext);
            SetEditTextMaximumLength (address1_edittext,100);
            address1_edittext.Hint = RaffleBuyerSignUpScreenData.Address1TextFieldPlaceholder;

            address2_edittext = view.FindViewById<EditText> (Resource.Id.signup_address2_edittext);
            SetEditTextMaximumLength (address2_edittext,100);
            address2_edittext.Hint = RaffleBuyerSignUpScreenData.Address2TextFieldPlaceholder;

            city_edittext = view.FindViewById<EditText> (Resource.Id.signup_city_edittext);
            SetEditTextMaximumLength (city_edittext,50);
            city_edittext.Hint=RaffleBuyerSignUpScreenData.CityTextFieldPlaceholder;

            postcode_edittext = view.FindViewById<EditText> (Resource.Id.signup_postal_edittext);
            SetEditTextMaximumLength (postcode_edittext,20);
            postcode_edittext.Hint=RaffleBuyerSignUpScreenData.ZipcodeTextFieldPlaceholder;

            TextView basicinfo=view.FindViewById<TextView> (Resource.Id.signup_basicinfo_textview);
            basicinfo.Text = RaffleBuyerSignUpScreenData.BasicInfoLabelText;

            TextView contactinfo=view.FindViewById<TextView> (Resource.Id.signup_contactinfo_textview);
            contactinfo.Text = RaffleBuyerSignUpScreenData.ContactInfoLabelText;

            TextView address=view.FindViewById<TextView> (Resource.Id.signup_addressinfo_textview);
            address.Text = RaffleBuyerSignUpScreenData.AddressInfoLabelText;

            TextView communicateraffle=view.FindViewById<TextView> (Resource.Id.signup_communicateraffle_textview);
            communicateraffle.Text = RaffleBuyerSignUpScreenData.RaffleResultsLabelText;

            TextView receivecharity=view.FindViewById<TextView> (Resource.Id.signup_receivecharity_textview);
            receivecharity.Text = RaffleBuyerSignUpScreenData.CharityMarketingMessagesLabelText;

            Button createaccountbutton = view.FindViewById<Button> (Resource.Id.signup_createaccount_button);
            createaccountbutton.Text = RaffleBuyerSignUpScreenData.CreateAccountBtnTitle;
            createaccountbutton.Click+= (object sender, EventArgs e) => {

                FormatCheckFlagObject[] flags=new FormatCheckFlagObject[14];
                for(int i=0;i<flags.Length;i++){
                    string message="";
                    if(i==0){
                        message="First Name";
                    }
                    if(i==1){
                        message="Last Name";
                    }
                    if(i==2){
                        message="Mobile Phone";
                    }
                    if(i==3){
                        message="Email";
                    }
                    if(i==4){
                        message="Email Confirm";
                    }
                    if(i==5){
                        message="Address1";
                    }
                    if(i==6){
                        message="Address2";
                    }
                    if(i==7){
                        message="City";
                    }
                    if(i==8){
                        message="Postcode";
                    }
                    if(i==9){
                        message="Country";
                    }
                    if(i==10){
                        message="State And Province";
                    }
                    if(i==11){
                        message="Raffle Results";
                    }
                    if(i==12){
                        message="Market Message";
                    }
                    if(i==13){
                        message="Birthdate";
                    }
                    flags[i]=new FormatCheckFlagObject(message);
                }

                string firstname = firstname_edittext.Text;
                string lastname=lastname_edittext.Text;
                string mobilephone=mobilephone_edittext.Text;
                string email=email_edittext.Text;
                string reemail=confirmemail_edittext.Text;
                string address1=address1_edittext.Text;
                string address2=address2_edittext.Text;
                string city=city_edittext.Text;
                string postcode=postcode_edittext.Text;

                string country=countryspinner.Tag==null?"":listcountry[(int)countryspinner.Tag].country_code;
                string stateandprovince=provincespinner.Tag==null?"":stateandprovincespinneradapter.showlist[(int)provincespinner.Tag].state_province_abbrev;

                string raffleresults=raffleresultspinner.Tag==null?"":GlobalVariable.ResultAndMessageList[(int)raffleresultspinner.Tag];
                string marketmesage=marketmesagespinner.Tag==null?"":GlobalVariable.ResultAndMessageList[(int)marketmesagespinner.Tag];

                string datetime=picktimebutton.Text;

                if(FormatManager.chechinput(firstname,FormatManager.FormatOption.OnlyLetter)){
                    flags[0].flag=true;
                }
                if(FormatManager.chechinput(lastname,FormatManager.FormatOption.OnlyLetter)){
                    flags[1].flag=true;
                }
                if(FormatManager.chechinput(mobilephone,FormatManager.FormatOption.OnlyNumber)&&mobilephone.Length>=5){
                    flags[2].flag=true;
                }
                if(FormatManager.chechinput(email,FormatManager.FormatOption.Email)){
                    flags[3].flag=true;
                }
                if(FormatManager.chechinput(reemail,FormatManager.FormatOption.Email)){
                    flags[4].flag=true;
                }
                if(!email.Equals(reemail)){
                    flags[4].flag=false;
                }
                if(FormatManager.chechinput(address1,FormatManager.FormatOption.Regular)){
                    flags[5].flag=true;
                }
                if(FormatManager.chechinput(address2,FormatManager.FormatOption.Regular)){
                    flags[6].flag=true;
                }
                //address2 can be empty
                if(address2.Equals("")){
                    flags[6].flag=true;
                }
                if(FormatManager.chechinput(city,FormatManager.FormatOption.Regular)){
                    flags[7].flag=true;
                }
                if(FormatManager.chechinput(postcode,FormatManager.FormatOption.Regular)){
                    flags[8].flag=true;
                }
                if(postcode.Equals("")){
                    flags[8].flag=true;
                }
                if(FormatManager.chechinput(country,FormatManager.FormatOption.Regular)){
                    flags[9].flag=true;
                }
                if(FormatManager.chechinput(stateandprovince,FormatManager.FormatOption.Regular)){
                    flags[10].flag=true;
                }
                if(FormatManager.chechinput(raffleresults,FormatManager.FormatOption.Regular)){
                    flags[11].flag=true;
                }
                if(FormatManager.chechinput(marketmesage,FormatManager.FormatOption.Regular)){
                    flags[12].flag=true;
                }
                if(FormatManager.chechinput(datetime,FormatManager.FormatOption.Date)){
                    flags[13].flag=true;
                }
                bool totalfalg=true;
                foreach(var flagobj in flags){
                    if(!flagobj.flag){
                        totalfalg=false;
                    }
                }
                if(totalfalg==true){

                    AddSpinner(rootlayout,RaffleBuyerSignUpScreenData.LoadingScreenTextCreate);

                    Dictionary<string,string> paramdic =new Dictionary<string, string>();
                    paramdic.Add("email",email);
                    paramdic.Add("firstname",firstname);
                    paramdic.Add("lastname",lastname);
                    paramdic.Add("birthdate",datetime);
                    paramdic.Add("m_phone",mobilephone);
                    paramdic.Add("add1",address1);
                    paramdic.Add("add2",address2);
                    paramdic.Add("city",city);
                    paramdic.Add("province",stateandprovince);
                    paramdic.Add("postal",postcode);
                    paramdic.Add("country",country);
                    paramdic.Add("raffle_result",raffleresults);
                    paramdic.Add("charity_marketing_message",marketmesage);

                    App.INSTANCE.networknamager.Register (paramdic,(Tap5050WebResponse response)=>{
                        nn_activity.RunOnUiThread(()=>{
                            RemoveSpinner (rootlayout);
                        });
                        if(response.available){
                            if((response.parsedobject as Register).result_success.Equals("Y")) {
                                nn_activity.ShowCustomAlterDialogFragment(RaffleBuyerSignUpScreenData.AlertScreenCreateAccountRespondTitle,RaffleBuyerSignUpScreenData.AlertScreenCreateAccountRespondSuccessMessage,"OK",null,"successdialog.buyersignup.success");
                            }
                            else if((response.parsedobject as Register).result_success.Equals("N")){
                                nn_activity.ShowCustomAlterDialogFragment((response.parsedobject as Register).err_message,"OK",null,"invalidedialog.buyersignup.failed");
                            }
                        }
                        else{
                            nn_activity.ShowCustomAlterDialogFragment(GlobalScreenData.WebExceptionTitle,response.exceptionreport.errormessage,"Ok",null,"exceptiondialog.buyersignup.failed");
                        }
                    });

                }
                else if(!email.Equals(reemail)){
                    Toast.MakeText(nn_activity,RaffleBuyerSignUpScreenData.AlertScreenEmailNotMatchTitle+"\n"+RaffleBuyerSignUpScreenData.AlertScreenEmailNotMatchMessage,ToastLength.Long).Show();
                }
                else if(totalfalg==false){
                    string message="Please check:\n";
                    for(int i=0;i<flags.Length;i++){
                        if(flags[i].flag==false){
                            if(i!=flags.Length-1){
                                message+=flags[i].message+"\n";
                            }else{
                                message+=flags[i].message+".";
                            }
                        }
                    }
                    nn_activity.ShowCustomAlterDialogFragment(RaffleBuyerSignUpScreenData.AlertScreenFormatErrorTitle,message,"OK",null,"formatcheckdialog");
                }

            };

            return view;
        }
Exemplo n.º 2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);
            nn_email = Intent.GetStringExtra ("autofillemail") ?? "";

            getcountryflag = false;
            getprovincestate = false;

            SetContentView (Resource.Layout.signup);

            rootlayout = (RelativeLayout)FindViewById (Resource.Id.rootlayout);

            SetTitleBarText (RegisterScreenData.Screentitle);
            SetTitleLeftImg (TapUtil.defaulticon);
            AddSpinner (RegisterScreenData.LoadingScreenTextInit);

            RelativeLayout backcontainer=(RelativeLayout)rootlayout.FindViewById (Resource.Id.header_back_relativelayout);
            backcontainer.Visibility = ViewStates.Visible;
            backimg = (ImageView)rootlayout.FindViewById (Resource.Id.header_backimg_imageview);
            backimg.Click+= (object sender, EventArgs e) => {
                Finish();
            };

            TextView basicinfo=FindViewById<TextView> (Resource.Id.signup_basicinfo_textview);
            basicinfo.Text = RegisterScreenData.BasicInfoLabelText;

            TextView contactinfo=FindViewById<TextView> (Resource.Id.signup_contactinfo_textview);
            contactinfo.Text = RegisterScreenData.ContactInfoLabelText;

            TextView address=FindViewById<TextView> (Resource.Id.signup_address_textview);
            address.Text = RegisterScreenData.AddressInfoLabelText;

            TextView communicateraffle=FindViewById<TextView> (Resource.Id.signup_communicateraffle_textview);
            communicateraffle.Text = RegisterScreenData.RaffleResultsLabelText;

            TextView receivecharity=FindViewById<TextView> (Resource.Id.signup_receivecharity_textview);
            receivecharity.Text = RegisterScreenData.CharityMarketingMessagesLabelText;

            picktimebutton = FindViewById<Button> (Resource.Id.signup_birthday_button);
            picktimebutton.Hint=RegisterScreenData.BirthDateTextFieldPlaceholder;
            picktimebutton.Click += (object sender, EventArgs e) => {
                showDatePickerDialog ();
            };

            countryspinner = FindViewById<Spinner> (Resource.Id.signup_country_spinner);
            countryspinner.ItemSelected+= (object sender, AdapterView.ItemSelectedEventArgs e) => {
                if(stateandprovincespinneradapter!=null){
                stateandprovincespinneradapter.ChangeShowList(provincespinner,listcountry[e.Position].country_code);
                stateandprovincespinneradapter.NotifyDataSetChanged ();
                }
                countryspinner.Tag=e.Position;
            };

            provincespinner= FindViewById<Spinner> (Resource.Id.signup_province_spinner);
            provincespinner.ItemSelected+= (object sender, AdapterView.ItemSelectedEventArgs e) => {
                provincespinner.Tag=e.Position;
            };

            raffleresultspinner= FindViewById<Spinner> (Resource.Id.signup_raffleresult_spinner);

            resultadapter = new CustomResultAndMessageSpinnerAdapter (this, GlobalVariable.ResultAndMessageList);
            raffleresultspinner.Adapter = resultadapter;
            resultadapter.NotifyDataSetChanged ();

            raffleresultspinner.ItemSelected+= (object sender, AdapterView.ItemSelectedEventArgs e) => {
                raffleresultspinner.Tag=e.Position;
            };

            marketmesagespinner= FindViewById<Spinner> (Resource.Id.signup_marketingmessage_spinner);

            messaegadapter = new CustomResultAndMessageSpinnerAdapter (this, GlobalVariable.ResultAndMessageList);
            marketmesagespinner.Adapter = messaegadapter;
            messaegadapter.NotifyDataSetChanged ();

            marketmesagespinner.ItemSelected+= (object sender, AdapterView.ItemSelectedEventArgs e) => {
                marketmesagespinner.Tag=e.Position;
            };

            firstname_edittext = FindViewById<EditText> (Resource.Id.signup_firstname_edittext);
            SetEditTextMaximumLength (firstname_edittext,100);
            firstname_edittext.Hint = RegisterScreenData.FirstNameTextFieldPlaceholder;

            lastname_edittext = FindViewById<EditText> (Resource.Id.signup_lastname_edittext);
            SetEditTextMaximumLength (lastname_edittext,100);
            lastname_edittext.Hint = RegisterScreenData.LastNameTextFieldPlaceholder;

            mobilephone_edittext = FindViewById<EditText> (Resource.Id.signup_mobilephone_edittext);
            SetEditTextMaximumLength (mobilephone_edittext,20);
            mobilephone_edittext.InputType = global::Android.Text.InputTypes.ClassPhone;
            mobilephone_edittext.Hint = RegisterScreenData.MobilePhoneTextFieldPlaceholder;

            email_edittext = FindViewById<EditText> (Resource.Id.signup_email_edittext);
            SetEditTextMaximumLength (email_edittext,60);
            if(!string.IsNullOrEmpty(nn_email)){
                email_edittext.Text = nn_email;
            }
            email_edittext.Hint = RegisterScreenData.EmailTextFieldPlaceholder;

            confirmemail_edittext = FindViewById<EditText> (Resource.Id.signup_reemail_edittext);
            SetEditTextMaximumLength (confirmemail_edittext,60);
            confirmemail_edittext.Hint = RegisterScreenData.EmailConfirmTextFieldPlaceholder;

            address1_edittext = FindViewById<AutoCompleteTextView> (Resource.Id.signup_address1_edittext);
            SetEditTextMaximumLength (address1_edittext,100);
            address1_edittext.Hint = RegisterScreenData.Address1TextFieldPlaceholder;
            address1_edittext.Adapter=new GooglePlacesAutocompleteAdapter(this);
            address1_edittext.OnItemClickListener = this;
            address1_edittext.Threshold = 3;

            address2_edittext = FindViewById<EditText> (Resource.Id.signup_address2_edittext);
            SetEditTextMaximumLength (address2_edittext,100);
            address2_edittext.Hint = RegisterScreenData.Address2TextFieldPlaceholder;

            city_edittext = FindViewById<EditText> (Resource.Id.signup_city_edittext);
            SetEditTextMaximumLength (city_edittext,50);
            city_edittext.Hint = RegisterScreenData.CityTextFieldPlaceholder;

            postcode_edittext = FindViewById<EditText> (Resource.Id.signup_postal_edittext);
            SetEditTextMaximumLength (postcode_edittext,20);
            postcode_edittext.Hint = RegisterScreenData.ZipcodeTextFieldPlaceholder;

            MobileBarcodeScanner.Initialize (Application);
            scanner = new MobileBarcodeScanner();

            //			Button scanlicencebut=FindViewById<Button> (Resource.Id.signup_scanlicence_button);
            //			scanlicencebut.Click+=async delegate {
            //				//Tell our scanner to use the default overlay
            //				scanner.UseCustomOverlay = false;
            //
            //				//We can customize the top and bottom text of the default overlay
            //				scanner.TopText = "Hold the camera up to the barcode\nAbout 6 inches away";
            //				scanner.BottomText = "Wait for the barcode to automatically scan!";
            //
            //				//Start scanning
            //				var result = await scanner.Scan();
            //
            //				HandleScanResult(result);
            //			};

            Button createaccountbutton = FindViewById<Button> (Resource.Id.signup_createaccount_button);
            createaccountbutton.Text = RegisterScreenData.CreateAccountBtnTitle;
            createaccountbutton.Click+= (object sender, EventArgs e) => {

                FormatCheckFlagObject[] flags=new FormatCheckFlagObject[14];
                for(int i=0;i<flags.Length;i++){
                    string message="";
                    if(i==0){
                        message="First Name";
                    }
                    if(i==1){
                        message="Last Name";
                    }
                    if(i==2){
                        message="Mobile Phone";
                    }
                    if(i==3){
                        message="Email";
                    }
                    if(i==4){
                        message="Email Confirm";
                    }
                    if(i==5){
                        message="Address1";
                    }
                    if(i==6){
                        message="Address2";
                    }
                    if(i==7){
                        message="City";
                    }
                    if(i==8){
                        message="Postcode";
                    }
                    if(i==9){
                        message="Country";
                    }
                    if(i==10){
                        message="State And Province";
                    }
                    if(i==11){
                        message="Raffle Results";
                    }
                    if(i==12){
                        message="Market Message";
                    }
                    if(i==13){
                        message="Birthdate";
                    }
                    flags[i]=new FormatCheckFlagObject(message);
                }

                string firstname = firstname_edittext.Text;
                string lastname=lastname_edittext.Text;
                string mobilephone=mobilephone_edittext.Text;
                string email=email_edittext.Text;
                string reemail=confirmemail_edittext.Text;
                string address1=address1_edittext.Text;
                string address2=address2_edittext.Text;
                string city=city_edittext.Text;
                string postcode=postcode_edittext.Text;

                string country=countryspinner.Tag==null?"":listcountry[(int)countryspinner.Tag].country_code;
                string stateandprovince=provincespinner.Tag==null?"":stateandprovincespinneradapter.showlist[(int)provincespinner.Tag].state_province_abbrev;

                string raffleresults=raffleresultspinner.Tag==null?"":GlobalVariable.ResultAndMessageList[(int)raffleresultspinner.Tag];
                string marketmesage=marketmesagespinner.Tag==null?"":GlobalVariable.ResultAndMessageList[(int)marketmesagespinner.Tag];

                string datetime=picktimebutton.Text;

                if(FormatManager.chechinput(firstname,FormatManager.FormatOption.OnlyLetter)){
                    flags[0].flag=true;
                }
                if(FormatManager.chechinput(lastname,FormatManager.FormatOption.OnlyLetter)){
                    flags[1].flag=true;
                }
                if(FormatManager.chechinput(mobilephone,FormatManager.FormatOption.OnlyNumber)&&mobilephone.Length>=5){
                    flags[2].flag=true;
                }
                if(FormatManager.chechinput(email,FormatManager.FormatOption.Email)){
                    flags[3].flag=true;
                }
                if(FormatManager.chechinput(reemail,FormatManager.FormatOption.Email)){
                    flags[4].flag=true;
                }
                if(!email.Equals(reemail)){
                    flags[4].flag=false;
                }
                if(FormatManager.chechinput(address1,FormatManager.FormatOption.Regular)){
                    flags[5].flag=true;
                }
                if(FormatManager.chechinput(address2,FormatManager.FormatOption.Regular)){
                    flags[6].flag=true;
                }
                //address2 can be empty
                if(address2.Equals("")){
                    flags[6].flag=true;
                }
                if(FormatManager.chechinput(city,FormatManager.FormatOption.Regular)){
                    flags[7].flag=true;
                }
                if(FormatManager.chechinput(postcode,FormatManager.FormatOption.Regular)){
                    flags[8].flag=true;
                }
                //postcode can be empty
                if(postcode.Equals("")){
                    flags[8].flag=true;
                }
                if(FormatManager.chechinput(country,FormatManager.FormatOption.Regular)){
                    flags[9].flag=true;
                }
                if(FormatManager.chechinput(stateandprovince,FormatManager.FormatOption.Regular)){
                    flags[10].flag=true;
                }
                if(FormatManager.chechinput(raffleresults,FormatManager.FormatOption.Regular)){
                    flags[11].flag=true;
                }
                if(FormatManager.chechinput(marketmesage,FormatManager.FormatOption.Regular)){
                    flags[12].flag=true;
                }
                if(FormatManager.chechinput(datetime,FormatManager.FormatOption.Date)){
                    flags[13].flag=true;
                }
                bool totalfalg=true;
                foreach(var flagobj in flags){
                    if(!flagobj.flag){
                        totalfalg=false;
                    }
                }
                if(totalfalg==true && email.Equals(reemail)){

                    AddSpinner(RegisterScreenData.LoadingScreenTextCreate);

                    Dictionary<string,string> paramdic =new Dictionary<string, string>();
                    paramdic.Add("email",email);
                    paramdic.Add("firstname",firstname);
                    paramdic.Add("lastname",lastname);
                    paramdic.Add("birthdate",datetime);
                    paramdic.Add("m_phone",mobilephone);
                    paramdic.Add("add1",address1);
                    paramdic.Add("add2",address2);
                    paramdic.Add("city",city);
                    paramdic.Add("province",stateandprovince);
                    paramdic.Add("postal",postcode);
                    paramdic.Add("country",country);
                    paramdic.Add("raffle_result",raffleresults);
                    paramdic.Add("charity_marketing_message",marketmesage);
            //					//try to create new user
                    App.INSTANCE.networknamager.Register (paramdic,(Tap5050WebResponse response)=>{
                        this.RunOnUiThread(()=>{
                            RemoveSpinner ();
                        });
                        if(response.available){
                            if((response.parsedobject as Register).result_success.Equals("Y")) {
                                ShowCustomAlterDialogFragment(RegisterScreenData.AlertScreenCreateAccountRespondTitle,RegisterScreenData.AlertScreenCreateAccountRespondSuccessMessage,GlobalScreenData.DefaultPositive,null,"registersuccessdialog");
                            }
                            else if((response.parsedobject as Register).result_success.Equals("N")){
                                ShowCustomAlterDialogFragment((response.parsedobject as Register).err_message,GlobalScreenData.DefaultPositive,null,"registerfailedsdialog");
                            }
                        }
                        else{
                            ShowCustomAlterDialogFragment(response.exceptionreport.errormessage,GlobalScreenData.DefaultPositive,null,"registerexceptiondialog");
                        }
                    });

                }
                else if(!email.Equals(reemail)){
                    Toast.MakeText(this,RegisterScreenData.AlertScreenEmailNotMatchTitle+"\n"+RegisterScreenData.AlertScreenEmailNotMatchMessage,ToastLength.Long).Show();
                }
                else if(totalfalg==false){
                    string message="Please check:\n";
                    for(int i=0;i<flags.Length;i++){
                        if(flags[i].flag==false){
                            if(i!=flags.Length-1){
                                message+=flags[i].message+"\n";
                            }else{
                                message+=flags[i].message+".";
                            }
                        }
                    }
                    ShowCustomAlterDialogFragment(RegisterScreenData.AlertScreenFormatErrorTitle,message,GlobalScreenData.DefaultPositive,null,"formatcheckdialog");
                }

            };
            GetCountryStateAndProivince ();
        }
Exemplo n.º 3
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            rootview=(RelativeLayout)inflater.Inflate (Resource.Layout.accountedit, container, false);

            firstnameedittext=(EditText)rootview.FindViewById (Resource.Id.accountedit_firstname_edittext);
            nn_activity.SetEditTextMaximumLength (firstnameedittext,100);
            firstnameedittext.Text = nn_accountinfo.first_name;

            lasetnameedittext=(EditText)rootview.FindViewById (Resource.Id.accountedit_lastname_edittext);
            nn_activity.SetEditTextMaximumLength (lasetnameedittext,100);
            lasetnameedittext.Text= nn_accountinfo.last_name;

            birthdatebutton = (Button)rootview.FindViewById (Resource.Id.accountedit_birthday_button);
            birthdatebutton.Hint="Birthdate";
            birthdatebutton.Click += (object sender, EventArgs e) => {
                showDatePickerDialog ();
            };
            birthdatebutton.Text = nn_accountinfo.user_birthdate.Split ('T') [0].Replace("-","/");

            mobilephoneedittext=(EditText)rootview.FindViewById (Resource.Id.accountedit_mobilephone_edittext);
            nn_activity.SetEditTextMaximumLength (mobilephoneedittext,20);

            mobilephoneedittext.Text = nn_accountinfo.phone_mobile;

            emailedittext = (EditText)rootview.FindViewById (Resource.Id.accountedit_email_edittext);
            nn_activity.SetEditTextMaximumLength (emailedittext,60);
            emailedittext.Focusable = false;
            emailedittext.InputType = global::Android.Text.InputTypes.Null;
            emailedittext.Text = nn_accountinfo.email;

            address1edittext=(EditText)rootview.FindViewById (Resource.Id.accountedit_address1_edittext);
            nn_activity.SetEditTextMaximumLength (address1edittext,100);
            address1edittext.Text = nn_accountinfo.mail_address_line_1;

            address2edittext=(EditText)rootview.FindViewById (Resource.Id.accountedit_address2_edittext);
            nn_activity.SetEditTextMaximumLength (address2edittext,100);
            address2edittext.Text = nn_accountinfo.mail_address_line_2;

            countryspinner=(Spinner)rootview.FindViewById (Resource.Id.accountedit_country_spinner);
            countryspinner.ItemSelected+= (object sender, AdapterView.ItemSelectedEventArgs e) => {
                if(stateandprovincespinneradapter!=null){
                    stateandprovincespinneradapter.ChangeShowList(provincespinner,listcountry[e.Position].country_code);
                    stateandprovincespinneradapter.NotifyDataSetChanged ();
                }
                countryspinner.Tag=e.Position;
            };

            provincespinner=(Spinner)rootview.FindViewById (Resource.Id.accountedit_province_spinner);
            provincespinner.ItemSelected+= (object sender, AdapterView.ItemSelectedEventArgs e) => {
                provincespinner.Tag=e.Position;
            };

            cityedittext = (EditText)rootview.FindViewById (Resource.Id.accountedit_city_edittext);
            nn_activity.SetEditTextMaximumLength (cityedittext,50);
            cityedittext.Text = nn_accountinfo.mail_city;

            postaledittext=(EditText)rootview.FindViewById (Resource.Id.accountedit_postal_edittext);
            nn_activity.SetEditTextMaximumLength (postaledittext,20);
            postaledittext.Text = nn_accountinfo.mail_postal;

            raffleresultspinner=(Spinner)rootview.FindViewById (Resource.Id.accountedit_raffleresult_spinner);
            resultadapter = new CustomResultAndMessageSpinnerAdapter (nn_activity, GlobalVariable.ResultAndMessageList);
            raffleresultspinner.Adapter = resultadapter;
            resultadapter.NotifyDataSetChanged ();
            raffleresultspinner.ItemSelected+= (object sender, AdapterView.ItemSelectedEventArgs e) => {
                raffleresultspinner.Tag=e.Position;
            };
            if (!nn_accountinfo.prefered_contact_method.Equals(null)) {
                int spinnerPosition = 0;
                for(int i=0;i< GlobalVariable.ResultAndMessageList.Count;i++){
                    if(GlobalVariable.ResultAndMessageList[i].Equals(nn_accountinfo.prefered_contact_method)){
                        spinnerPosition = i;
                    }
                }
                raffleresultspinner.SetSelection(spinnerPosition);
            }

            charitymessagespinner=(Spinner)rootview.FindViewById (Resource.Id.accountedit_marketingmessage_spinner);
            messaegadapter = new CustomResultAndMessageSpinnerAdapter (nn_activity, GlobalVariable.ResultAndMessageList);
            charitymessagespinner.Adapter = messaegadapter;
            messaegadapter.NotifyDataSetChanged ();
            charitymessagespinner.ItemSelected+= (object sender, AdapterView.ItemSelectedEventArgs e) => {
                charitymessagespinner.Tag=e.Position;
            };
            if (!nn_accountinfo.prefered_contact_methodcharity.Equals(null)) {
                int spinnerPosition = 0;
                for(int i=0;i< GlobalVariable.ResultAndMessageList.Count;i++){
                    if(GlobalVariable.ResultAndMessageList[i].Equals(nn_accountinfo.prefered_contact_methodcharity)){
                        spinnerPosition = i;
                    }
                }
                charitymessagespinner.SetSelection(spinnerPosition);
            }

            TextView firstnamelabel=rootview.FindViewById<TextView> (Resource.Id.accountedit_firstname_label);
            firstnamelabel.Text = EditAccountScreenData.AccountFirstNameLabel;

            TextView AccountLastNameLabel=rootview.FindViewById<TextView> (Resource.Id.accountedit_lastname_label);
            AccountLastNameLabel.Text = EditAccountScreenData.AccountLastNameLabel;

            TextView AccountMobilePhoneLabel=rootview.FindViewById<TextView> (Resource.Id.accountedit_mobilephone_label);
            AccountMobilePhoneLabel.Text = EditAccountScreenData.AccountMobilePhoneLabel;

            TextView AccountEmailLabel=rootview.FindViewById<TextView> (Resource.Id.accountedit_email_label);
            AccountEmailLabel.Text = EditAccountScreenData.AccountEmailLabel;

            TextView AccountAddress1Label=rootview.FindViewById<TextView> (Resource.Id.accountedit_address1_label);
            AccountAddress1Label.Text = EditAccountScreenData.AccountAddress1Label;

            TextView AccountAddress2Label=rootview.FindViewById<TextView> (Resource.Id.accountedit_address1_label);
            AccountAddress2Label.Text = EditAccountScreenData.AccountAddress2Label;

            TextView AccountCityLabel=rootview.FindViewById<TextView> (Resource.Id.accountedit_city_label);
            AccountCityLabel.Text = EditAccountScreenData.AccountCityLabel;

            TextView AccountPostalLabel=rootview.FindViewById<TextView> (Resource.Id.accountedit_postal_label);
            AccountPostalLabel.Text = EditAccountScreenData.AccountPostalLabel;

            // info label
            TextView basicinfo=rootview.FindViewById<TextView> (Resource.Id.accountedit_basicinfo_textview);
            basicinfo.Text = EditAccountScreenData.BasicInfoLabelText;

            TextView contactinfo=rootview.FindViewById<TextView> (Resource.Id.accountedit_contactinfo_textview);
            contactinfo.Text = EditAccountScreenData.ContactInfoLabelText;

            TextView address=rootview.FindViewById<TextView> (Resource.Id.accountedit_addressinfo_textview);
            address.Text = EditAccountScreenData.AddressInfoLabelText;

            TextView communicateraffle=rootview.FindViewById<TextView> (Resource.Id.accountedit_communicateraffle_textview);
            communicateraffle.Text = EditAccountScreenData.RaffleResultsLabelText;

            TextView receivecharity=rootview.FindViewById<TextView> (Resource.Id.accountedit_receivecharity_textview);
            receivecharity.Text = EditAccountScreenData.CharityMarketingMessagesLabelText;

            Button editaccountbutton = rootview.FindViewById<Button> (Resource.Id.accountedit_updateaccount_button);
            editaccountbutton.Text = EditAccountScreenData.UpdateBtnText;
            editaccountbutton.Click += OnUpdateAccount;

            return rootview;
        }