Пример #1
0
        //Modify or Delete constructor
        public new_user(MainWindow mainwin, Solutec.Models.users nuser)
        {
            InitializeComponent();
            mainw              = mainwin;
            user               = nuser;
            userTextBox.Text   = user.user;
            password.IsEnabled = false;
            int index = 0;

            switch (nuser.user_type)
            {
            case 1:
                index = 0;
                break;

            case 2:
                index = 1;
                break;

            case 3:
                index = 2;
                break;
            }
            user_typeComboBox.SelectedIndex = index;
            btnSave.Visibility         = Visibility.Hidden;
            btnDelete.Visibility       = Visibility.Visible;
            btnModify.Visibility       = Visibility.Visible;
            notification.Visibility    = Visibility.Hidden;
            change_password.Visibility = Visibility.Visible;
            change_password.IsChecked  = false;
        }
Пример #2
0
        private void ModifyCommandHandler(Object sender, ExecutedRoutedEventArgs e)
        {
            if (userTextBox.Text == "")
            {
                MessageBox.Show("El campo usuario no debe estar vacio");
                return;
            }
            else if (change_password.IsChecked == true)
            {
                if (string.IsNullOrEmpty(password.Password))
                {
                    MessageBox.Show("El campo contraseña no debe estar vacio");
                    return;
                }
            }

            var mUser = new Solutec.Models.users {
                id_user = user.id_user
            };

            using (var context = new Solutec.Models.solutecEntities())

            {
                context.users.Attach(mUser);

                mUser.user = userTextBox.Text;
                if (change_password.IsChecked == true)
                {
                    mUser.password = mainw.GetSHA1(password.Password);
                }
                short user_type = 0;
                switch (user_typeComboBox.Text)
                {
                case "Administrador":
                    user_type = 1;

                    break;

                case "Atencion al cliente":
                    user_type = 2;
                    break;

                case "Tecnico":
                    user_type = 3;
                    break;

                default:
                    user_type = 1;
                    break;
                }
                mUser.user_type = user_type;
                context.Configuration.ValidateOnSaveEnabled = false;

                context.SaveChanges();
            }

            lblNotification.Content = "El usuario ha sido modificado";
            notification.Visibility = Visibility.Visible;
            mainw.Succesful("user");
        }
Пример #3
0
        private void DeleteCommandHandler(Object sender, ExecutedRoutedEventArgs e)
        {
            var dUser = new Solutec.Models.users {
                id_user = user.id_user
            };

            using (var context = new Solutec.Models.solutecEntities())

            {
                context.users.Attach(dUser);

                context.users.Remove(dUser);

                context.SaveChanges();
            }

            lblNotification.Content = "El usuario ha sido eliminado";
            notification.Visibility = Visibility.Visible;
            mainw.Succesful("user");
            userTextBox.IsEnabled       = false;
            password.IsEnabled          = false;
            user_typeComboBox.IsEnabled = false;
            btnDelete.IsEnabled         = false;
            btnModify.IsEnabled         = false;
        }
Пример #4
0
        private void UsersDataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            Solutec.Models.users user = (Solutec.Models.users)usersDataGrid.SelectedItem;

            mainw.userSelected(user);
        }
Пример #5
0
 public void userSelected(Solutec.Models.users user)
 {
     Solutec.Views.new_user newUser = new Solutec.Views.new_user(this, user);
     secondary_frame.NavigationService.Navigate(newUser);
 }