示例#1
0
        private void Apply_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(idUser);

            var query = data.Users.SingleOrDefault(u => u.ID.Equals(id));

            if (query.RoleID.Equals(1))
            {
                query.RoleID = 2;
                data.SaveChanges();
            }
            else
            {
                query.RoleID = 1;
                data.SaveChanges();
            }

            Administrator ad = new Administrator();

            ad.Show();
            this.Close();
        }
示例#2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            User user = new User();

            user.FirstName = txtFirstname.Text;
            user.LastName  = txtLastname.Text;
            user.Email     = txtEmail.Text;
            user.Birthdate = dateTimePicker1.Value;
            user.Password  = txtPassword.Text;
            user.OfficeID  = Convert.ToInt32(cbOffice.SelectedValue.ToString());
            user.RoleID    = 2;
            db.Users.Add(user);
            db.SaveChanges();

            MessageBox.Show("Saved", "Notification");


            Administrator ad = new Administrator();

            ad.Show();
            this.Dispose();
        }