Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. using Android.App;
  7. using Android.Content;
  8. using Android.OS;
  9. using Android.Runtime;
  10. using Android.Views;
  11. using Android.Widget;
  12.  
  13. namespace Siman_Android
  14. {
  15. [Activity(Label = "PersonAddActivity")]
  16. public class PersonAddActivity : Activity
  17. {
  18. protected override void OnCreate(Bundle bundle)
  19. {
  20. base.OnCreate(bundle);
  21.  
  22.  
  23. Button btn = FindViewById<Button>(Resource.Id.btnadd);
  24.  
  25.  
  26. btn.Click += Btn_Click;
  27.  
  28. }
  29. ServiceRefrence.Service1 myService = new ServiceRefrence.Service1();
  30.  
  31. private void Btn_Click(object sender, EventArgs e)
  32. {
  33. myService.Url=("http://localhost:13294/Service1.svc");
  34. EditText txtname = FindViewById<EditText>(Resource.Id.txtname);
  35. EditText txtfamily = FindViewById<EditText>(Resource.Id.txtfamily);
  36.  
  37. myService.GetPersonAsync(txtname.Text, txtfamily.Text);
  38. }
  39. }
  40. }
  41.  
  42. public bool GetPerson(string FirstName, string LastName)
  43. {
  44. try
  45. {
  46. PersonName pr = new PersonName()
  47. {
  48. Family = LastName,
  49. Name = FirstName
  50. };
  51. db.PersonNames.Add(pr);
  52. db.SaveChanges();
  53. return true;
  54. }
  55. catch (Exception)
  56. {
  57.  
  58. return false;
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement