Пример #1
0
        private async void Tile_Click(object sender, RoutedEventArgs e)
        {
            ClienteEmpresa nuevoCliente = new ClienteEmpresa()
            {
                IdGiro    = (decimal)cbGiro.SelectedValue,
                IdComuna  = (decimal)cbComuna.SelectedValue,
                Correo    = txtCorreo.Text,
                Direccion = txtDireccion.Text,
                Nombre    = txtNombre.Text,
                Rut       = txtRut.Text,
                Telefono  = txtTelefono.Text
            };
            string xml = nuevoCliente.Serializar();


            PrevencionRiesgosWCF.PrevencionClient proxy = new PrevencionRiesgosWCF.PrevencionClient();
            bool valido = proxy.CreateClienteEmpresa(xml);

            proxy.Close();


            if (valido)
            {
                await this.ShowMessageAsync("Exito", "Cliente registrado correctamente.");

                LimpiarControles();
            }
            else
            {
                await this.ShowMessageAsync("Error", "No se creo el cliente, revise los datos.");
            }
        }
Пример #2
0
        private void CargarControles()
        {
            PrevencionRiesgosWCF.PrevencionClient proxy = new PrevencionRiesgosWCF.PrevencionClient();
            Regiones = RegionCollection.Deserializar(proxy.ReadRegionCiudadComunaCollection()).ToDictionary(x => x.IdRegion, x => x);
            var giros = GiroCollection.Deserializar(proxy.ReadGiroCollection());

            proxy.Close();

            cbRegion.DisplayMemberPath = "Nombre";
            cbRegion.SelectedValuePath = "IdRegion";

            cbCiudad.DisplayMemberPath = "Nombre";
            cbCiudad.SelectedValuePath = "IdCiudad";

            cbComuna.DisplayMemberPath = "Nombre";
            cbComuna.SelectedValuePath = "IdComuna";

            CargarComboRegion(Regiones.First().Key);


            cbGiro.DisplayMemberPath = "Nombre";
            cbGiro.SelectedValuePath = "IdGiro";
            cbGiro.ItemsSource       = giros;
            cbGiro.SelectedValue     = giros.First().IdGiro;
            cbGiro.Items.Refresh();
        }
Пример #3
0
        private void CargarDgCat()
        {
            int IdTipo = (int)cbTipBusc.SelectedValue;

            PrevencionRiesgosWCF.PrevencionClient proxy = new PrevencionRiesgosWCF.PrevencionClient();

            List <Usuario> lu = UsuarioCollection.Deserializar(proxy.ReadUsuariosCollection());

            lu = lu.Where(u => u.IdTipo == IdTipo).ToList();
            List <TipoUsuario>    ltu = TipoUsuarioCollection.Deserializar(proxy.ReadTipoUsuario());
            List <ClienteEmpresa> lce = ClienteEmpresaCollection.Deserializar(proxy.ReadClienteEmpresa());

            proxy.Close();

            foreach (var item in lu)
            {
                item.Tipo_Usuario = ltu.First(tu => tu.IdTipo == item.IdTipo).Nombre;

                try
                {
                    item.Empresa = lce.First(ce => ce.Rut == item.RutEmpresa).Nombre;
                }
                catch (Exception)
                {
                    item.Empresa = string.Empty;
                }
            }
            List <IDGUsuario> ld = new UsuarioCollection().ListaDesplegable(lu).OrderBy(usu => usu.Rut).ToList();



            dgUsuarios.ItemsSource = ld;
            dgUsuarios.Items.Refresh();
        }
Пример #4
0
        private async void btnBaja_Click(object sender, RoutedEventArgs e)
        {
            Usuario u = (Usuario)dgUsuarios.SelectedItem;

            u.DarBaja = true;

            string xml = u.Serializar();

            PrevencionRiesgosWCF.PrevencionClient proxy = new PrevencionRiesgosWCF.PrevencionClient();

            bool valido = proxy.ModificarUsuario(xml);

            proxy.Close();



            if (valido)
            {
                await this.ShowMessageAsync("Exito", "Usuario dado de baja Correctamente.");
            }
            else
            {
                await this.ShowMessageAsync("Error", "No Se Pudo dar de baja El Usuario.");
            }
            CargarModificar(u);
        }
