示例#1
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            MarathonSkillsEntities entitites = new MarathonSkillsEntities();

            //List<CharityItem> charities = entitites.Charity.Select(x => new CharityItem()
            //{
            //	HeaderText = x.CharityName,
            //	DescriptionText = x.CharityDescription,
            //	ImageSource = String.Format("/Images/{0}", x.CharityLogo)
            //}).ToList();


            List <CharityItem> charities = entitites.Charity
                                           .Select(x => new { x.CharityLogo, x.CharityName, x.CharityDescription })
                                           .AsEnumerable()
                                           .Select(x => new CharityItem()
            {
                HeaderText      = x.CharityName,
                DescriptionText = x.CharityDescription,
                ImageSource     = String.Format("/Images/{0}", x.CharityLogo)
            }).ToList();

            //List<CharityItem> charities = new List<CharityItem>();
            //charities.Add(new CharityItem() { ImageSource = "/Images/arise-logo.png", HeaderText = "SampleHeaderText1", DescriptionText = "Descriptionaaaaaaaaaaaa1" });
            //charities.Add(new CharityItem() { ImageSource = "/Images/aves-do-brazil-logo.png", HeaderText = "SampleHeaderText2", DescriptionText = "Descriptionaaaaaaaaaaaa2" });
            //charities.Add(new CharityItem() { ImageSource = "/Images/upbeat-logo.png", HeaderText = "SampleHeaderText3", DescriptionText = "Descriptionaaaaaaaaaaa3" });

            CharityList.ItemsSource = charities;
        }
示例#2
0
        public SponsorRunnerPage()
        {
            InitializeComponent();
            var entities = new MarathonSkillsEntities();



            var RunnerQuery = from r in entities.Runner
                              from c in entities.Country
                              from u in entities.User
                              where r.CountryCode == c.CountryCode && r.Email == u.Email
                              orderby r.RunnerId
                              select new { Name = u.FirstName, LastName = u.LastName, Id = r.RunnerId, Country = c.CountryName }
            ;

            var RunnerList = RunnerQuery.ToList();

            //var RunnerNameList = entities.Runner.Select(x => x.Country.CountryName).ToList();
            //RunnerList = entities.Runner.Where(x => entities.User.Where(y => y.Email.Equals(x.Email))).Country.CountryName;
            List <string> ComboBoxItems = RunnerList.Select(r => r.Name.ToString() + " " + r.LastName.ToString() + "-" + r.Id.ToString() + "(" + r.Country.ToString() + ")").ToList();


            RunnerComboBox.ItemsSource   = ComboBoxItems;
            RunnerComboBox.SelectedIndex = 0;
        }
