Пример #1
0
        private void clLogin_Click(object sender, EventArgs e)
        {
            if (textUsername.Text.Trim().Length == 0) return;
            if (textPassword.Text.Trim().Length == 0) return;

            var user = db.Users.Where(o => o.Username == textUsername.Text).FirstOrDefault();
            if (user == null)
            {
                user = new User { Username = textUsername.Text, Password = textPassword.Text };

                db.AddToUsers(user);
                db.SaveChanges();

                _args = new TextEventArgs("Success") { Data = user };
                this.Hide();
            }
            else if (user.Password != textPassword.Text)
            {
                _args = new TextEventArgs("Fail") { Data = null };
                MessageBox.Show(this, @"Username/Password does not match!");

            }
            else
            {
                _args = new TextEventArgs("Success") { Data = user };
                this.Hide();
            }
        }
Пример #2
0
        public MovieListForm(User user, MovieDbEntities context = null)
        {
            _user = user;
            _entities = context ?? new MovieDbEntities();
            InitializeComponent();

            dataListView1.DataSource = _entities.UserLists.Where(o => o.User.Id == _user.Id);
        }
Пример #3
0
        private void clUpdate_Click(object sender, System.EventArgs e)
        {
            User u = (from user in _entities.Users
                      where user.Username == textUsername.Text
                      select user).FirstOrDefault();
            if (u == null)
            {
                u = new User { Username = textUsername.Text, Password = textPassword.Text };
                _entities.AddToUsers(u);

                dataListView1.DataSource = _entities.Users;
            }
            else
            {

                u.Username = textUsername.Text;
                u.Password = textPassword.Text;
            }
            _entities.SaveChanges();

            dataListView1.Enabled = true;
            textUsername.ReadOnly = true;
            textPassword.ReadOnly = true;
        }