Esempio n. 1
0
		private async void Load()
		{
			DateTime now = new DateTime ();
			DatoWebService service = new DatoWebService();

			List<Prenotazioni> myArr = new List<Prenotazioni> ();
			myArr = await service.elencoPrenotazioni (App.id, string.Format ("{0:dd-MM-yyyy}", now));

			System.Diagnostics.Debug.WriteLine(myArr[0].username);
		

			StackLayout stack = new StackLayout {
				HorizontalOptions = LayoutOptions.Center,
				Spacing = 20,
				Children = {
				}
			};
			Content = new ScrollView { Content = stack };
		}
Esempio n. 2
0
		public CreateAccount ()
		{
			var create = new Button { Text = "Create Account" };
			create.Clicked += async (sender, e) => {

				if (String.IsNullOrEmpty(username.Text) || String.IsNullOrEmpty(password.Text)|| String.IsNullOrEmpty(email.Text) || String.IsNullOrEmpty(telefono.Text) || String.IsNullOrEmpty(via.Text) || String.IsNullOrEmpty(denominazione.Text))
				{
					await DisplayAlert("Errore", "Compila tutti i campi correttamente", "Re-try");
				}
				else if (password.Text != confirmPassword.Text) {
					await DisplayAlert("Errore", "Le password inserite non coincidono", "Re-try");
				}
				else if (Regex.Match(email.Text, @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$").Success) {
					var sv = new DatoWebService();
					String result = await sv.Create(denominazione.Text, via.Text, telefono.Text, email.Text, username.Text, password.Text);
					HandleResult(result);
				} else {
					await DisplayAlert("Errore", "Indirizzo Email Non Valido", "Re-try");
				}

			};

			var cancel = new Button { Text = "Cancel" };
			cancel.Clicked += (sender, e) => {
				App.Current.MainPage = new NavigationPage(new LoginPage());
			};
			username = new Entry {
				Keyboard = Keyboard.Text,
				Placeholder = "Enter Username",
			};

			denominazione = new Entry {
				Placeholder = "Inserisci il nome del locale"
			};

			via = new Entry {
				Placeholder = "Indirizzo"
			};

			password = new Entry {
				Keyboard = Keyboard.Text,
				Placeholder = "Enter password",
				IsPassword = true,
			};

			confirmPassword = new Entry {
				Keyboard = Keyboard.Text,
				Placeholder = "Confirm password",
				IsPassword = true,
			};

			email = new Entry {
				Keyboard = Keyboard.Email,
				Placeholder = "Enter your e-mail",
			};

			telefono = new Entry {
				Keyboard = Keyboard.Telephone,
				Placeholder = "Enter Number",
			};

			Content = new StackLayout {
				Padding = new Thickness (10, 40, 10, 10),
				Children = {
					new Label { 
						Text = "Compila i campi richiesti per la registrazione",
						FontSize = 20,
						TextColor = Color.Blue,
						//XAlign = TextAlignment.Center
					},
					new Label { Text = "Username" },
					username,
					new Label { Text = "Denominazione ristorante/pizzeria" },
					denominazione,
					new Label { Text = "Via" },
					via,
					new Label { Text = "Password" },
					password,
					new Label { Text = "Confirm Password" },
					confirmPassword,
					new Label { Text = "Email" },
					email,
					new Label { Text = "Telefono" },
					telefono,
					create, cancel
				}
			};
		}
Esempio n. 3
0
		public LoginPage ()
		{
			System.Diagnostics.Debug.WriteLine("COSTRUTTORE LOGIN PAGE");
			var sv = new DatoWebService();
			var accedi = new Button { Text = "Accedi" };
			accedi.Clicked += async (sender, e) => {
				if (await sv.CheckNetwork()){
					if (String.IsNullOrEmpty(username.Text) || String.IsNullOrEmpty(password.Text))
					{
						await DisplayAlert("Validation Error", "Username and Password are required", "Retry");
					}
					else {
						System.Diagnostics.Debug.WriteLine("ACCESSO OK");
						String result = await sv.LoginTestAsync(username.Text,password.Text);
						App.user = username.Text;
						App.dati = await sv.getRistorante(username.Text);
						App.id = await sv.idRistorante(App.user);
						HandleResult(result);
						System.Diagnostics.Debug.WriteLine("id: "+ App.id);
						//await Navigation.PushAsync(new Profilo());
					}
				} else {
					await DisplayAlert("Errore", "Verifica la connessione ad internet", "Ok");
				}
			};

			var create = new Button { Text = "Registrati" };
			create.Clicked += (sender, e) => {
				Navigation.PushModalAsync(new CreateAccount());
			};

			username = new Entry {
				//Text=globalUser,
				Keyboard = Keyboard.Text,
				Placeholder = "Type Username",
				WidthRequest = 200,
				HorizontalOptions = LayoutOptions.Start
			};

			password = new Entry {
				Keyboard = Keyboard.Text,
				Placeholder = "Type password",
				IsPassword = true,
			};


			Content = new StackLayout {
				Padding = new Thickness (10, 20, 10, 10),
				Children = {
					new BoxView { HorizontalOptions = LayoutOptions.FillAndExpand, },
					new Label { Text = "Username" },
					username,
					new Label { Text = "Password" },
					password,
					accedi, 
					create

				},
				HorizontalOptions = LayoutOptions.CenterAndExpand,
				Spacing = 10
			};
		}
Esempio n. 4
0
		public async void Personale(){

			DatoWebService sv = new DatoWebService ();
			Image avatar = new Image
			{
				Source = "Avatar.png",
				Aspect = Aspect.AspectFit,
				HorizontalOptions = LayoutOptions.Center,
				//VerticalOptions = LayoutOptions.Fill
			};

			Label info = new Label
			{
				Text = App.dati,
				FontSize = Device.GetNamedSize (NamedSize.Large, typeof(Label)),
				HorizontalOptions = LayoutOptions.Center,
				XAlign = TextAlignment.Center
			};

			DateTime now = DateTime.Now.ToLocalTime ();


			Label data = new Label {
				Text = string.Format ("{0:dd/MM/yyyy}", now),
				HorizontalOptions = LayoutOptions.Center,
				FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label))
			};

			Button genera = new Button {
				Text = "GENERA CODICE GIORNALIERO",
				WidthRequest = 50,
				HeightRequest = 50
			};

			Button logout = new Button {
				Text = "LOGOUT",
				WidthRequest = 50,
				HeightRequest = 50
			};

			Label cod = new Label {
				XAlign = TextAlignment.Center
			};

			String[] splitstring;
			String r = await sv.dailyCheck(App.id, string.Format ("{0:dd-MM-yyyy}", now));

			if (r.Equals("NOTREACH")){
				await DisplayAlert ("Errore", "Errore nel server", "OK");
			} else if (r.Equals ("FALSE")) {
				cod.Text = "Genera il tuo codice giornaliero";
				genera.IsEnabled = true;
			} else {
				splitstring = r.Split('\n');
				App.idcg = splitstring [0];
				App.cg = splitstring [1];
				cod.Text = App.cg;
				genera.IsEnabled = false;
			}

			genera.Clicked += async (object sender, EventArgs e) => {
				String s = randomString ();
				await DisplayAlert ("CODICE GIORNALIERO", "Il codice giornaliero è: " + s, "OK");
				//String result = await sv.setCodiceGiornaliero(s, string.Format ("{0:yyyy-M-d}", now));
				r = await sv.setCodiceGiornaliero (s, string.Format ("{0:dd-MM-yyyy}", now), App.id);

				if (r.Equals("FALSE")){
					await DisplayAlert ("Errore", "Errore nel server", "OK");
				} else {
					App.id = r;
					App.cg = s;
					cod.Text = App.cg;
					genera.IsEnabled = false;
				}

			};



			logout.Clicked += (object sender, EventArgs e) => {
				App.Current.MainPage = new NavigationPage(new LoginPage());
				//Navigation.PushAsync(new LoginPage());
			};

			StackLayout stack = new StackLayout {
				Children = {
					avatar,
					new BoxView { HorizontalOptions = LayoutOptions.FillAndExpand },
					info,
					data,
					new BoxView { HorizontalOptions = LayoutOptions.FillAndExpand },
					cod,
					genera,
					new BoxView { HorizontalOptions = LayoutOptions.FillAndExpand },
					logout
				},
			};
			Content = new ScrollView { Content = stack};
		}