예제 #1
0
        public void DeleteUser(int ID)
        {
            UsersBD user = (from u in _context.UsersBD where u.ID_User == ID select u).SingleOrDefault();

            try
            {
                _context.UsersBD.Remove(user);
                _context.SaveChanges();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Warning");
                Logging(ex.Message, ex.StackTrace);
            }
        }
예제 #2
0
        public List <UsersBD> GetUsersTableEF()
        {
            List <UsersBD> User = new List <UsersBD>();

            foreach (var el in _context.UsersBD)
            {
                UsersBD u = new UsersBD();
                u.ID_User       = el.ID_User;
                u.First_Name    = el.First_Name;
                u.Second_Name   = el.Second_Name;
                u.Login         = el.Login;
                u.Password      = el.Password;
                u.Administrator = el.Administrator;
                User.Add(u);
            }
            return(User.ToList());
        }
예제 #3
0
        public void AddUser(string First_Name, string Second_Name, string Login, string Password, bool Administrator)
        {
            var     _context = new db_MinligareevMAContext();
            UsersBD user     = new UsersBD();

            user.First_Name    = First_Name;
            user.Second_Name   = Second_Name;
            user.Login         = Login;
            user.Password      = Password;
            user.Administrator = Administrator;
            try
            {
                _context.UsersBD.Add(user);
                _context.SaveChanges();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Warning");
                Logging(ex.Message, ex.StackTrace);
            }
        }
예제 #4
0
        public List <UsersBD> GetUsersEF(string Login, string Password)
        {
            bool           find = false;
            List <UsersBD> User = new List <UsersBD>();

            foreach (var el in _context.UsersBD)
            {
                if (el.Login == Login && el.Password == Password)
                {
                    UsersBD u = new UsersBD();
                    find            = true;
                    u.First_Name    = el.First_Name;
                    u.Second_Name   = el.Second_Name;
                    u.Administrator = el.Administrator;
                    User.Add(u);
                }
            }
            if (find == false)
            {
                MessageBox.Show("User is not found");
            }
            return(User.ToList());
        }