Exemplo n.º 1
0
        internal static void AddProfession()
        {
            string newProfessionName = InputDialog.Show("Введите название профессии", "Создание профессии");

            if (!String.IsNullOrWhiteSpace(newProfessionName))
            {
                ITSkillsDataContext dataContext = new ITSkillsDataContext();
                var alreadyInDB = from p in dataContext.Professions
                                  where p.Profession == newProfessionName
                                  select p;
                if (alreadyInDB.Count() == 0)
                {
                    Professions newProfession = new Professions();
                    newProfession.Profession = newProfessionName;
                    dataContext.Professions.InsertOnSubmit(newProfession);
                    dataContext.SubmitChanges();
                }
            }
        }
Exemplo n.º 2
0
        private void AddSkill()
        {
            string newSkillName = InputDialog.Show("Введите название навыка", "Создание навыка");

            if (!String.IsNullOrWhiteSpace(newSkillName))
            {
                ITSkillsDataContext dataContext = new ITSkillsDataContext();
                string profession   = professionsListBox.SelectedItem.ToString();
                int    professionID = dataContext.Professions.SingleOrDefault(p => p.Profession == profession).Id;
                var    alreadyInDB  = from s in dataContext.Skills
                                      where s.Skill == newSkillName
                                      select s;
                if (alreadyInDB.Count() == 0)
                {
                    Skills newSkill = new Skills();
                    newSkill.Skill        = newSkillName;
                    newSkill.ProfessionID = professionID;
                    dataContext.Skills.InsertOnSubmit(newSkill);
                    dataContext.SubmitChanges();
                }
            }
            ShowSkills();
        }