示例#3
0
        private void RunnerComboBox_Selected(object sender, RoutedEventArgs e)
        {
            var entities = new MarathonSkillsEntities();

            var CharityQueue = from r in entities.Runner
                               from reg in entities.Registration
                               from c in entities.Charity
                               where r.RunnerId == reg.RunnerId && reg.CharityId == c.CharityId && r.RunnerId == RunnerComboBox.SelectedIndex + 100
                               select c.CharityName;

            var s = RunnerComboBox.SelectedItem.ToString();



            CharityNameLabel.Content = CharityQueue.First().ToString();
        }
        public RegisterRunnerPage()
        {
            InitializeComponent();


            MarathonSkillsEntities entities = new MarathonSkillsEntities();


            var CountryList = entities.Country
                              .Select(x => x.CountryName)
                              .Distinct()
                              .ToList();

            CountryPickerComboBox.ItemsSource = CountryList;

            var GenderList = entities.Gender
                             .Select(x => x.Gender1)
                             .Distinct()
                             .ToList();

            GenderPickerComboBox.ItemsSource = GenderList;
        }
        public CharityInformationWindow(string CharityName)
        {
            InitializeComponent();
            var entities = new MarathonSkillsEntities();


            CharityNameHeader.Text = CharityName;

            var ImageQuery = from i in entities.Charity
                             where i.CharityName == CharityName
                             select i.CharityLogo;

            string imageString = ImageQuery.First();

            CharityImage.Source = new BitmapImage(new Uri(String.Format("/Images/{0}", imageString), UriKind.Relative));

            var DescriptionQuery = from c in entities.Charity
                                   where c.CharityName == CharityName
                                   select c.CharityDescription;

            CharityDescription.Text = DescriptionQuery.First();
        }
        private void RegisterButton_Click(object sender, RoutedEventArgs e)
        {
            Regex EmailRegex = new Regex(@"^(\w+)@{1}(\w+)\.(\w+)");

            //Email
            if (EmailTextBox.Text.IsEmpty())
            {
                MessageBox.Show("Email не введен");
                return;
            }

            if (!EmailRegex.IsMatch(EmailTextBox.Text))
            {
                MessageBox.Show("Неверный формат Email");
                return;
            }

            //Password
            if (PasswordTextBox.Text.IsEmpty())
            {
                MessageBox.Show("Пароль не введен");
                return;
            }

            if (PasswordTextBox.Text.Length >= 6)
            {
                char[] RequiredCharacters = { '!', '@', '#', '$', '%', '^' };
                if (!(PasswordTextBox.Text.Any(char.IsDigit) && PasswordTextBox.Text.Any(char.IsUpper) && RequiredCharacters.Any(PasswordTextBox.Text.Contains)))
                {
                    MessageBox.Show("Пароль должен содержать одну цифру, одну прописную букву и один из этих символов : ! @ # $ % ^");
                    return;
                }
            }
            else
            {
                MessageBox.Show("Пароль должен быть длиннее 6 символов");
                return;
            }


            //Repeat Password
            if (RepeatPasswordTextBox.Text != PasswordTextBox.Text)
            {
                MessageBox.Show("Пароли не совпадают");
                return;
            }


            if (DateTime.Now - BirthDatePicker.SelectedDate < TimeSpan.FromDays(365 * 10) || BirthDatePicker.SelectedDate > DateTime.Now)
            {
                MessageBox.Show("Некорректная дата рождения");
                return;
            }

            MarathonSkillsEntities entities = new MarathonSkillsEntities();

            if (entities.User.Where(i => i.Email == EmailTextBox.Text).Count() != 0)
            {
                MessageBox.Show("Пользователь с таким именем уже существует");
                return;
            }


            if (ImageByteArray.Count() > 0)
            {
                entities.User.Add(new User
                {
                    Email     = EmailTextBox.Text,
                    Password  = PasswordTextBox.Text,
                    FirstName = FirstNameTextBox.Text,
                    LastName  = LastNameTextBox.Text,
                    RoleId    = "R"
                });

                entities.Runner.Add(new Runner
                {
                    Email       = EmailTextBox.Text,
                    Gender      = GenderPickerComboBox.Text,
                    DateOfBirth = BirthDatePicker.SelectedDate,
                    CountryCode = entities.Country.Where(i => i.CountryName == CountryPickerComboBox.Text).FirstOrDefault().CountryCode
                });

                int RunnerID = entities.Runner.Max(r => r.RunnerId);

                entities.RunnerImages.Add(new RunnerImages
                {
                    ImageBytes = ImageByteArray,
                    runnerId   = RunnerID
                });


                entities.SaveChanges();

                NavigationService.Navigate(new LoginPage());
                NavigationService.RemoveBackEntry();
            }
            else
            {
                MessageBox.Show("Изображение не выбрано");
                return;
            }
        }
示例#7
0
        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            //TestingLoginWindow window = new TestingLoginWindow();
            //window.Show();
            //Window.GetWindow(this).Close();

            if (EmailTextBox.Text == String.Empty || PasswordTextBox.Password == String.Empty)
            {
                MessageBox.Show("Все данные должны быть введены");
                return;
            }

            var entities = new MarathonSkillsEntities();

            var User = entities.User.Where(i => i.Email == EmailTextBox.Text && i.Password == PasswordTextBox.Password).FirstOrDefault();

            if (User == null)
            {
                MessageBox.Show("Пользователя с такими данными не существует");
                return;
            }
            else
            {
                MainWindow mainWindow;


                switch (User.RoleId)
                {
                case "R":
                    mainWindow          = new MainWindow(new RunnerPage());
                    mainWindow.UserData = new Data.UserData
                    {
                        Email    = User.Email,
                        RunnerId = entities.Runner.Where(i => i.Email == User.Email).First().RunnerId
                    };
                    break;

                case "C":
                    mainWindow          = new MainWindow(new CoordinatorPage());
                    mainWindow.UserData = new Data.UserData
                    {
                        Email = User.Email
                    };
                    break;

                case "A":
                    mainWindow          = new MainWindow(new AdministratorPage());
                    mainWindow.UserData = new Data.UserData
                    {
                        Email = User.Email
                    };
                    break;

                default:
                    mainWindow = null;
                    break;
                }


                if (mainWindow == null)
                {
                    MessageBox.Show("Пользователя с такой ролью не существует");
                    return;
                }



                mainWindow.UserNameTextBox.Text    = User.FirstName + " " + User.LastName;
                mainWindow.LoginExitButton.Content = "Выход";

                mainWindow.Show();
                Window.GetWindow(this).Close();
            }
        }