forked from AlexisVB/IDE-AR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
administradorCuentas.xaml.cs
101 lines (96 loc) · 3.23 KB
/
administradorCuentas.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using IDE_AR.Datos;
namespace IDE_AR
{
/// <summary>
/// Interaction logic for administradorCuentas.xaml
/// </summary>
public partial class administradorCuentas : Window
{
List<usuario> listUsers=new List<usuario>();
usuario currentUsuario = new usuario();
public administradorCuentas()
{
InitializeComponent();
lstUsuario.DataContext = currentUsuario;
lstUsuario.ItemsSource = listUsers;
BuscarDatos();
}
private void BuscarDatos()
{
Usuarios users = InterfaceHttp.GetUsuarios();
listUsers = users.usuarios;
lstUsuario.ItemsSource = null;
lstUsuario.Items.Clear();
lstUsuario.ItemsSource = listUsers;
}
private void btnAgregarUsuario_Click(object sender, RoutedEventArgs e)
{
this.Opacity = 0.5;
AgergarUsuario nuevoUsuario = new AgergarUsuario();
nuevoUsuario.Owner = this;
//mostar la ventana
if (nuevoUsuario.ShowDialog() == true)
{
//actualizar lista usuarios
listUsers.Add(nuevoUsuario.nuevoUsuario);
lstUsuario.ItemsSource = null;
lstUsuario.Items.Clear();
lstUsuario.ItemsSource = listUsers;
}
this.Opacity = 1;
}
private void ModificarUsuario_Click(object sender, RoutedEventArgs e)
{
this.Opacity = 0.5;
ModificarUsuario modificarUsuario = new ModificarUsuario(currentUsuario);
modificarUsuario.Owner = this;
//mostar la ventana
if (modificarUsuario.ShowDialog() == true)
{
//refrescar lista materias
lstUsuario.Items.Refresh();
}
this.Opacity = 1;
}
private void EliminarUsuario_Click(object sender, RoutedEventArgs e)
{
this.Opacity = 0.5;
VentanaEliminar deleteWindow = new VentanaEliminar(delete.Usuario, currentUsuario);
if (deleteWindow.ShowDialog() == true)
{
BuscarDatos();
}
this.Opacity = 1;
}
public void list1_SelectionChanged(Object sender, SelectionChangedEventArgs e)
{
if(lstUsuario.SelectedIndex>=0)
currentUsuario = listUsers[lstUsuario.SelectedIndex];
}
private void btnCerrar_Click(Object sender, RoutedEventArgs e)
{
this.Close();
}
private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
this.DragMove();
}
private void btnReduce_Click(Object sender, RoutedEventArgs e)
{
WindowState = System.Windows.WindowState.Minimized;
}
}
}