示例#1
0
        private void StudentUpdBtn_Click(object sender, RoutedEventArgs e)
        {
            int num = (GridStudents.SelectedItem as Student).StudentId;

            var queryUpdate  = db.Student.Where(u => u.StudentId == num).FirstOrDefault();
            var queryUpdate1 = db.Diploma.Where(u => u.Student.StudentId == num).FirstOrDefault();


            Student          student          = new Student();
            PersonalDocument personalDocument = new PersonalDocument();
            Person           person           = new Person();
            Diploma          diploma          = new Diploma();

            queryUpdate.Person.PersonalDocument.NumberPersonalDocument = NumberPersonalDocumentTB.Text;
            queryUpdate.Person.PersonalDocument.NumberInventory        = NumberInventoryTB.Text;
            queryUpdate.Person.PersonalDocument.ShelfLife = Convert.ToInt16(ShelfLifeTB.Text);

            queryUpdate.Person.Lastname    = LastNameTB.Text;
            queryUpdate.Person.Firstname   = FirstTB.Text;
            queryUpdate.Person.Middlename  = MiddleNameTB.Text;
            queryUpdate.Person.DateofBirth = Convert.ToDateTime(DateofBirthDP.SelectedDate);

            queryUpdate.NumberGroup = Convert.ToInt32(GroupCB.SelectedValue);

            queryUpdate1.Series             = Convert.ToInt32(SeriesTB.Text);
            queryUpdate1.Number             = Convert.ToInt32(NumberTB.Text);
            queryUpdate1.RegistrationNumber = Convert.ToInt32(RegistrationNumberTB.Text);
            queryUpdate1.IdQualification    = Convert.ToInt32(QualificationCB.SelectedValue);
            queryUpdate1.IdSpecialty        = Convert.ToInt32(SpecialtyCB.SelectedValue);
            queryUpdate1.ApplicationSeries  = Convert.ToInt32(ApplicationSeriesTB.Text);
            queryUpdate1.ApplicationNumber  = Convert.ToInt32(ApplicationNumberTB.Text);
            queryUpdate1.ApplicationDate    = Convert.ToDateTime(ApplicationDateDP.SelectedDate);
            queryUpdate1.EnrollmentNumber   = Convert.ToInt32(EnrollmentNumberTB.Text);
            queryUpdate1.EnrollmentDate     = Convert.ToDateTime(EnrollmentDateDP.SelectedDate);
            queryUpdate1.ReleaseNumber      = Convert.ToInt32(ReleaseNumberTB.Text);
            queryUpdate1.ReleaseDate        = Convert.ToDateTime(ReleaseDate.SelectedDate);

            db.SaveChanges();
            GridStudents.ItemsSource = db.Student.ToList();
        }
示例#2
0
        private void Button_ClickAddData(object sender, RoutedEventArgs e)
        {
            Person           person           = new Person();
            PersonalDocument personalDocument = new PersonalDocument();
            OrderList        orderList        = new OrderList();

            try
            {
                if (personalDocument != null)
                {
                    // Приказ
                    //personalDocument.DateOrder = DpDateOrder.SelectedDate;
                    //personalDocument.NumberOrder = TbNumberOrder.Text;
                    //personalDocument.TitleOrder = TbNumberOrder.Text;
                    ///



                    personalDocument.NumberPersonalDocument = NumberPersonalDocumentTB.Text;
                    personalDocument.NumberInventory        = NumberInventoryTB.Text;
                    personalDocument.ShelfLife = Convert.ToInt16(ShelfLifeTB.Text);

                    db.PersonalDocument.Add(personalDocument);
                    //db.OrderList.Add(orderList);
                    db.SaveChanges();
                }



                if (person != null)
                {
                    person.Lastname           = LastNameTB.Text;
                    person.Firstname          = FirstTB.Text;
                    person.Middlename         = MiddleNameTB.Text;
                    person.DateofBirth        = Convert.ToDateTime(DateofBirthDP.SelectedDate);
                    person.IdPersonalDocument = personalDocument.PersonalDocumentId;
                    person.Аddress            = TbAdress.Text;
                    person.NumberPhone        = TbNumberPhone.Text;

                    //person.IdOrderList = orderList.IdOrderList;



                    db.Person.Add(person);
                    db.SaveChanges();

                    orderList.IdPerson    = person.PersonId;
                    orderList.DateOrder   = DpDateOrder.SelectedDate;
                    orderList.NumberOrder = TbNumberOrder.Text;
                    orderList.TitleOrder  = TbTitleOrder.Text;

                    db.OrderList.Add(orderList);
                    db.SaveChanges();
                    GetOrderPerson = person.PersonId;
                }

                MessageBox.Show("Добавлен!");
            }
            catch (Exception)
            {
                MessageBox.Show("Поля не заполнены или введены некорректные данные!");
            }



            // Добавление студента выпускника
            if (check1.IsChecked == true)
            {
                GroupCB.ItemsSource = db.GroupStudentNumber.ToList();
                Student            student            = new Student();
                GroupStudentNumber groupStudentNumber = new GroupStudentNumber();
                Diploma            diploma            = new Diploma();
                GroupStudentNumber groupStudent       = new GroupStudentNumber();

                if (student != null)
                {
                    student.IdPerson        = person.PersonId;
                    student.NumberGroup     = Convert.ToInt32(GroupCB.SelectedValue);
                    student.GradebookNumber = TbGradebookNumber.Text;


                    db.Student.Add(student);
                    db.SaveChanges();
                }

                if (diploma != null)
                {
                    diploma.IdStudent          = student.StudentId;
                    diploma.Series             = Convert.ToInt32(SeriesTB.Text);
                    diploma.Number             = Convert.ToInt32(NumberTB.Text);
                    diploma.RegistrationNumber = Convert.ToInt32(RegistrationNumberTB.Text);
                    diploma.IdQualification    = Convert.ToInt32(QualificationCB.SelectedValue);
                    diploma.IdSpecialty        = Convert.ToInt32(SpecialtyCB.SelectedValue);
                    diploma.ApplicationSeries  = Convert.ToInt32(ApplicationSeriesTB.Text);
                    diploma.ApplicationNumber  = Convert.ToInt32(ApplicationNumberTB.Text);
                    //diploma.EnrollmentNumber = Convert.ToInt32(EnrollmentNumberTB.Text);
                    //diploma.EnrollmentDate = Convert.ToDateTime(EnrollmentDateDP.SelectedDate);
                    //diploma.ReleaseNumber = Convert.ToInt32(ReleaseNumberTB.Text);
                    //diploma.ReleaseDate = Convert.ToDateTime(ReleaseDate.SelectedDate);
                    diploma.NameEducational = TbNameEducational.Text;

                    db.Diploma.Add(diploma);
                    db.SaveChanges();
                }
            }
            // Добавление отчисленного
            if (check2.IsChecked == true)
            {
                try
                {
                    Student student = new Student()
                    {
                        IdPerson = person.PersonId,
                        //EnrollmentNumber = Convert.ToInt32(EnrollmentNumberTb.Text),
                        //EnrollmentDate = Convert.ToDateTime(EnrollmentDateDp.SelectedDate),
                        //DeductionNumber = Convert.ToInt32(DeductionNumberTb.Text),
                        //DeductionDate = Convert.ToDateTime(DeductionDateDp.SelectedDate),
                        //Reasonfordeduction = ReasonfordeductionTb.Text,
                        NumberGroup = Convert.ToInt32(GroupCb.SelectedValue)
                    };

                    db.Student.Add(student);
                    db.SaveChanges();
                }
                catch
                {
                    MessageBox.Show("Поля не заполнены или введены некорректные данные!");
                }
            }
            // Добавление сотрудники
            if (check3.IsChecked == true)
            {
                Employee employee = new Employee()
                {
                    IdPerson = person.PersonId,
                    //NumberReception = Convert.ToInt32(NumberReceptionTB.Text),
                    //DateReception = Convert.ToDateTime(DateReceptionDP.SelectedDate),
                    Position = PositionTB.Text,
                    //NumberFired = Convert.ToInt32(NumberFiredTB.Text),
                    //DateFired = Convert.ToDateTime(DateFiredDP.SelectedDate),
                    //СauseFired = СauseFired.Text,
                    PersonalNumber = TbPersonalNumber.Text
                };

                db.Employee.Add(employee);
                db.SaveChanges();
            }
        }
