Ejemplo n.º 1
0
        public LoginPage()
        {
            InitializeComponent();
            loginVM = new LoginViewModel();
            EntryUserLogin.Completed += (object sender, EventArgs e) =>
            {
                EntryUserPassword.Focus();
            };

            //EntryUserPassword.Completed += (object sender, EventArgs e) =>
            //{
            //    loginVM.SubmitCommand.Execute(null);
            //};
        }
Ejemplo n.º 2
0
 public RegisterPage()
 {
     InitializeComponent();
     NavigationPage.SetHasBackButton(this, false);
     EntryEmail.ReturnCommand        = new Command(() => EntryUserName.Focus());
     EntryUserName.ReturnCommand     = new Command(() => EntryUserPassword.Focus());
     EntryUserPassword.ReturnCommand = new Command(() => EntryUserPConfirm.Focus());
     if (App.originalStyle)
     {
         Resources["currentStyle"] = Resources["lightTheme"];
     }
     else
     {
         Resources["currentStyle"] = Resources["darkTheme"];
     }
 }
Ejemplo n.º 3
0
        private async void Button_Clicked(object sender, EventArgs e)
        {
            if (EntryUserName.Text == null)
            {
                //await this.DisplayAlert(null, "กรุณาระบุชื่อผู้ใช้งาน", null, "ตกลง");
                EntryUserName.PlaceholderColor = Color.FromHex("#ffb3ba");
                EntryUserName.Placeholder      = "กรุณาระบุชื่อผู้ใช้งาน";
                EntryUserName.Focus();
                return;
            }

            if (EntryUserPassword.Text == null)
            {
                //await this.DisplayAlert(null, "กรุณาระบุรหัสผ่าน", null, "ตกลง");
                EntryUserPassword.PlaceholderColor = Color.FromHex("#ffb3ba");
                EntryUserPassword.Placeholder      = "กรุณาระบุรหัสผ่าน";
                EntryUserPassword.Focus();
                return;
            }

            if (EntryUserEmail.Text == null)
            {
                //await this.DisplayAlert(null, "กรุณาระบุรหัสผ่าน", null, "ตกลง");
                EntryUserEmail.PlaceholderColor = Color.FromHex("#ffb3ba");
                EntryUserEmail.Placeholder      = "กรุณาระบุอีเมล์";
                EntryUserEmail.Focus();
                return;
            }

            if (EntryUserPhoneNumber.Text == null)
            {
                //await this.DisplayAlert(null, "กรุณาระบุรหัสผ่าน", null, "ตกลง");
                EntryUserPhoneNumber.PlaceholderColor = Color.FromHex("#ffb3ba");
                EntryUserPhoneNumber.Placeholder      = "กรุณาระบุเบอร์โทรศัพท์";
                EntryUserPhoneNumber.Focus();
                return;
            }

            Device.BeginInvokeOnMainThread(async() => {
                //Register data to firebase also
                var isExist = await apiRequestHelper.RequestCheckUserExistAsync(EntryUserName.Text);
                if (isExist == "true")
                {
                    Toast.MakeText(this.context, "ชื่อผู้ใช้งานซ้ำ", ToastLength.Short).Show();
                    EntryUserName.PlaceholderColor = Color.FromHex("#ffb3ba");
                    EntryUserName.Placeholder      = "กรุณาระบุชื่อผู้ใช้งานใหม่";
                    EntryUserName.Focus();
                    return;
                }

                var dbpath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "UserDatabase.db");
                var db     = new SQLiteConnection(dbpath);
                db.CreateTable <RegUserTable>();

                var item = new RegUserTable()
                {
                    UserName    = EntryUserName.Text,
                    Password    = EntryUserPassword.Text,
                    Email       = EntryUserEmail.Text,
                    PhoneNumber = EntryUserPhoneNumber.Text,
                };

                db.Insert(item);

                var profile = new ProfileTable()
                {
                    UserName    = EntryUserName.Text,
                    Email       = EntryUserEmail.Text,
                    PhoneNumber = EntryUserPhoneNumber.Text,
                };
                db.CreateTable <ProfileTable>();
                db.Insert(profile);


                //Register data to firebase also
                await apiRequestHelper.RequestRegisterUserAsync(EntryUserName.Text, EntryUserPassword.Text, EntryUserEmail.Text, EntryUserPhoneNumber.Text);
                ProfileJson json = new ProfileJson();
                json.UserName    = EntryUserName.Text;
                json.Email       = EntryUserEmail.Text;
                json.PhoneNumber = EntryUserPhoneNumber.Text;
                json.CreateDate  = DateTime.Now.ToString("dd/MM/yyyy hh:mm tt");
                await apiRequestHelper.RequestAddProfileAsync(json);


                var result = await this.DisplayAlert(null, "สมัครสมาชิกสำเร็จ!", null, "ตกลง");

                if (!result)
                {
                    await Navigation.PushAsync(new LoginPage());
                }
            });
        }