Exemple #1
0
        public string Create([Bind(Exclude = "Id")] LTP Model)
        {
            ApplicationDbContext db = new ApplicationDbContext();
            string msg;

            try
            {
                if (ModelState.IsValid)
                {
                    db.LTPs.Add(Model);

                    db.SaveChanges();
                    msg = "Сохранено успешно";
                }
                else
                {
                    msg = "Данные не прошли проверку ввода";
                }
            }
            catch (Exception ex)
            {
                msg = "Произошла ошибка:" + ex.Message;
            }
            return(msg);
        }
Exemple #2
0
 public TipoPersonal(ETP persona)
 {
     InitializeComponent();
     _lTP = new LTP();
     _eTP = new ETP();
     BindingTipoPersonalReload();
     _eTP             = persona;
     _isEnablebinding = true;
 }
Exemple #3
0
 public TipoPersonal()
 {
     InitializeComponent();
     _lTP             = new LTP();
     _eTP             = new ETP();
     _isEnablebinding = true;
     BindingTipoPersonal();
     btnUpdateTP.Enabled = false;
 }
Exemple #4
0
        public string Delete(int Id)
        {
            ApplicationDbContext db = new ApplicationDbContext();
            LTP lTPs = db.LTPs.Find(Id);

            db.LTPs.Remove(lTPs);
            db.SaveChanges();
            return("Удалено успешно");
        }
Exemple #5
0
        public string Edit(LTP Model)
        {
            ApplicationDbContext db = new ApplicationDbContext();
            string msg;

            try
            {
                if (ModelState.IsValid)
                {
                    db.Entry(Model).State = EntityState.Modified;
                    db.SaveChanges();
                    msg = "Сохранено успешно";
                }
                else
                {
                    msg = "Данные не прошли проверку ввода";
                }
            }
            catch (Exception ex)
            {
                msg = "Произошла ошибка:" + ex.Message;
            }
            return(msg);
        }