protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.LayLogin); CopyExistingDB(); var url = ConAddress.GetConnectionURL(); GlobalVariables.GlobalUrl = url.url; txtuser = FindViewById <EditText> (Resource.Id.txtusername); txtpass = FindViewById <EditText> (Resource.Id.txtpassword); btnlogin = FindViewById <Button>(Resource.Id.btnlogin); btnlogin.Click += new EventHandler(btnlogin_click); //var intent1 = new Intent (); //intent1.SetClass (this, typeof(ActMemberAdd)); //StartActivity (intent1); var users = ConAddress.GetUser(); if (users.username != "") { GlobalVariables.GlobalUserid = users.user_id; GlobalVariables.GlobalFname = users.fname; GlobalVariables.GlobalLname = users.lname; var intent = new Intent(); intent.SetClass(this, typeof(ActAddress)); Toast.MakeText(this, "Login Successfully\n" + users.fname + " " + users.lname + ".", ToastLength.Long).Show(); StartActivity(intent); } }
private async void btnlogin_click(object sender, EventArgs e) { var url = ConAddress.GetConnectionURL(); GlobalVariables.GlobalUrl = url.url; if (txtuser.Text != "" && txtpass.Text != "") { var progressDialog = ProgressDialog.Show(this, "Please wait...", "Verifying Credentials...", true); try { await(ApiConnection1.UserLogin(GlobalVariables.GlobalUrl + "/login/" + txtuser.Text + "/" + txtpass.Text)); var users = ConAddress.GetUser(); if (users.username != "") { GlobalVariables.GlobalUserid = users.user_id; GlobalVariables.GlobalFname = users.fname; GlobalVariables.GlobalLname = users.lname; var intent = new Intent(); intent.SetClass(this, typeof(ActAddress)); Toast.MakeText(this, "Login Successfully\n" + users.fname + " " + users.lname + ".", ToastLength.Long).Show(); StartActivity(intent); } else { Toast.MakeText(this, "Login Failed\nIncorect UserName Or Password..", ToastLength.Long).Show(); } } catch (Exception ex) { Toast.MakeText(this, "Unable To Connect To Server.\n" + ex.Message, ToastLength.Long).Show(); } progressDialog.Cancel(); } else { Toast.MakeText(this, "Unable To Login.\nPlease Complete Your Credential..", ToastLength.Long).Show(); } txtpass.Text = ""; }