Exemplo n.º 1
0
        private void SearchOnLastName()
        {
            DBCContext db = new DBCContext();

            if (comboBoxGroupNameSearch.SelectedIndex >= 0)
            {
                var student = (from st in db.UserStudents
                               where st.LastName.Contains(textBoxLastNameSearch.Text) && st.IDGroup == comboBoxGroupNameSearch.SelectedIndex + 1
                               join gr in db.Groups on st.IDGroup equals gr.IDGroup
                               select new
                {
                    ID = st.IDUser,
                    FirstName = st.FirstName,
                    LastName = st.LastName,
                    GroupID = gr.GroupName
                }).ToList();
                ObservableCollection <Object> oc = new ObservableCollection <object>(student);
                datagridStudentList.ItemsSource = oc;
            }
            else
            {
                var student = (from st in db.UserStudents
                               where st.LastName.Contains(textBoxLastNameSearch.Text)
                               join gr in db.Groups on st.IDGroup equals gr.IDGroup
                               select new
                {
                    ID = st.IDUser,
                    FirstName = st.FirstName,
                    LastName = st.LastName,
                    GroupID = gr.GroupName
                }).ToList();
                ObservableCollection <Object> oc = new ObservableCollection <object>(student);
                datagridStudentList.ItemsSource = oc;
            }
        }
Exemplo n.º 2
0
        private void bindComboGroup()
        {
            DBCContext db   = new DBCContext();
            var        item = db.Groups.ToList();

            groups      = item;
            DataContext = groups;
        }
Exemplo n.º 3
0
        private void SearchOnGroupName()
        {
            DBCContext db      = new DBCContext();
            var        student = (from gr in db.Groups
                                  where gr.IDGroup == comboBoxGroupNameSearch.SelectedIndex + 1
                                  select gr).ToList();
            ObservableCollection <Object> oc = new ObservableCollection <object>(student);

            datagridGroupList.ItemsSource = oc;
        }
Exemplo n.º 4
0
        private void SetDataGrid()
        {
            comboBoxGroupNameSearch.SelectedIndex = -1;
            DBCContext db = new DBCContext();

            db.Groups.Load();
            var group = (from gr in db.Groups select gr).ToList();
            ObservableCollection <Object> oc = new ObservableCollection <object>(group);

            datagridGroupList.ItemsSource = oc;
        }
Exemplo n.º 5
0
        private bool addProfile()
        {
            DBCContext db = new DBCContext();

            if ((textBoxFName.Text == "") || (textBoxLName.Text == "") || (passwordBoxPassword.Password == "") || (passwordBoxPasswordrepeat.Password == "") || (textBoxLogin.Text == ""))
            {
                MessageBox.Show("Необходимо заполнить все поля!");
                return(false);
            }
            else
            {
                if ((passwordBoxPassword.Password == passwordBoxPasswordrepeat.Password) && (passwordBoxPassword.Password != "") && (passwordBoxPasswordrepeat.Password != ""))
                {
                    var authoriz = from p in db.Users
                                   where p.Login == textBoxLogin.Text
                                   select p;
                    if (authoriz.Count() > 0)
                    {
                        MessageBox.Show("Введеный Логин уже занять.");
                        return(false);
                    }
                    else
                    {
                        try
                        {
                            User u1 = new User {
                                Login = textBoxLogin.Text, Password = passwordBoxPassword.Password, IDRole = 2
                            };
                            db.Users.Add(u1);
                            UserStudent uS1 = new UserStudent {
                                IDUser = u1.IDUser, FirstName = textBoxFName.Text, LastName = textBoxLName.Text, IDGroup = comboBoxGroup.SelectedIndex + 1
                            };

                            db.UserStudents.Add(uS1);
                            db.SaveChanges();
                            MessageBox.Show("Регистрация прошла успешно!");
                            return(true);
                        }
                        catch
                        {
                            MessageBox.Show("Возникло исключение!");
                            return(false);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Введеные пароли не совпадают! Пожалуйста, убедитесь в правильности ввода паролей.");
                    return(false);
                }
            }
        }
Exemplo n.º 6
0
        private void SetDataGrid()
        {
            comboBoxGroupNameSearch.SelectedIndex = -1;
            textBoxFirstNameSearch.Text           = "";
            textBoxLastNameSearch.Text            = "";
            DBCContext db = new DBCContext();

            db.UserStudents.Load();
            var student = (from st in db.UserStudents
                           join gr in db.Groups on st.IDGroup equals gr.IDGroup
                           select new
            {
                ID = st.IDUser,
                FirstName = st.FirstName,
                LastName = st.LastName,
                GroupID = gr.GroupName
            }).ToList();
            ObservableCollection <Object> oc = new ObservableCollection <object>(student);

            datagridStudentList.ItemsSource = oc;
        }