private void cargarComboRegion()
 {
     try
     {
         ServiceProcess_Region.Process_RegionSoapClient auxServiceRegion = new ServiceProcess_Region.Process_RegionSoapClient();
         auxServiceRegion.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis;
         auxServiceRegion.ClientCredentials.UserName.Password = Cuenta.Clave_iis;
         DataSet   ds = new DataSet();
         DataTable dt = new DataTable();
         ds = auxServiceRegion.TraerTodasRegiones_Escritorio();
         dt = ds.Tables[0];
         DataRow fila = dt.NewRow();
         fila["ID_REGION"] = 0;
         fila["NOMBRE"]    = "SELECCIONE REGION";
         fila["NUMERO"]    = " ";
         dt.Rows.InsertAt(fila, 0);
         cbRegion.DropDownStyle = ComboBoxStyle.DropDownList;
         cbRegion.DataSource    = dt;
         cbRegion.DisplayMember = "NOMBRE";
         cbRegion.ValueMember   = "ID_REGION";
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error al cargar Informacion cargarComboRegion, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #2
0
        public FormUsuarioModal(string tituloModal, int accion, string rut_usuario, string primer_nombre, string segundo_nombre,
                                string primer_apellido, string segundo_apellido, string direccion, string telefono_fijo, string telefono_movil,
                                string estado, string id_comuna, string rut_empresa, string id_cargo)
        {
            InitializeComponent();

            try
            {
                //Carga de Web Service
                ServiceProcess_Cargo.Process_CargoSoapClient auxServiceCargo = new ServiceProcess_Cargo.Process_CargoSoapClient();
                auxServiceCargo.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis;
                auxServiceCargo.ClientCredentials.UserName.Password = Cuenta.Clave_iis;
                ServiceProcess_Region.Process_RegionSoapClient auxServiceRegion = new ServiceProcess_Region.Process_RegionSoapClient();
                auxServiceRegion.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis;
                auxServiceRegion.ClientCredentials.UserName.Password = Cuenta.Clave_iis;
                ServiceProcess_Provincia.Process_ProvinciaSoapClient auxServiceProvincia = new ServiceProcess_Provincia.Process_ProvinciaSoapClient();
                auxServiceProvincia.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis;
                auxServiceProvincia.ClientCredentials.UserName.Password = Cuenta.Clave_iis;
                ServiceProcess_Comuna.Process_ComunaSoapClient auxServiceComuna = new ServiceProcess_Comuna.Process_ComunaSoapClient();
                auxServiceComuna.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis;
                auxServiceComuna.ClientCredentials.UserName.Password = Cuenta.Clave_iis;
                ServiceProcess_Empresa.Process_EmpresaSoapClient auxServiceEmpresa = new ServiceProcess_Empresa.Process_EmpresaSoapClient();
                auxServiceEmpresa.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis;
                auxServiceEmpresa.ClientCredentials.UserName.Password = Cuenta.Clave_iis;
                ServiceProcess_Empresa.Empresa auxEmpresa = new ServiceProcess_Empresa.Empresa();
                auxEmpresa = auxServiceEmpresa.TraerEmpresaConEntidad_Escritorio(rut_empresa);

                _rut_empresa = rut_empresa;
                if (accion == 1)// modificar
                {
                    //Se cargan las clases de comuna provincia y region mediante web service
                    ServiceProcess_Comuna.Comuna       auxComuna    = new ServiceProcess_Comuna.Comuna();
                    ServiceProcess_Provincia.Provincia auxProvincia = new ServiceProcess_Provincia.Provincia();
                    //Se buscan comuna y provincia
                    auxComuna    = auxServiceComuna.TraerComunaConEntidad_Escritorio(Convert.ToInt32(id_comuna));
                    auxProvincia = auxServiceProvincia.TraerProvinciaConEntidad_Escritorio(auxComuna.Id_provincia);
                    //Se almacena en variables
                    int _id_provincia = auxProvincia.Id_provincia;
                    int _region       = auxProvincia.Id_region;
                    //Cambiar Titulo de Modal
                    lblTitulo.Text = tituloModal;
                    //Se habilita Boton
                    btnGuardar.Visible  = true;
                    btnCancelar.Visible = true;
                    btnVolver.Visible   = false;
                    //Se carga combos de estado y region
                    cargarComboRegion();
                    cargarComboCargo(rut_empresa);
                    //bloquear combobox
                    cbRegion.DropDownStyle    = ComboBoxStyle.DropDownList;
                    cbProvincia.DropDownStyle = ComboBoxStyle.DropDownList;
                    cbComuna.DropDownStyle    = ComboBoxStyle.DropDownList;
                    cbCargo.DropDownStyle     = ComboBoxStyle.DropDownList;
                    //se inactiva txtbox de rut de Usuario
                    txtRutUsuario.ReadOnly = true;
                    txtRutUsuario.Enabled  = false;
                    //desbloquear cajas de texto
                    txtPrimerNombre.ReadOnly    = false;
                    txtSegundoNombre.ReadOnly   = false;
                    txtPrimerApellido.ReadOnly  = false;
                    txtSegundoApellido.ReadOnly = false;
                    txtDireccion.ReadOnly       = false;
                    txtTelefonoFijo.ReadOnly    = false;
                    txtTelefonoMovil.ReadOnly   = false;
                    //se pasan datos a cajas de texto de cuadro de datos
                    txtRutUsuario.Text        = rut_usuario;
                    txtPrimerNombre.Text      = primer_nombre;
                    txtSegundoNombre.Text     = segundo_nombre;
                    txtPrimerApellido.Text    = primer_apellido;
                    txtSegundoApellido.Text   = segundo_apellido;
                    txtDireccion.Text         = direccion;
                    txtTelefonoFijo.Text      = telefono_fijo;
                    txtTelefonoMovil.Text     = telefono_movil;
                    cbRegion.SelectedValue    = _region;
                    cbProvincia.SelectedValue = _id_provincia;
                    cbComuna.SelectedValue    = id_comuna;
                    _estado = estado;
                    if (_estado.Equals("1"))
                    {
                        txtEstado.Text = "ACTIVO";
                    }
                    else
                    {
                        txtEstado.Text = "DASACTIVADO";
                    }
                    txtEstado.Enabled     = false;
                    txtEmpresa.Text       = auxEmpresa.Nombre;
                    txtEmpresa.ReadOnly   = true;
                    txtEmpresa.Enabled    = false;
                    cbCargo.SelectedValue = id_cargo;
                    //se vacian variables para que no queden con informacion
                    _rut_usuario      = null;
                    _primer_nombre    = null;
                    _segundo_nombre   = null;
                    _primer_apellido  = null;
                    _segundo_apellido = null;
                    _direccion        = null;
                    _telefono_fijo    = null;
                    _telefono_movil   = null;
                    _estado           = null;
                    _id_comuna        = null;
                    //Variable para interaccion de botones (0 = ninguno) (1 = modificar) - (2 = guardar)
                    _guardar = 1;
                }
                else// mostrar
                {
                    //Se cargan las clases de comuna provincia y region mediante web service
                    ServiceProcess_Comuna.Comuna       auxComuna    = new ServiceProcess_Comuna.Comuna();
                    ServiceProcess_Provincia.Provincia auxProvincia = new ServiceProcess_Provincia.Provincia();
                    //Se buscan comuna y provincia
                    auxComuna    = auxServiceComuna.TraerComunaConEntidad_Escritorio(Convert.ToInt32(id_comuna));
                    auxProvincia = auxServiceProvincia.TraerProvinciaConEntidad_Escritorio(auxComuna.Id_provincia);
                    //Se almacena en variables
                    int _id_provincia = auxProvincia.Id_provincia;
                    int _region       = auxProvincia.Id_region;
                    //Cambiar Titulo de Modal
                    lblTitulo.Text = tituloModal;
                    //Se habilita Boton
                    btnGuardar.Visible  = false;
                    btnCancelar.Visible = false;
                    btnVolver.Visible   = true;
                    //Se carga combos de estado y region
                    cargarComboRegion();
                    cargarComboCargo(rut_empresa);
                    //bloquear combobox
                    cbRegion.DropDownStyle    = ComboBoxStyle.DropDownList;
                    cbProvincia.DropDownStyle = ComboBoxStyle.DropDownList;
                    cbComuna.DropDownStyle    = ComboBoxStyle.DropDownList;
                    cbCargo.DropDownStyle     = ComboBoxStyle.DropDownList;
                    cbRegion.Enabled          = false;
                    cbCargo.Enabled           = false;
                    //se inactiva txtbox de rut de Usuario
                    txtRutUsuario.ReadOnly = true;
                    txtRutUsuario.Enabled  = false;
                    //bloquear cajas de texto
                    txtRutUsuario.Enabled      = false;
                    txtPrimerNombre.Enabled    = false;
                    txtSegundoNombre.Enabled   = false;
                    txtPrimerApellido.Enabled  = false;
                    txtSegundoApellido.Enabled = false;
                    txtDireccion.Enabled       = false;
                    txtTelefonoFijo.Enabled    = false;
                    txtTelefonoMovil.Enabled   = false;
                    txtEmpresa.Enabled         = false;
                    //se pasan datos a cajas de texto de cuadro de datos
                    txtRutUsuario.Text        = rut_usuario;
                    txtPrimerNombre.Text      = primer_nombre;
                    txtSegundoNombre.Text     = segundo_nombre;
                    txtPrimerApellido.Text    = primer_apellido;
                    txtSegundoApellido.Text   = segundo_apellido;
                    txtDireccion.Text         = direccion;
                    txtTelefonoFijo.Text      = telefono_fijo;
                    txtTelefonoMovil.Text     = telefono_movil;
                    cbRegion.SelectedValue    = _region;
                    cbProvincia.SelectedValue = _id_provincia;
                    cbComuna.SelectedValue    = id_comuna;
                    _estado = estado;
                    if (_estado.Equals("1"))
                    {
                        txtEstado.Text = "ACTIVO";
                    }
                    else
                    {
                        txtEstado.Text = "DASACTIVADO";
                    }
                    txtEstado.Enabled     = false;
                    txtEmpresa.Text       = auxEmpresa.Nombre;
                    cbCargo.SelectedValue = id_cargo;
                    cbProvincia.Enabled   = false;
                    cbComuna.Enabled      = false;
                    //se vacian variables para que no queden con informacion
                    _rut_usuario      = null;
                    _primer_nombre    = null;
                    _segundo_nombre   = null;
                    _primer_apellido  = null;
                    _segundo_apellido = null;
                    _direccion        = null;
                    _telefono_fijo    = null;
                    _telefono_movil   = null;
                    _estado           = null;
                    _id_comuna        = null;
                    //Variable para interaccion de botones (0 = ninguno) (1 = modificar) - (2 = guardar)
                    _guardar = 3;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error al cargar Informacion Modal Usuario, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }