Esempio n. 1
0
 public void GetUserDetail(string userId)
 {
     userDetail       = db.GetItem(userId);
     txtname.Text     = userDetail.Name;
     txtuserid.Text   = userDetail.Username;
     txtpassword.Text = userDetail.Password;
 }
        async void Click_Reg(object sender, EventArgs e)
        {
            if (txtuserid.Text != "")
            {
                RegEntity fileexist = db.GetItem(txtuserid.Text);
                if (fileexist == null)
                {
                    if (txtname.Text != "" && txtpassword.Text != "" && txtuserid.Text != "")
                    {
                        RegEntity OReg = new RegEntity();
                        OReg.Name     = txtname.Text;
                        OReg.Username = txtuserid.Text;
                        OReg.Password = txtpassword.Text;
                        int i = db.SaveItem(OReg);
                        if (i > 0)
                        {
                            await DisplayAlert("Registrtion", "Registrtion Success ... Login and Edit profile ", "OK");

                            await Navigation.PushModalAsync(new MainPage());
                        }
                        else
                        {
                            await DisplayAlert("Registrtion", "Registrtion Fail .. Please try again ", "OK");
                        }
                    }
                }
                else
                {
                    await DisplayAlert("Registrtion Failed", "username already exist .. Please try differnt user name ", "OK");

                    txtuserid.Text = "";
                    txtuserid.Focus();
                }
            }
        }
Esempio n. 3
0
 public int SaveItem(RegEntity item)
 {
     lock (locker)
     {
         if (item.ID != 0)
         {
             //Update Item
             database.Update(item);
             return(item.ID);
         }
         else
         {
             //Insert item
             return(database.Insert(item));
         }
     }
 }
        async void Click_Login(object sender, EventArgs e)
        {
            RegEntity userDetail = db.GetItem(txtuserid.Text, txtpassword.Text);

            if (userDetail != null)
            {
                if (txtuserid.Text != userDetail.Username && txtpassword.Text != userDetail.Password)
                {
                    await DisplayAlert("Login", "Login failed .. Please try again ", "OK");
                }
                else
                {
                    await DisplayAlert("Registrtion", "Login Success ... Now Edit your profile ", "OK");

                    await Navigation.PushModalAsync(new Home(txtuserid.Text));
                }
            }
            else
            {
                await DisplayAlert("Login", "Login failed .. Please try again ", "OK");
            }
        }