Exemple #1
0
        private void AddHuman(human newhuman)
        {
            int        newdepartmentid;
            department newdep  = _departmens.FirstOrDefault(ndep => ndep.idd == (int)newhuman.departmentid);
            department basedep = _fe.departments.FirstOrDefault(dep => dep.description == newdep.description);

            if (basedep == null)
            {
                newdepartmentid = this.AddDepartment(_departmens.First(dep => dep.idd == newhuman.departmentid));
            }
            else
            {
                newdepartmentid = basedep.idd;
            }

            human createdhuman = human.Createhuman(0, newhuman.secondname);

            createdhuman.additinfo    = newhuman.additinfo;
            createdhuman.birthday     = newhuman.birthday;
            createdhuman.departmentid = newdepartmentid;
            createdhuman.educationid  = newhuman.educationid;
            createdhuman.firstname    = newhuman.firstname;
            createdhuman.genderid     = newhuman.genderid;
            createdhuman.lastname     = newhuman.lastname;


            foreach (testresult tresult in newhuman.testresults)
            {
                testresult createdtresult = testresult.Createtestresult(0, createdhuman.idh, tresult.testdate, tresult.testid, tresult.teststream, tresult.mode);
                createdhuman.testresults.Add(createdtresult);
            }
            _fe.humans.AddObject(createdhuman);
            _fe.SaveChanges();
        }
Exemple #2
0
        private int AddDepartment(department newdepartment)
        {
            department newdep = department.Createdepartment(0, newdepartment.description);

            _fe.departments.AddObject(newdep);
            _fe.SaveChanges();
            return(newdep.idd);
        }
Exemple #3
0
        /// <summary>
        /// Создание нового объекта department.
        /// </summary>
        /// <param name="idd">Исходное значение свойства idd.</param>
        /// <param name="description">Исходное значение свойства description.</param>
        public static department Createdepartment(global::System.Int32 idd, global::System.String description)
        {
            department department = new department();

            department.idd         = idd;
            department.description = description;
            return(department);
        }
Exemple #4
0
        public bool CheckRestorePath(string restorePath)
        {
            bool pathisexists       = false;
            bool humansisexists     = false;
            bool departmentisexists = false;

            if (Directory.Exists(restorePath) == true)
            {
                pathisexists = true;
                _restorePath = new DirectoryInfo(restorePath);
                _humans      = new List <human>();
                _departmens  = new List <department>();
                FileInfo[] files = _restorePath.GetFiles("*.rbk");
                if (files.Length != 0)
                {
                    for (int fileindex = 0; fileindex < files.Length; fileindex++)
                    {
                        human _human = this.Restore <human>(files[fileindex].Name);

                        if (_human != null)
                        {
                            _humans.Add(_human);
                            humansisexists = true;
                        }
                        else
                        {
                            department _department = this.Restore <department>(files[fileindex].Name);
                            if (_department != null)
                            {
                                _departmens.Add(_department);
                                departmentisexists = true;
                            }
                        }
                    }
                }
            }

            return(pathisexists & humansisexists & departmentisexists);
        }
Exemple #5
0
 /// <summary>
 /// Устаревший метод для добавления новых объектов в набор EntitySet departments. Взамен можно использовать метод .Add связанного свойства ObjectSet&lt;T&gt;.
 /// </summary>
 public void AddTodepartments(department department)
 {
     base.AddObject("departments", department);
 }
Exemple #6
0
 /// <summary>
 /// Создание нового объекта department.
 /// </summary>
 /// <param name="idd">Исходное значение свойства idd.</param>
 /// <param name="description">Исходное значение свойства description.</param>
 public static department Createdepartment(global::System.Int32 idd, global::System.String description)
 {
     department department = new department();
     department.idd = idd;
     department.description = description;
     return department;
 }
Exemple #7
0
 /// <summary>
 /// Устаревший метод для добавления новых объектов в набор EntitySet departments. Взамен можно использовать метод .Add связанного свойства ObjectSet&lt;T&gt;.
 /// </summary>
 public void AddTodepartments(department department)
 {
     base.AddObject("departments", department);
 }