private void Btn_filtrar_Click(object sender, RoutedEventArgs e)
        {
            bool rol = true;

            if (coc.IsSelected || bart.IsSelected || Gar.IsSelected || fina.IsSelected || Admin.IsSelected || caja.IsSelected)
            {
                rol = true;
            }
            else
            {
                rol = false;
            }

            if (txt_rut.Text.Trim() == "")
            {
                lb1.Content = "Debe ingresar un rut para filtrar";
            }
            else
            {
                usuarioBLL ub     = new usuarioBLL();
                bool       existe = ub.GetUserByRut(Int32.Parse(txt_rut.Text));
                if (existe)
                {
                    int rut = Int32.Parse(txt_rut.Text);
                    System.Data.DataTable dt = ub.userList(rut);
                    dtg_Usuarios.ItemsSource = dt.DefaultView;
                }
                else
                {
                    lb1.Content = "Este rut no existe en el sistema";
                }
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            usuarioBLL ub = new usuarioBLL();

            bool nombre    = true;
            bool apellido  = true;
            bool rut       = true;
            bool rol       = true;
            bool fono      = true;
            bool direccion = true;
            bool clave     = true;
            bool estado    = true;

            if (coc.IsSelected || bart.IsSelected || Admin.IsSelected || Gar.IsSelected || fina.IsSelected || caja.IsSelected || bodega.IsSelected)
            {
                rol = true;
            }
            else
            {
                rol         = false;
                lb2.Content = "Ingrese un rol";
            }
            if (txt_Contrasena.Text == "")
            {
                clave       = false;
                lb7.Content = "Ingrese una contraseña";
            }
            if (txt_apellido.Text == "")
            {
                nombre      = false;
                lb4.Content = "Ingrese un apellido";
            }

            if (txt_nombre.Text == "")
            {
                apellido    = false;
                lb3.Content = "Ingrese un nombre";
            }

            if (txt_rut.Text == "")
            {
                rut         = false;
                lb1.Content = "Ingrese un rut";
            }

            if (txt_direccion.Text == "")
            {
                direccion   = false;
                lb6.Content = "Ingrese una dirección";
            }

            if (txt_fono.Text == "")
            {
                fono        = false;
                lb5.Content = "Ingrese un número";
            }


            if (clave == true && nombre == true && rut == true && apellido == true && rol == true && fono == true && direccion == true && estado == true)
            {
                bool existe = ub.GetUserByRut(Int32.Parse(txt_rut.Text));
                if (existe)
                {
                    if (existe == true)
                    {
                        ub.id_usuario = Int32.Parse(txt_rut.Text);
                    }
                    string roll = "";
                    if (coc.IsSelected)
                    {
                        roll = "Cocinero";
                    }
                    else if (bart.IsSelected)
                    {
                        roll = "Bartender";
                    }
                    else if (Gar.IsSelected)
                    {
                        roll = "Garzón";
                    }
                    else if (fina.IsSelected)
                    {
                        roll = "Finanzas";
                    }
                    else if (Admin.IsSelected)
                    {
                        roll = "Administrador";
                    }
                    else if (caja.IsSelected)
                    {
                        roll = "caja";
                    }
                    else if (bodega.IsSelected)
                    {
                        roll = "Bodeguero";
                    }
                    else
                    {
                        lb2.Content = "Debe seleccionar un rol";
                    }

                    ub.rol              = roll;
                    ub.nom_usuario      = txt_nombre.Text;
                    ub.apellido_usuario = txt_apellido.Text;
                    ub.fono             = Int32.Parse(txt_fono.Text);
                    ub.direccion        = txt_direccion.Text;
                    ub.rut              = Int32.Parse(txt_rut.Text);
                    ub.clave            = txt_Contrasena.Text;
                    string[] partesnom = txt_nombre.Text.Split(' ');
                    string[] partesape = txt_apellido.Text.Split(' ');
                    string   primera   = partesnom[0];
                    string   segunda   = partesape[0];

                    string nick      = (primera + "." + segunda).ToString();
                    bool   nickexist = ub.Getnick(nick);
                    string namefinal = "";
                    if (nickexist)
                    {
                        namefinal = nick;
                    }
                    else
                    {
                        namefinal = nick;
                    }

                    string habilitado = "";
                    if (rdb_habilitar.IsChecked == true)
                    {
                        habilitado = "Si";
                    }
                    else
                    {
                        habilitado = lb_estado.Content.ToString();
                    }
                    int    rutt = Int32.Parse(txt_rut.Text);
                    string nom  = namefinal;
                    string pass = txt_Contrasena.Text;
                    ub.AlterInfoUser(ub);
                    ub.AlterUser(rutt, namefinal, roll, pass, habilitado);
                    PopupNotifier popup = new PopupNotifier();
                    popup.TitleText         = "Aviso";
                    popup.Image             = Properties.Resources.add;
                    popup.ContentText       = "El usuario con RUT: " + txt_rut.Text + " Fue modificado de forma exitosa";
                    popup.AnimationDuration = 1000;
                    popup.Delay             = 1500;
                    popup.Popup();
                    txt_rut.Text             = "";
                    txt_nombre.Text          = "";
                    txt_apellido.Text        = "";
                    cbb_rol.SelectedIndex    = -1;
                    txt_fono.Text            = "";
                    txt_direccion.Text       = "";
                    txt_Contrasena.Text      = "";
                    rdb_habilitar.IsEnabled  = false;
                    txt_nombre.IsEnabled     = false;
                    txt_apellido.IsEnabled   = false;
                    cbb_rol.IsEnabled        = false;
                    txt_fono.IsEnabled       = false;
                    txt_direccion.IsEnabled  = false;
                    txt_Contrasena.IsEnabled = false;
                    rdb_habilitar.IsChecked  = false;
                }
                else
                {
                    lb1.Content = "Este rut no está registrado en el sistema";
                }
            }
            else
            {
            }
        }
Ejemplo n.º 3
0
        private void Btn_delete_Click(object sender, RoutedEventArgs e)
        {
            Generic gen = new Generic();

            gen.ACCION.Content    = "eliminar";
            gen.ACCION.Visibility = Visibility.Hidden;
            usuarioBLL us = new usuarioBLL();

            bool rute = true;

            if (txt_rut.Text.Trim() == "")
            {
                rute        = false;
                lb1.Content = "Ingrese un rut o seleccione el que desea desde la lista";
            }

            if (rute == true)
            {
                int  rut    = Int32.Parse(txt_rut.Text);
                bool existe = us.GetUserByRut(rut);
                if (existe)
                {
                    try
                    {
                        DataTable da     = us.userList(rut);
                        DataRow   row    = da.Rows[0];
                        string    rutt   = row[0].ToString();
                        string    Nombre = row[1].ToString() + " " + row[2].ToString();
                        string    rol    = row[4].ToString();
                        gen.lb_titulo.FontSize       = 18;
                        gen.lb_confirmacion.FontSize = 16;
                        gen.lb_contenido.FontSize    = 16;
                        gen.lb_titulo.Content        = "¿Desea deshabilitar a este usuario?";
                        gen.lb_confirmacion.Content  = "Al realizar esta accion, se deshabilitará al usuario:";
                        gen.lb_contenido.Content     = "Rut : " + rut + "\n" +
                                                       "Nombre: " + Nombre + "\n" +
                                                       "Rol: " + rol;
                        gen.Title = "Confirmación";
                        gen.btn_Cancelar.Content  = "Volver";
                        gen.btn_Confirmar.Content = "Eliminar";
                        gen.lb_rut.Content        = txt_rut.Text;
                        gen.Owner = this;
                        gen.ShowDialog();

                        usuarioBLL ub = new usuarioBLL();
                        DataTable  dt = ub.AllUserList();
                        dtg_eliminar.ItemsSource = dt.DefaultView;
                    }

                    catch (Exception ex)
                    {
                        MessageBox.Show("" + ex);
                    }
                }
                else
                {
                    lb1.Content = "El rut no esta ingresado en el sistema";
                }
            }
            else
            {
                lb1.Content = "Ingrese un rut o seleccione el que desea desde la lista";
            }
        }
        private void Btn_suser_Click(object sender, RoutedEventArgs e)
        {
            usuarioBLL us = new usuarioBLL();

            if (txt_rut.Text == "")
            {
                lb1.Content = "Debe ingresar un rut para buscar";
            }
            else if (txt_rut.Text != "")
            {
                bool existe = us.GetUserByRut(Int32.Parse(txt_rut.Text));
                if (existe == true)
                {
                    int       rut = Int32.Parse(txt_rut.Text);
                    DataTable da  = us.userList(rut);
                    DataRow   row = da.Rows[0];
                    txt_nombre.Text   = row[1].ToString();
                    txt_apellido.Text = row[2].ToString();
                    string estado = row[3].ToString();
                    string rol    = row[4].ToString();
                    if (rol == "Cocinero")
                    {
                        coc.IsSelected = true;
                    }
                    else if (rol == "Bartender")
                    {
                        bart.IsSelected = true;
                    }
                    else if (rol == "Garzón")
                    {
                        Gar.IsSelected = true;
                    }
                    else if (rol == "Finanzas")
                    {
                        fina.IsSelected = true;
                    }
                    else if (rol == "Administrador")
                    {
                        Admin.IsSelected = true;
                    }
                    else if (rol == "caja")
                    {
                        caja.IsSelected = true;
                    }
                    else if (rol == "Bodeguero")
                    {
                        bodega.IsSelected = true;
                    }
                    else
                    {
                    }
                    txt_fono.Text       = row[5].ToString();
                    txt_direccion.Text  = row[6].ToString();
                    txt_Contrasena.Text = row[8].ToString();
                    if (estado == "No")
                    {
                        rdb_habilitar.IsEnabled = true;
                    }
                    else
                    {
                        lb_estado.Content = estado;
                    }

                    txt_nombre.IsEnabled     = true;
                    txt_apellido.IsEnabled   = true;
                    cbb_rol.IsEnabled        = true;
                    txt_fono.IsEnabled       = true;
                    txt_direccion.IsEnabled  = true;
                    txt_Contrasena.IsEnabled = true;
                }
                else
                {
                    lb1.Content = "Este rut no está registrado en el sistema";
                }
            }
        }
Ejemplo n.º 5
0
        private void Btn_adduser_Click(object sender, RoutedEventArgs e)
        {
            usuarioBLL ub = new usuarioBLL();
            Generic    g  = new Generic();

            verificar();

            bool nombre     = true;
            bool apellido   = true;
            bool rut        = true;
            bool rol        = true;
            bool fono       = true;
            bool direccion  = true;
            bool contrasena = true;

            if (coc.IsSelected || bart.IsSelected || Admin.IsSelected || Gar.IsSelected || fina.IsSelected || caja.IsSelected || bodega.IsSelected)
            {
                rol = true;
            }
            else
            {
                rol         = false;
                lb2.Content = "Ingrese un rol";
            }

            if (txt_apellido.Text.Trim() == "")
            {
                nombre      = false;
                lb4.Content = "Ingrese un apellido";
            }

            if (txt_pass.Text == "")
            {
                contrasena  = false;
                lb7.Content = "Ingrese una contraseña";
            }

            if (txt_nombre.Text.Trim() == "")
            {
                apellido    = false;
                lb3.Content = "Ingrese un nombre";
            }

            if (txt_rut.Text.Trim() == "")
            {
                rut         = false;
                lb1.Content = "Ingrese un rut";
            }

            if (txt_direccion.Text.Trim() == "")
            {
                direccion   = false;
                lb6.Content = "Ingrese una dirección";
            }

            if (txt_fono.Text.Trim() == "")
            {
                fono        = false;
                lb5.Content = "Ingrese un número";
            }



            if (nombre == true && rut == true && apellido == true && rol == true && fono == true && direccion == true && contrasena == true)
            {
                ub.id_usuario = Int32.Parse(txt_rut.Text);
                string roll = "";
                if (coc.IsSelected)
                {
                    roll = "Cocinero";
                }
                else if (bart.IsSelected)
                {
                    roll = "Bartender";
                }
                else if (Gar.IsSelected)
                {
                    roll = "Garzon";
                }
                else if (fina.IsSelected)
                {
                    roll = "Finanzas";
                }
                else if (Admin.IsSelected)
                {
                    roll = "Administrador";
                }
                else if (caja.IsSelected)
                {
                    roll = "Caja";
                }
                else if (bodega.IsSelected)
                {
                    roll = "Bodeguero";
                }
                else
                {
                    lb2.Content = "Ingrese un rol";
                }
                ub.rol = roll;

                string[] partesnom = txt_nombre.Text.Split(' ');
                string[] partesape = txt_apellido.Text.Split(' ');
                string   primera   = partesnom[0];
                string   segunda   = partesape[0];

                string nick      = (primera + "." + segunda).ToString();
                bool   nickexist = ub.Getnick(nick);
                string namefinal = "";
                if (nickexist)
                {
                    string primera1 = partesnom[1];
                    string name     = primera + primera1 + segunda;
                    namefinal = name;
                }
                else
                {
                    namefinal = nick;
                }
                ub.nom_usuario      = txt_nombre.Text;
                ub.apellido_usuario = txt_apellido.Text;
                ub.fono             = Int32.Parse(txt_fono.Text);
                ub.direccion        = txt_direccion.Text;
                ub.rut = Int32.Parse(txt_rut.Text);
                string nomb = txt_nombre.Text + " " + txt_apellido.Text;
                string ru   = txt_rut.Text;
                string ro   = roll;
                ub.clave = txt_pass.Text;
                bool existe = ub.GetUserByRut(Int32.Parse(txt_rut.Text));
                if (existe)
                {
                    PopupNotifier popup = new PopupNotifier();
                    popup.TitleText         = "Aviso";
                    popup.Image             = Properties.Resources.add;
                    popup.ContentText       = "El usuario con RUT: " + ru + " Ya existe en sistema";
                    popup.AnimationDuration = 500;
                    popup.Delay             = 3500;
                    popup.Popup();
                }
                else
                {
                    ub.AddUser(Int32.Parse(txt_rut.Text), namefinal, txt_pass.Text, roll, "Si");
                    ub.AddinfoUser(ub);
                    PopupNotifier popup = new PopupNotifier();
                    popup.TitleText   = "Aviso";
                    popup.Image       = Properties.Resources.add;
                    popup.ContentText = "Se ha Creado el usuario: " + nomb + "\n" +
                                        "RUT: " + ru + "\n" +
                                        "ROL: " + roll;
                    popup.AnimationDuration = 800;
                    popup.Delay             = 1000;
                    popup.Popup();
                    txt_rut.Clear();
                    txt_nombre.Clear();
                    txt_apellido.Clear();
                    cbb_rol.SelectedIndex = -1;
                    txt_fono.Clear();
                    txt_direccion.Clear();
                    txt_pass.Clear();
                }
            }
        }