Пример #1
0
        public async Task SaveAsync(StudyForm entity)
        {
            try
            {
                if (entity == null)
                {
                    return;
                }

                using (var timeLineContext = _contextFactory.GetTimeLineContext())
                {
                    var entityModel = await timeLineContext
                                      .StudyForms
                                      .FirstOrDefaultAsync(item => item.Id.Equals(entity.Id));

                    if (entityModel == null)
                    {
                        entityModel = new DA.StudyForm();
                        MapForUpdateentity(entity, entityModel);
                        await timeLineContext.StudyForms.AddAsync(entityModel);
                    }
                    else
                    {
                        MapForUpdateentity(entity, entityModel);
                    }


                    timeLineContext.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
 private void StudyFormEntityForm_Load(object sender, EventArgs e)
 {
     try
     {
         if (StudyFormId == 0)
         {
             this.Text = "Добавление формы обучения";
             MesAccept = "Запись успешно добавлена";
         }
         else
         {
             this.Text = "Редактирование формы обучения";
             using (ApplicationDbContext context = new ApplicationDbContext())
             {
                 studyform = context.StudyForms.Find(StudyFormId);
                 metroTextBoxStudyFormName.Text = studyform.StudyFormName;
             }
             MesAccept = "Запись успешно изменена";
         }
     }
     catch (Exception gg)
     {
         MessageBox.Show(gg.Message, "SWA", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #3
0
 public Student(string name, string group, double averageMark, double familyMemberIncome, Gender gender, StudyForm studyForm)
 {
     Name               = name;
     Group              = group;
     AverageMark        = averageMark;
     FamilyMemberIncome = familyMemberIncome;
     Gender             = gender;
     StudyForm          = studyForm;
 }
        public async Task <ActionResult> DeleteConfirmed(string id)
        {
            StudyForm studyForm = await db.StudyForms.FindAsync(id);

            db.StudyForms.Remove(studyForm);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Пример #5
0
        public Student(string FIO, string Group, double Average_score, int Min_salary)
        {
            Random rnd = new Random();

            this.FIO                 = FIO;
            this.Group               = Group;
            this.Average_score       = Average_score;
            Income_per_family_member = new int[2];
            this.StudyForm           = (StudyForm)rnd.Next(2);
        }
Пример #6
0
 public void WriteXml(XmlWriter writer)
 {
     writer.WriteString(Abbrevation);
     writer.WriteString(Year.ToString());
     writer.WriteString(Semester.ToString());
     writer.WriteString(NumberOfStudents.ToString());
     writer.WriteString(StudyForm.ToString());
     writer.WriteString(StudyType.ToString());
     writer.WriteString(Language.ToString());
 }
Пример #7
0
 public Group(string abbrevation, int year, Semester semester, int numberOfStudents, StudyForm studyForm, StudyType studyType, Language language)
 {
     Abbrevation      = abbrevation;
     Year             = year;
     Semester         = semester;
     NumberOfStudents = numberOfStudents;
     StudyForm        = studyForm;
     StudyType        = studyType;
     Language         = language;
 }
        public async Task <ActionResult> Edit([Bind(Include = "Form")] StudyForm studyForm)
        {
            if (ModelState.IsValid)
            {
                db.Entry(studyForm).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(studyForm));
        }
        public async Task <ActionResult> Create([Bind(Include = "Form")] StudyForm studyForm)
        {
            if (ModelState.IsValid)
            {
                db.StudyForms.Add(studyForm);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(studyForm));
        }
Пример #10
0
        protected override void Seed(SWA.ApplicationDbContext context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data.


            var dt1 = new DocumentType {
                DocumentTypeName = "Входящий"
            };
            var dt2 = new DocumentType {
                DocumentTypeName = "Исходящий"
            };
            var dt3 = new DocumentType {
                DocumentTypeName = "Внутренний"
            };

            context.DocumentTypes.Add(dt1);
            context.DocumentTypes.Add(dt2);
            context.DocumentTypes.Add(dt3);


            var sf = new StudyForm {
                StudyFormName = "Дневная"
            };

            var s = new Specialty {
                SpecialtyId = "Default", SpecialtyName = "Default"
            };

            var g1 = new Group {
                GroupName = "Абитурьенты"
            };
            var g2 = new Group {
                GroupName = "Отчисленные"
            };

            context.Groups.Add(g1);
            context.Groups.Add(g2);

            s.Groups.Add(g1);
            s.Groups.Add(g2);

            context.Specialties.Add(s);

            sf.Specialties.Add(s);

            context.StudyForms.Add(sf);

            context.SaveChanges();
        }
Пример #11
0
 public async Task <IActionResult> Put([FromBody] StudyForm value)
 {
     try
     {
         var entity = _mapper.Map <BL.StudyForm>(value);
         var id     = _service.SaveAsync(entity);
         return(Ok(id));
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }
        // GET: StudyForms/Edit/5
        public async Task <ActionResult> Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StudyForm studyForm = await db.StudyForms.FindAsync(id);

            if (studyForm == null)
            {
                return(HttpNotFound());
            }
            return(View(studyForm));
        }
Пример #13
0
 /**
  * <summary> Constructor from known parameters. </summary>
  * <param name="id"> Group's ID in the DB. </param>
  * <param name="abbreviation"> Abbreaviation of the program the students are in. </param>
  * <param name="name"> Name of the program the students are in. </param>
  * <param name="year"> Year/grade to which students belong to. </param>
  * <param name="semester"> Semester in which the students are. </param>
  * <param name="form"> Form of study the students attend. </param>
  * <param name="type"> Type of study the students are in. </param>
  * <param name="language"> Language of study in which the student use. </param>
  * <param name="studentCount"> Number of student's in a study group. </param>
  */
 public StudentGroup(UInt32 id, string abbreviation, string name, StudyYear year,
                     StudySemester semester, StudyForm form, StudyType type, StudyLanguage language,
                     UInt16 studentCount)
 {
     this.Id           = id;
     this.Abbreviation = abbreviation;
     this.Name         = name;
     this.Year         = year;
     this.Semester     = semester;
     this.Form         = form;
     this.Type         = type;
     this.Language     = language;
     this.StudentCount = studentCount;
     this.Subjects     = new Dictionary <UInt32, Subject>();
 }
Пример #14
0
        private void UpdateCollections(object sender, SelectionChangedEventArgs e)
        {
            var institutes = SqlServer.SqlServer.ExecuteStoredProcedure(_connectionString, _userCredential,
                                                                        "GetInstitutes", "Institutes").Tables["Institutes"].Rows;

            Institutes = Institute.GetCollection(institutes);

            InstitutesComboBox.ItemsSource = Institutes.Select(i => i.InstituteSName).ToList();

            var qualificationLevels = SqlServer.SqlServer.ExecuteStoredProcedure(_connectionString, _userCredential,
                                                                                 "GetQualificationLevels", "QualificationLevels").Tables["QualificationLevels"].Rows;

            QualificationLevels = QualificationLevel.GetCollection(qualificationLevels);

            var studyForms = SqlServer.SqlServer.ExecuteStoredProcedure(_connectionString, _userCredential,
                                                                        "GetStudyForms", "StudyForms").Tables["StudyForms"].Rows;

            StudyForms = StudyForm.GetCollection(studyForms);

            var academicRanks = SqlServer.SqlServer.ExecuteStoredProcedure(_connectionString, _userCredential,
                                                                           "GetAcademicRanks", "AcademicRanks").Tables["AcademicRanks"].Rows;

            AcademicRanks = AcademicRank.GetCollection(academicRanks);
        }
Пример #15
0
 private void MapForUpdateentity(StudyForm entity, DA.StudyForm daEntity)
 {
     daEntity.Id = entity.Id;
 }
Пример #16
0
        static void Main(string[] args)
        {
            //1 HomeWork
            Employee[] employees = new Employee[SetEmployeesCount()];

            for (int i = 0; i < employees.Length; i++)
            {
                Console.WriteLine($"Заполнение данных о {i+Constants.LENTH_TO_INDEX} работнике");
                string    name         = SetEmploeeName();
                int       receptiYear  = SetRecepitDateYear();
                Month     receptiMonth = SetRecepitDateMonth();
                int       receptiDay   = SetRecepitDateDay(receptiMonth, receptiYear);
                Vacancies vacancies    = SetEmploeeVacanci();
                int       salary       = SetEmploeeSalary();
                employees[i] = new Employee(name, vacancies, salary, receptiYear, receptiMonth, receptiDay);
            }
            Console.WriteLine();
            Console.WriteLine("----------------------------------------");

            //a
            for (int i = 0; i < employees.Length; i++)
            {
                Console.WriteLine($"Информация про {i+Constants.LENTH_TO_INDEX} сотрудника");
                Console.WriteLine(employees[i].GetFullInormation());
            }
            Console.WriteLine();
            Console.WriteLine("----------------------------------------");

            //b
            int clercCout     = Constants.NULL;
            int allClerSalary = Constants.NULL;

            for (int i = 0; i < employees.Length; i++)
            {
                if (employees[i].Vacancy == Vacancies.Clerk)
                {
                    ++clercCout;
                    allClerSalary += employees[i].Salary;
                }
            }

            if (clercCout != Constants.NULL)
            {
                double averageClercSalary = allClerSalary / clercCout;

                for (int i = 0; i < employees.Length; i++)
                {
                    if (employees[i].Vacancy == Vacancies.Manager && employees[i].Salary >= averageClercSalary)
                    {
                        Console.WriteLine(employees[i].GetFullInormation());
                    }
                }
                Console.WriteLine();
                Console.WriteLine("----------------------------------------");
            }

            bool flag = true;

            while (flag)
            {
                flag = false;
                for (int i = 0; i < employees.Length - Constants.LENTH_TO_INDEX; ++i)
                {
                    if (employees[i].Name.CompareTo(employees[i + Constants.LENTH_TO_INDEX].Name) > 0)
                    {
                        string    name         = employees[i].Name;
                        Vacancies vacancies    = employees[i].Vacancy;
                        int       salary       = employees[i].Salary;
                        int       recepitYear  = employees[i].RecepitDate[Constants.DATE_YEAR];
                        int       recepitMonth = employees[i].RecepitDate[Constants.DATE_MONTH];
                        int       recepitDay   = employees[i].RecepitDate[Constants.DATE_DAY];

                        employees[i].Name    = employees[i + Constants.LENTH_TO_INDEX].Name;
                        employees[i].Vacancy = employees[i + Constants.LENTH_TO_INDEX].Vacancy;
                        employees[i].Salary  = employees[i + Constants.LENTH_TO_INDEX].Salary;
                        employees[i].RecepitDate[Constants.DATE_YEAR]  = employees[i + Constants.LENTH_TO_INDEX].RecepitDate[Constants.DATE_YEAR];
                        employees[i].RecepitDate[Constants.DATE_MONTH] = employees[i + Constants.LENTH_TO_INDEX].RecepitDate[Constants.DATE_MONTH];
                        employees[i].RecepitDate[Constants.DATE_DAY]   = employees[i + Constants.LENTH_TO_INDEX].RecepitDate[Constants.DATE_DAY];

                        employees[i + Constants.LENTH_TO_INDEX].Name    = name;
                        employees[i + Constants.LENTH_TO_INDEX].Vacancy = vacancies;
                        employees[i + Constants.LENTH_TO_INDEX].Salary  = salary;
                        employees[i + Constants.LENTH_TO_INDEX].RecepitDate[Constants.DATE_YEAR]  = recepitYear;
                        employees[i + Constants.LENTH_TO_INDEX].RecepitDate[Constants.DATE_MONTH] = recepitMonth;
                        employees[i + Constants.LENTH_TO_INDEX].RecepitDate[Constants.DATE_DAY]   = recepitDay;
                        flag = true;
                    }
                }
            }

            for (int i = 0; i < employees.Length; i++)
            {
                if (employees[i].Vacancy == Vacancies.Manager)
                {
                    Console.WriteLine(employees[i].GetFullInormation());
                }
            }
            Console.WriteLine();
            Console.WriteLine("----------------------------------------");

            //c
            int bossRecepitYear  = Constants.NULL;
            int bossRecepitMonth = Constants.NULL;
            int bossRecepitDay   = Constants.NULL;

            for (int i = 0; i < employees.Length; i++)
            {
                if (employees[i].Vacancy == Vacancies.Boss)
                {
                    bossRecepitDay   = employees[i].RecepitDate[Constants.DATE_DAY];
                    bossRecepitMonth = employees[i].RecepitDate[Constants.DATE_MONTH];
                    bossRecepitYear  = employees[i].RecepitDate[Constants.DATE_YEAR];
                    break;
                }
            }

            for (int i = 0; i < employees.Length; i++)
            {
                if (employees[i].Vacancy == Vacancies.Manager)
                {
                    if (employees[i].RecepitDate[Constants.DATE_YEAR] > bossRecepitYear)
                    {
                        Console.WriteLine(employees[i].GetFullInormation());
                    }
                    else if (employees[i].RecepitDate[Constants.DATE_YEAR] == bossRecepitYear)
                    {
                        if (employees[i].RecepitDate[Constants.DATE_MONTH] > bossRecepitMonth)
                        {
                            Console.WriteLine(employees[i].GetFullInormation());
                        }
                        else if (employees[i].RecepitDate[Constants.DATE_MONTH] == bossRecepitMonth)
                        {
                            if (employees[i].RecepitDate[Constants.DATE_DAY] > bossRecepitDay)
                            {
                                Console.WriteLine(employees[i].GetFullInormation());
                            }
                        }
                    }
                }
            }
            Console.WriteLine("----------------------------------------");
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();

            //2 HomeWork
            Student[] students = new Student[SetStudentCount()];

            for (int i = 0; i < students.Length; i++)
            {
                string    name               = SetStudentName();
                string    group              = SetStudentGroup();
                double    averageMark        = SetStudentAverageMark();
                double    familyMemberIncome = SetStudentFamilyMemberIncome();
                Gender    gender             = SetStudentGender();
                StudyForm studyForm          = SetStudentStudyForm();

                students[i] = new Student(name, group, averageMark, familyMemberIncome, gender, studyForm);
            }

            bool flag_ = true;

            while (flag_)
            {
                flag_ = false;
                for (int i = 0; i < students.Length - Constants.LENTH_TO_INDEX; ++i)
                {
                    if (students[i].FamilyMemberIncome.CompareTo(students[i + Constants.LENTH_TO_INDEX].FamilyMemberIncome) < 0)
                    {
                        string    name  = students[i].Name;
                        string    group = students[i].Group;
                        double    familyMemberIncome = students[i].FamilyMemberIncome;
                        double    averageMark        = students[i].AverageMark;
                        Gender    gender             = students[i].Gender;
                        StudyForm studyForm          = students[i].StudyForm;

                        students[i].Name  = students[i + Constants.LENTH_TO_INDEX].Name;
                        students[i].Group = students[i + Constants.LENTH_TO_INDEX].Group;
                        students[i].FamilyMemberIncome = students[i + Constants.LENTH_TO_INDEX].FamilyMemberIncome;
                        students[i].AverageMark        = students[i + Constants.LENTH_TO_INDEX].AverageMark;
                        students[i].Gender             = students[i + Constants.LENTH_TO_INDEX].Gender;
                        students[i].StudyForm          = students[i + Constants.LENTH_TO_INDEX].StudyForm;

                        students[i + Constants.LENTH_TO_INDEX].Name  = name;
                        students[i + Constants.LENTH_TO_INDEX].Group = group;
                        students[i + Constants.LENTH_TO_INDEX].FamilyMemberIncome = familyMemberIncome;
                        students[i + Constants.LENTH_TO_INDEX].AverageMark        = averageMark;
                        students[i + Constants.LENTH_TO_INDEX].Gender             = gender;
                        students[i + Constants.LENTH_TO_INDEX].StudyForm          = studyForm;
                        flag_ = true;
                    }
                }
            }

            for (int i = 0; i < students.Length; ++i)
            {
                if (students[i].FamilyMemberIncome <= Constants.MINIMAl_SALARY * Constants.DOUBLE)
                {
                    Console.WriteLine(students[i].GetFullInfomation());
                }
            }

            for (int i = 0; i < students.Length; ++i)
            {
                if (students[i].FamilyMemberIncome > Constants.MINIMAl_SALARY * Constants.DOUBLE)
                {
                    Console.WriteLine(students[i].GetFullInfomation());
                }
            }
        }