예제 #1
0
        public string AddDolznostSave(Dolgnost dol)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    Dolznost dolznost = new Dolznost()
                                            {
                                                NameDolznost = dol.dolgnost
                                            };
                    ugtu_db.Dolznost.InsertOnSubmit(dolznost);
                    ugtu_db.SubmitChanges();
                    return ugtu_db.Dolznost.Where(m => m.NameDolznost == dol.dolgnost).Select(m => m.IDDolznost).First().ToString();
                }
                catch (Exception)
                {
                    return ("Данная должность уже существует");
                }

            }
            else
            {
                return ("Ошибка. Длина поля больше 100 символов");
            }
        }
예제 #2
0
 //добавление
 public int AddDolgnostSave(string name)
 {
     using (var ugtu_db = new UGTU_DBDataContext())
     {
         Dolznost Dol = new Dolznost()
         {
             NameDolznost = name
         };
         ugtu_db.Dolznost.InsertOnSubmit(Dol);
         ugtu_db.SubmitChanges();
         return Dol.IDDolznost;
     }
 }
예제 #3
0
 partial void DeleteDolznost(Dolznost instance);
예제 #4
0
 partial void UpdateDolznost(Dolznost instance);
예제 #5
0
 partial void InsertDolznost(Dolznost instance);
예제 #6
0
        public int? AddDolgnost(string name)
        {
            using (var ugtu_db = new UGTU_DBDataContext())
            {
                if (name == null) return null;
                int? idDol = ugtu_db.Dolznost.Where(m => m.NameDolznost.ToLower() == name.ToLower()).Select(m => m.IDDolznost).SingleOrDefault();
                if (idDol == 0)
                {
                    Dolznost D = new Dolznost()
                    {
                        NameDolznost = name
                    };
                    ugtu_db.Dolznost.InsertOnSubmit(D);
                    ugtu_db.SubmitChanges();
                    idDol = D.IDDolznost;
                }

                return idDol;
            }
        }