Пример #5
0
        private async void button1_Click(object sender, RoutedEventArgs e)
        {
            Usuario u = (Usuario)dgUsuarios.SelectedItem;

            u.Nombres   = txtMNombres.Text;
            u.ApellidoP = txtMApellidoP.Text;
            u.Correo    = txtMCorreo.Text;
            u.Direccion = txtMDireccion.Text;
            u.ApellidoM = txtMApellidoM.Text;
            u.Telefono  = txtMTelefono.Text;
            u.IdTipo    = (int)cbMTipoUsuario.SelectedValue;

            string xml = u.Serializar();

            PrevencionRiesgosWCF.PrevencionClient proxy = new PrevencionRiesgosWCF.PrevencionClient();

            bool valido = proxy.ModificarUsuario(xml);

            proxy.Close();



            if (valido)
            {
                await this.ShowMessageAsync("Exito", "Usuario Modificado Correctamente.");
            }
            else
            {
                await this.ShowMessageAsync("Error", "No Se Pudo Modificado El Usuario.");
            }
            CargarModificar(u);
        }
Пример #6
0
        private void CargarControles()
        {
            PrevencionRiesgosWCF.PrevencionClient proxy = new PrevencionRiesgosWCF.PrevencionClient();

            List <TipoUsuario>    lu  = TipoUsuarioCollection.Deserializar(proxy.ReadTipoUsuario());
            List <ClienteEmpresa> lce = ClienteEmpresaCollection.Deserializar(proxy.ReadClienteEmpresa());

            proxy.Close();


            cbTipAgr.DisplayMemberPath = "Nombre";
            cbTipAgr.SelectedValuePath = "IdTipo";
            cbTipAgr.ItemsSource       = lu.Where(t => t.IdTipo == 1 || t.IdTipo == 2 || t.IdTipo == 3);
            cbTipAgr.SelectedValue     = "2";
            cbTipAgr.Items.Refresh();
            cbEmp.DisplayMemberPath = "Nombre";
            cbEmp.SelectedValuePath = "Rut";
            cbEmp.ItemsSource       = lce;
            cbEmp.SelectedValue     = "12456378-9";
            cbTipAgr.Items.Refresh();
            cbTipBusc.DisplayMemberPath = "Nombre";
            cbTipBusc.SelectedValuePath = "IdTipo";
            cbTipBusc.ItemsSource       = lu.Where(t => t.IdTipo == 1 || t.IdTipo == 2 || t.IdTipo == 3);;
            cbTipBusc.SelectedValue     = "1";
            cbTipBusc.Items.Refresh();
        }
Пример #7
0
        private async void Tile_Click(object sender, RoutedEventArgs e)
        {
            Usuario u = new Usuario();

            u.Rut  = txtUser.Text;
            u.Pass = boxPassword.Password;
            string xml1 = u.Serializar();

            PrevencionRiesgosWCF.PrevencionClient proxy = new PrevencionRiesgosWCF.PrevencionClient();

            bool valido = proxy.ValidarUsuario(xml1);


            proxy.Close();


            if (valido)
            {
                proxy = new PrevencionRiesgosWCF.PrevencionClient();
                string xml = proxy.ReadUsuario(u.Serializar());
                proxy.Close();
                u           = Usuario.Deserializar(xml);
                u.ULogueado = u;

                if (u.IdTipo == 1 || u.IdTipo == 2)
                {
                    await this.ShowMessageAsync("Alerta", "Usuario no permitido");
                }
                else
                {
                    if (u.DarBaja == true)
                    {
                        await this.ShowMessageAsync("Alerta", "Usuario dado de baja");

                        return;
                    }

                    await this.ShowMessageAsync("Exito", "Tus datos son correctos");

                    menu men = new menu();
                    this.Close();
                    men.ShowDialog();

                    //MainWindow mw = new MainWindow();
                    //mw.Show();
                    //this.Close();
                }
            }
            else
            {
                await this.ShowMessageAsync("Error", "Usuario no registrado");

                //lblInfo.Content = "Usuario no registrado";
            }
        }
Пример #8
0
        private void btnModificar_Click(object sender, RoutedEventArgs e)
        {
            PrevencionRiesgosWCF.PrevencionClient proxy = new PrevencionRiesgosWCF.PrevencionClient();
            List <TipoUsuario> lu = TipoUsuarioCollection.Deserializar(proxy.ReadTipoUsuario());

            proxy.Close();

            cbMTipoUsuario.DisplayMemberPath = "Nombre";
            cbMTipoUsuario.SelectedValuePath = "IdTipo";
            cbMTipoUsuario.ItemsSource       = lu.Where(t => t.IdTipo == 1 || t.IdTipo == 2 || t.IdTipo == 3);
            cbMTipoUsuario.Items.Refresh();
            Usuario    u  = (Usuario)dgUsuarios.SelectedItem;
            IDGUsuario uv = (IDGUsuario)u;

            flModificar.IsOpen = true;
            flModificar.Header = string.Format("{0} {1}", uv.Nombres, uv.Apellidos);
            CargarModificar(u);
        }
