private async void Button_login_Click(object sender, RoutedEventArgs e) { var dialog = new MessageDialog(""); dialog.Content = ""; using (var db = new GreenContext()) { var user = db.Usuarios.FirstOrDefault(l => l.UserName == txtBox_Username.Text && l.Password == txtBox_Password.Password); if (user != null) { UserId = user.Id; this.Frame.Navigate(typeof(UserMenu)); } else { dialog.Content += "The username or password are incorrect\n"; } } if (dialog.Content != "") { await dialog.ShowAsync(); } }
protected override void Initialize(HttpControllerContext controllerContext) { base.Initialize(controllerContext); IMobileAppSettingsProvider provider = controllerContext.Configuration.GetMobileAppSettingsProvider(); GreenContext context = new GreenContext(); DomainManager = new EntityDomainManager <Green>(context, Request, enableSoftDelete: true); }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.FullScreen; this.InitializeComponent(); this.Suspending += OnSuspending; using (var db = new GreenContext()) { db.Database.Migrate(); } }
private async void Button_Register_ClickAsync(object sender, RoutedEventArgs e) { var dialog = new MessageDialog(""); dialog.Content = ""; using (var db = new GreenContext()) { var user = db.Usuarios.FirstOrDefault(l => l.UserName == txtBox_Username.Text); if (passwordBox_ConfirmYourPassword.Password != passwordBox_TypeYourPassword.Password) { dialog.Content += "Please verify that both passwords are the same"; } else if (passwordBox_TypeYourPassword.Password == "" || passwordBox_TypeYourPassword.Password.Length < 3) { dialog.Content += "The password is not accepted"; } else if (txtBox_Username.Text == "" || txtBox_Username.Text.Length < 3) { dialog.Content += "The username is not valid"; } else if (user != null) { dialog.Content += "That username is already taken\n"; } else { db.Usuarios.Add(new Model.Usuario { Password = passwordBox_TypeYourPassword.Password, UserName = txtBox_Username.Text }); db.SaveChanges(); } } if (dialog.Content != "") { await dialog.ShowAsync(); } else { this.Frame.Navigate(typeof(MainPage)); } }
public IndividualResults() { this.InitializeComponent(); progressBar_House.Value = UserControl.Emisionhogar; progressBar_Meat.Value = UserControl.EmisionComida; progressBar_Transport.Value = UserControl.EmisionTransporte; using (var db = new GreenContext()) { var bars = db.Usuarios.Where(u => u.Id == MainPage.UserId) .Select(l => new { l.Electricidad, l.KmCarro, l.KmCamion, l.KmVuelos, l.KmTaxi, l.Carne }).FirstOrDefault(); progressBar_House.Value = bars.Electricidad; progressBar_Transport.Value = bars.KmCarro + bars.KmCamion + bars.KmVuelos + bars.KmTaxi; progressBar_Meat.Value = bars.Carne; } if (progressBar_House.Value <= 700) { progressBar_House.Foreground = new SolidColorBrush(Colors.Green); } else if (progressBar_House.Value <= 1000) { progressBar_House.Foreground = new SolidColorBrush(Colors.YellowGreen); } else if (progressBar_House.Value <= 1300) { progressBar_House.Foreground = new SolidColorBrush(Colors.GreenYellow); } else if (progressBar_House.Value <= 1600) { progressBar_House.Foreground = new SolidColorBrush(Colors.OrangeRed); } else if (progressBar_House.Value > 1600) { progressBar_House.Foreground = new SolidColorBrush(Colors.PaleVioletRed); } else { progressBar_House.Foreground = new SolidColorBrush(Colors.DarkRed); } if (progressBar_Transport.Value <= 20) { progressBar_Transport.Foreground = new SolidColorBrush(Colors.Green); } else if (progressBar_Transport.Value <= 45) { progressBar_Transport.Foreground = new SolidColorBrush(Colors.YellowGreen); } else if (progressBar_Transport.Value <= 70) { progressBar_Transport.Foreground = new SolidColorBrush(Colors.GreenYellow); } else if (progressBar_Transport.Value <= 90) { progressBar_Transport.Foreground = new SolidColorBrush(Colors.OrangeRed); } else if (progressBar_Transport.Value > 90) { progressBar_Transport.Foreground = new SolidColorBrush(Colors.PaleVioletRed); } else { progressBar_Transport.Foreground = new SolidColorBrush(Colors.DarkRed); } if (progressBar_Meat.Value <= 3) { progressBar_Meat.Foreground = new SolidColorBrush(Colors.Green); } else if (progressBar_Meat.Value <= 8) { progressBar_Meat.Foreground = new SolidColorBrush(Colors.YellowGreen); } else if (progressBar_Meat.Value <= 12) { progressBar_Meat.Foreground = new SolidColorBrush(Colors.GreenYellow); } else if (progressBar_Meat.Value <= 16) { progressBar_Meat.Foreground = new SolidColorBrush(Colors.OrangeRed); } else if (progressBar_Meat.Value > 16) { progressBar_Meat.Foreground = new SolidColorBrush(Colors.PaleVioletRed); } else { progressBar_Meat.Foreground = new SolidColorBrush(Colors.DarkRed); } splitView_tips.PaneBackground = new ImageBrush { ImageSource = new BitmapImage(new Uri("ms-appx:///Assets/backPanelTips.jpg")), Stretch = Stretch.Fill }; }
public WorldProgress() { this.InitializeComponent(); using (var db = new GreenContext()) { var bars = db.Usuarios.Select(l => new { l.Electricidad, l.KmCarro, l.KmCamion, l.KmVuelos, l.KmTaxi, l.Carne }).ToList(); for (int i = 0; i < bars.Count(); ++i) { progressBar_House.Value += bars[i].Electricidad; progressBar_Transport.Value += bars[i].KmCarro + bars[i].KmCamion + bars[i].KmVuelos + bars[i].KmTaxi; progressBar_Meat.Value += bars[i].Carne; } progressBar_House.Value = progressBar_House.Value / (bars.Count() * 1.0); progressBar_Transport.Value = progressBar_Transport.Value / (bars.Count() * 1.0); progressBar_Meat.Value = progressBar_Meat.Value / (bars.Count() * 1.0); } if (progressBar_House.Value <= 700) { progressBar_House.Foreground = new SolidColorBrush(Colors.Green); } else if (progressBar_House.Value <= 1000) { progressBar_House.Foreground = new SolidColorBrush(Colors.YellowGreen); } else if (progressBar_House.Value <= 1300) { progressBar_House.Foreground = new SolidColorBrush(Colors.GreenYellow); } else if (progressBar_House.Value <= 1600) { progressBar_House.Foreground = new SolidColorBrush(Colors.OrangeRed); } else if (progressBar_House.Value > 1600) { progressBar_House.Foreground = new SolidColorBrush(Colors.PaleVioletRed); } else { progressBar_House.Foreground = new SolidColorBrush(Colors.DarkRed); } if (progressBar_Transport.Value <= 20) { progressBar_Transport.Foreground = new SolidColorBrush(Colors.Green); } else if (progressBar_Transport.Value <= 45) { progressBar_Transport.Foreground = new SolidColorBrush(Colors.YellowGreen); } else if (progressBar_Transport.Value <= 70) { progressBar_Transport.Foreground = new SolidColorBrush(Colors.GreenYellow); } else if (progressBar_Transport.Value <= 90) { progressBar_Transport.Foreground = new SolidColorBrush(Colors.OrangeRed); } else if (progressBar_Transport.Value > 90) { progressBar_Transport.Foreground = new SolidColorBrush(Colors.PaleVioletRed); } else { progressBar_Transport.Foreground = new SolidColorBrush(Colors.DarkRed); } if (progressBar_Meat.Value <= 3) { progressBar_Meat.Foreground = new SolidColorBrush(Colors.Green); } else if (progressBar_Meat.Value <= 8) { progressBar_Meat.Foreground = new SolidColorBrush(Colors.YellowGreen); } else if (progressBar_Meat.Value <= 12) { progressBar_Meat.Foreground = new SolidColorBrush(Colors.GreenYellow); } else if (progressBar_Meat.Value <= 16) { progressBar_Meat.Foreground = new SolidColorBrush(Colors.OrangeRed); } else if (progressBar_Meat.Value > 16) { progressBar_Meat.Foreground = new SolidColorBrush(Colors.PaleVioletRed); } else { progressBar_Meat.Foreground = new SolidColorBrush(Colors.DarkRed); } }