//добавление/редактирование планируемой занятости ОТСУСТВУЕТ ЗАПИСЬ В БД ЯЗЫКА ТЕЛЕФОНА И ЭЛ ЯЩИКА!!!!!!!
        public void AddPlanZan(PlanZan obj)
        {
            if (ugtu_db.PlanZanyat_Student.Join(ugtu_db.PlanZanyat, PZS => PZS.idPlanZanyat, PZ => PZ.IDPlanZanyat,(PZS, PZ) => new { PZS, PZ })
                .Where(student => student.PZS.idStud == obj.idStud && student.PZ.IDTypeZan == PlanTypeZan).Count() == 0) //add
            {
                PlanZanyat_Student res = new PlanZanyat_Student()
            {
                DataObzvona = obj.Data,
                idPlanZanyat = obj.idPlanZan,
                idStud = obj.idStud
            };
                ugtu_db.PlanZanyat_Student.InsertOnSubmit(res);

            }
            else  //edit
            {
                var f = (from PZS in ugtu_db.PlanZanyat_Student
                         where PZS.idStud == obj.idStud
                         select PZS).First();
                f.DataObzvona = obj.Data;
                f.idPlanZanyat = obj.idPlanZan;
                f.idStud = obj.idStud;
            }

            ugtu_db.SubmitChanges();
            if (obj.RabProffs != null)
            {
                for (int i = 0; i < obj.RabProffs.Count(); i++)
                {
                    if (ugtu_db.RabProfStudenta.Where(m => m.idStud == obj.idStud && m.idRabProf == obj.RabProffs[i]).Select(m => m.idRabProfstudenta).Count() == 0)
                    {
                        RabProfStudenta RP = new RabProfStudenta()
                        {
                            idRabProf = obj.RabProffs[i],
                            idStud = obj.idStud,
                            Razryad = obj.Razryads[i]
                        };
                        ugtu_db.RabProfStudenta.InsertOnSubmit(RP);
                        ugtu_db.SubmitChanges();
                    }
                    else
                    {
                        var rp = ugtu_db.RabProfStudenta.Where(m => m.idStud == obj.idStud && m.idRabProf == obj.RabProffs[i]).ToList();
                        foreach (var rabProff in rp)
                        {
                            rabProff.idRabProf = obj.RabProffs[i];
                            rabProff.idStud = obj.idStud;
                            rabProff.Razryad = obj.Razryads[i];
                        }
                        ugtu_db.SubmitChanges();
                    }
                }

                var RPs = ugtu_db.RabProfStudenta.Where(m => m.idStud == obj.idStud).ToList();
                foreach (var rabProffInBD in RPs)
                {
                    if (!obj.RabProffs.ToList().Exists(m => m == rabProffInBD.idRabProf))
                    {
                        ugtu_db.RabProfStudenta.DeleteOnSubmit(rabProffInBD);
                        ugtu_db.SubmitChanges();
                    }
                }
            }
            else {
                var RPs = ugtu_db.RabProfStudenta.Where(m => m.idStud == obj.idStud).ToList();
                foreach (var rabProffInBD in RPs)
                {
                        ugtu_db.RabProfStudenta.DeleteOnSubmit(rabProffInBD);
                        ugtu_db.SubmitChanges();
                }
            }
            if (obj.masLang != null)
            {
                foreach (var lang in obj.masLang)
                {
                    if (ugtu_db.Lang_stud.Where(m => m.nCode == obj.idStud && m.Ik_lang == lang).Select(m => m.Step_vlad).Count() == 0)
                    {
                        Lang_stud LS = new Lang_stud()
                        {
                            Ik_lang = lang,
                            Ik_step_vlad = 0,// не указано
                            nCode = obj.idStud
                        };
                        ugtu_db.Lang_stud.InsertOnSubmit(LS);
                        ugtu_db.SubmitChanges();
                    }
                }
                var LPs = ugtu_db.Lang_stud.Where(m => m.nCode == obj.idStud).ToList();
                foreach (var LPsInBD in LPs)
                {
                    if (!obj.masLang.ToList().Exists(m => m == LPsInBD.Ik_lang))
                    {
                        ugtu_db.Lang_stud.DeleteOnSubmit(LPsInBD);
                        ugtu_db.SubmitChanges();
                    }
                }
            }
            else {
                var LPs = ugtu_db.Lang_stud.Where(m => m.nCode == obj.idStud).ToList();
                foreach (var LPsInBD in LPs)
                {
                    ugtu_db.Lang_stud.DeleteOnSubmit(LPsInBD);
                    ugtu_db.SubmitChanges();
                }
            }

            if (obj.Email != null) {
                var PersonEmail = ugtu_db.Person.Where(m => m.nCode == obj.idStud).ToList();
                foreach (var person in PersonEmail) {
                    person.cEmail = obj.Email;
                    ugtu_db.SubmitChanges();
                }
            }
            if (obj.Tel != null)
            {
                var PersonTel = ugtu_db.Person.Where(m => m.nCode == obj.idStud).ToList();
                foreach (var person in PersonTel)
                {
                    person.cSotTel = obj.Tel;
                   ugtu_db.SubmitChanges();
                }
            }
        }
 public void EditViborTrud(PlanZan obj)
 {
     var res = ugtu_db.PlanZanyat_Student.Where(m => m.idPlanZanyat_Student == obj.idPlanZanStud);
     foreach (var c in res)
     {
         c.DataObzvona = obj.Data;
         c.idPlanZanyat = obj.idPlanZan;
         c.idStud = obj.idStud;
         c.idTrudoustr = obj.idTrud;
     };
     ugtu_db.SubmitChanges();
 }
 public void AddViborTrud(PlanZan obj)
 {
     PlanZanyat_Student res = new PlanZanyat_Student()
     {
         DataObzvona = obj.Data,
         idPlanZanyat = obj.idPlanZan,
         idStud = obj.idStud,
         idTrudoustr = obj.idTrud
     };
     ugtu_db.PlanZanyat_Student.InsertOnSubmit(res);
     var person = ugtu_db.Person.Where(m => m.nCode == obj.idStud).First();
     person.cEmail = obj.Email;
     person.cSotTel = obj.Tel;
     ugtu_db.SubmitChanges();
 }
 public void EditFactZanOnlySave(PlanZan obj)
 {
     var PZcount = ugtu_db.PlanZanyat_Student.Where(m => m.DataObzvona == obj.Data && m.idStud == obj.idStud && m.idPlanZanyat_Student != obj.idPlanZanStud).Count();
     if (PZcount == 0)
     {
         var PZS = ugtu_db.PlanZanyat_Student.Where(m => m.idPlanZanyat_Student == obj.idPlanZanStud).FirstOrDefault();
         PZS.idPlanZanyat = obj.idPlanZan;
         PZS.idPlanZanyat_Student = obj.idPlanZanStud;
         PZS.idStud = obj.idStud;
         PZS.DataObzvona = obj.Data;
         PZS.idTrudoustr = null;
         var person = ugtu_db.Person.Where(m => m.nCode == obj.idStud).First();
         person.cEmail = obj.Email;
         person.cSotTel = obj.Tel;
         ugtu_db.SubmitChanges();
     }
     else
     {
         throw new Exception("");
     }
 }
 public void AddFactZanOnlySave(PlanZan obj)
 {
     var PZcount = ugtu_db.PlanZanyat_Student.Where(m => m.DataObzvona == obj.Data && m.idStud == obj.idStud).Count();
     if (PZcount == 0)
     {
     PlanZanyat_Student res = new PlanZanyat_Student()
     {
         DataObzvona = obj.Data,
         idPlanZanyat = obj.idPlanZan,
         idStud = obj.idStud
     };
     ugtu_db.PlanZanyat_Student.InsertOnSubmit(res);
     var person = ugtu_db.Person.Where(m => m.nCode == obj.idStud).First();
     person.cEmail = obj.Email;
     person.cSotTel = obj.Tel;
     ugtu_db.SubmitChanges();
     }
     else
     {
         throw new Exception("");
     }
 }