Пример #9
0
        private async void Tile_Click(object sender, RoutedEventArgs e)
        {
            //se recuperan valores

            string Rut        = string.Empty;
            int    IdTipo     = 0;
            string Pass       = string.Empty;
            string Nombres    = string.Empty;;
            string ApellidoP  = string.Empty;
            string ApellidoM  = string.Empty;
            string Correo     = string.Empty;
            string Telefono   = string.Empty;
            string Direccion  = string.Empty;
            bool   Moroso     = false;
            bool   DarBaja    = false;
            string RutEmpresa = string.Empty;

            Rut        = txtRut.Text;
            IdTipo     = (int)cbTipAgr.SelectedValue;
            Pass       = txtPass.Text;
            Nombres    = txtNombre.Text;
            ApellidoP  = txtAplPat.Text;
            ApellidoM  = txtAplMat.Text;
            Correo     = txtCorreo.Text;
            Telefono   = txtTelefono.Text;
            Direccion  = txtDireccion.Text;
            Moroso     = false;
            DarBaja    = false;
            RutEmpresa = string.Format("{0}", cbEmp.SelectedValue);
            int  x;
            bool numerico = int.TryParse(Telefono, out x);

            if (Rut == string.Empty || Pass == string.Empty || Nombres == string.Empty || ApellidoP == string.Empty || ApellidoM == string.Empty || Correo == string.Empty || Telefono == string.Empty || Telefono == string.Empty)
            {
                await this.ShowMessageAsync("Alerta", "Debe llenar la informacion necesaria para continuar.");

                return;
            }
            else if (!numerico)
            {
                await this.ShowMessageAsync("Alerta", "Telefono debe ser valor numerico.");

                return;
            }
            else
            {
                //se crea el Usuario
                Usuario u = new Usuario();


                u.Rut = Rut;

                u.IdTipo = IdTipo;
                u.Pass   = Pass;
                Usuario ul = u.ULogueado;
                u.ULogueado = null;
                string xml = u.Serializar();
                u.Nombres   = Nombres;
                u.ApellidoP = ApellidoP;
                u.ApellidoM = ApellidoM;
                u.Correo    = Correo;
                u.Telefono  = Telefono;
                u.Direccion = Direccion;
                u.Moroso    = Moroso;
                u.DarBaja   = DarBaja;
                if (IdTipo == 1)
                {
                    u.RutEmpresa = RutEmpresa;
                }
                else
                {
                    u.RutEmpresa = string.Empty;
                }
                xml = u.Serializar();


                PrevencionRiesgosWCF.PrevencionClient proxy = new PrevencionRiesgosWCF.PrevencionClient();
                bool valido = proxy.CreateUsuario(xml);
                proxy.Close();
                u.ULogueado = ul;
                if (valido)
                {
                    await this.ShowMessageAsync("Exito", "Usuario Registrado Correctamente.");

                    //try
                    //{

                    //    Document doc = new Document();
                    //    PdfWriter.GetInstance(doc, new FileStream("C:DatosUsuario.pdf", FileMode.Create));
                    //    doc.Open();



                    //    StringBuilder sb = new StringBuilder();

                    //    sb.AppendLine("Rut: " + rut);
                    //    sb.AppendLine("Nombre: " + nombre);
                    //    sb.AppendLine("Apellido: " + apellidoP);
                    //    sb.AppendLine("Contraseña: " + pass);


                    //    iTextSharp.text.Paragraph par = new iTextSharp.text.Paragraph("" + sb);

                    //    doc.Add(par);
                    //    doc.Close();


                    //    Correo Cr = new Correo();
                    //    MailMessage mnsj = new MailMessage();

                    //    mnsj.Subject = "Registro de usuario";
                    //    mnsj.To.Add(new MailAddress(correo));
                    //    mnsj.From = new MailAddress("*****@*****.**", "Administrador BLD");
                    //    mnsj.Attachments.Add(new Attachment("C:DatosUsuario.pdf"));
                    //    mnsj.Body = string.Format("Usted ha sido registrado exitosamente en el pañol de {0} de Duoc Uc sede {1}", u.escuela, u.sede);

                    //    Cr.MandarCorreo(mnsj);

                    //    MessageBox.Show("El Mail se ha Enviado Correctamente", "Listo!!");
                    //}
                    //catch (Exception ex)
                    //{
                    //    MessageBox.Show(ex.ToString());
                    //}
                }
                else
                {
                    await this.ShowMessageAsync("Error", "No Se Pudo Registrar El Usuario.");
                }
                LimpiarControles();
            }
        }