Exemplo n.º 1
0
        public string LeerCargo(string xmlcargo)
        {
            Cargos cargo = new Cargos(xmlcargo);

            if (cargo.Read())
            {
                return(cargo.Serializar());
            }
            else
            {
                return(null);
            }
        }
        private void CargarDatos()
        {
            if (Rut != null)
            {
                btnCrear.IsEnabled = false;
                Empleado emp = new Empleado();
                emp.Rut = Rut;
                string xml = emp.Serializar();
                xml = servicio.LeerEmpleado(xml);
                if (xml != null)
                {
                    emp = new Empleado(xml);
                    Cargos carg = new Cargos();
                    carg.Id = int.Parse(emp.IdCargo.ToString());
                    xml     = carg.Serializar();
                    xml     = servicio.LeerCargo(xml);
                    if (xml != null)
                    {
                        carg               = new Cargos();
                        txt_Rut.Text       = emp.Rut;
                        txt_Nombre.Text    = emp.Nombre;
                        txt_Dv.Text        = emp.Dv;
                        txt_ApellidoP.Text = emp.ApellidoPaterno;
                        txt_ApellidoM.Text = emp.ApellidoMaterno;
                        txt_Direccion.Text = emp.Direccion;
                        int val = 0;
                        for (int i = 0; i < cbo_Cargo.Items.Count; i++)
                        {
                            Cargos c = (Cargos)cbo_Cargo.Items[i];
                            if (c.Id == emp.IdCargo)
                            {
                                val = i;
                            }
                        }
                        cbo_Cargo.SelectedIndex = val;
                        Comuna com = new Comuna();
                        com.Id = int.Parse(emp.IdComuna.ToString());
                        xml    = com.Serializar();
                        xml    = servicio.LeerComuna(xml);
                        if (xml != null)
                        {
                            com = new Comuna(xml);
                            for (int i = 0; i < cbo_Ciudad.Items.Count; i++)
                            {
                                Provincia c = (Provincia)cbo_Ciudad.Items[i];
                                if (c.Id == com.IdProvincia)
                                {
                                    val = i;
                                }
                            }
                            cbo_Ciudad.SelectedIndex = val;

                            for (int i = 0; i < cbo_Comuna.Items.Count; i++)
                            {
                                Comuna c = (Comuna)cbo_Comuna.Items[i];
                                if (c.Id == int.Parse(emp.IdComuna.ToString()))
                                {
                                    val = i;
                                }
                            }
                            cbo_Comuna.SelectedIndex = val;
                        }
                    }
                }
            }
        }