示例#3
0
        private void StudentAddBtn_Click(object sender, RoutedEventArgs e)
        {
            Person           person           = new Person();
            PersonalDocument personalDocument = new PersonalDocument();

            if (personalDocument != null)
            {
                personalDocument.NumberPersonalDocument = NumberPersonalDocumentTB.Text;
                personalDocument.NumberInventory        = NumberInventoryTB.Text;
                personalDocument.ShelfLife = Convert.ToInt16(ShelfLifeTB.Text);

                db.PersonalDocument.Add(personalDocument);
                db.SaveChanges();
            }

            if (person != null)
            {
                person.Lastname           = LastNameTB.Text;
                person.Firstname          = FirstTB.Text;
                person.Middlename         = MiddleNameTB.Text;
                person.DateofBirth        = Convert.ToDateTime(DateofBirthDP.SelectedDate);
                person.IdPersonalDocument = personalDocument.PersonalDocumentId;

                db.Person.Add(person);
                db.SaveChanges();
            }

            GroupCB.ItemsSource = db.GroupStudentNumber.ToList();
            Student            student            = new Student();
            GroupStudentNumber groupStudentNumber = new GroupStudentNumber();
            Diploma            diploma            = new Diploma();
            GroupStudentNumber groupStudent       = new GroupStudentNumber();

            if (student != null)
            {
                student.IdPerson    = person.PersonId;
                student.NumberGroup = Convert.ToInt32(GroupCB.SelectedValue);

                db.Student.Add(student);
                db.SaveChanges();
            }

            if (diploma != null)
            {
                diploma.IdStudent          = student.StudentId;
                diploma.Series             = Convert.ToInt32(SeriesTB.Text);
                diploma.Number             = Convert.ToInt32(NumberTB.Text);
                diploma.RegistrationNumber = Convert.ToInt32(RegistrationNumberTB.Text);
                diploma.IdQualification    = Convert.ToInt32(QualificationCB.SelectedValue);
                diploma.IdSpecialty        = Convert.ToInt32(SpecialtyCB.SelectedValue);
                diploma.ApplicationSeries  = Convert.ToInt32(ApplicationSeriesTB.Text);
                diploma.ApplicationNumber  = Convert.ToInt32(ApplicationNumberTB.Text);
                diploma.ApplicationDate    = Convert.ToDateTime(ApplicationDateDP.SelectedDate);
                diploma.EnrollmentNumber   = Convert.ToInt32(EnrollmentNumberTB.Text);
                diploma.EnrollmentDate     = Convert.ToDateTime(EnrollmentDateDP.SelectedDate);
                diploma.ReleaseNumber      = Convert.ToInt32(ReleaseNumberTB.Text);
                diploma.ReleaseDate        = Convert.ToDateTime(ReleaseDate.SelectedDate);

                db.Diploma.Add(diploma);
                db.SaveChanges();
            }
            MessageBox.Show("Выпускник добавлен");
            GridStudents.ItemsSource = db.Student.ToList();
        }