public void cargarComboProvincia(int _id_region)
 {
     try
     {
         ServiceProcess_Provincia.Process_ProvinciaSoapClient auxServiceProvincia = new ServiceProcess_Provincia.Process_ProvinciaSoapClient();
         auxServiceProvincia.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis;
         auxServiceProvincia.ClientCredentials.UserName.Password = Cuenta.Clave_iis;
         DataSet   ds = new DataSet();
         DataTable dt = new DataTable();
         ds = auxServiceProvincia.TraerTodasProvinciasPorRegion_Escritorio(_id_region);
         dt = ds.Tables[0];
         DataRow fila = dt.NewRow();
         fila["ID_PROVINCIA"] = 0;
         fila["NOMBRE"]       = "SELECCIONE PROVINCIA";
         fila["ID_REGION"]    = 1;
         dt.Rows.InsertAt(fila, 0);
         cbProvincia.DropDownStyle = ComboBoxStyle.DropDownList;
         cbProvincia.DataSource    = dt;
         cbProvincia.DisplayMember = "NOMBRE";
         cbProvincia.ValueMember   = "ID_PROVINCIA";
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error al cargar Informacion cargarComboProvincia, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        public FormEmpresaModal(string _tituloModal, int _accion, string _rut_empresa, string _nombre, string _giro, string _direccion, string _estado, string _id_comuna)
        {
            InitializeComponent();
            try
            {
                //Modalidad de Modal segun Accion Padre 1 = modificar / 2 = nuevo / 3 = Ver
                if (_accion == 1)
                {
                    //Cambiar Titulo de Modal
                    lblTitulo.Text = _tituloModal;
                    //Instancia de Web service con credenciales NT
                    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;

                    //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();
                    ServiceProcess_Region.Region       auxRegion    = new ServiceProcess_Region.Region();
                    //Se trae informacion de comuna y provincia de la empresa selecciionada
                    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;
                    //Se habilita Boton
                    btnGuardar.Visible  = true;
                    btnCancelar.Visible = true;
                    // desactivar boton acepatar
                    btnVolver.Visible = false;
                    //Se carga combos de estado y region
                    cargarComboRegion();
                    //bloquear combobox
                    cbRegion.DropDownStyle    = ComboBoxStyle.DropDownList;
                    cbProvincia.DropDownStyle = ComboBoxStyle.DropDownList;
                    cbComuna.DropDownStyle    = ComboBoxStyle.DropDownList;
                    //se inactiva txtbox de rut de empresa
                    txtRutEmpresa.ReadOnly = true;
                    txtRutEmpresa.Enabled  = false;
                    //se inactiva txtbox de ESTADO de empresa
                    txtEstado.ReadOnly = true;
                    txtEstado.Enabled  = false;
                    //desbloquear cajas de texto
                    txtNombreEmpresa.ReadOnly = false;
                    txtGiro.ReadOnly          = false;
                    txtDireccion.ReadOnly     = false;
                    //se pasan datos a cajas de texto de cuadro de datos
                    txtRutEmpresa.Text        = _rut_empresa;
                    txtNombreEmpresa.Text     = _nombre;
                    txtGiro.Text              = _giro;
                    txtDireccion.Text         = _direccion;
                    cbRegion.SelectedIndex    = _region;
                    cbProvincia.SelectedValue = _id_provincia;
                    cbComuna.SelectedValue    = _id_comuna;
                    if (_estado.Equals("1"))
                    {
                        txtEstado.Text = "ACTIVO";
                    }
                    else
                    {
                        txtEstado.Text = "DASACTIVADO";
                    }

                    //Variable para interaccion de botones (0 = ninguno) (1 = modificar) - (2 = guardar) - (3 = Ver)
                    _guardar = 1;
                }
                else if (_accion == 2)
                {
                    //Cambiar Titulo de Modal
                    lblTitulo.Text = _tituloModal;
                    //Se habilita Boton
                    btnGuardar.Visible  = true;
                    btnCancelar.Visible = true;
                    // desactivar boton acepatar
                    btnVolver.Visible = false;
                    //desbloquear cajas de texto
                    txtRutEmpresa.ReadOnly    = false;
                    txtNombreEmpresa.ReadOnly = false;
                    txtGiro.ReadOnly          = false;
                    txtDireccion.ReadOnly     = false;
                    //Cargar comobox de region
                    cargarComboRegion();
                    //vaciar textbox
                    txtRutEmpresa.Text    = string.Empty;
                    txtNombreEmpresa.Text = string.Empty;
                    txtGiro.Text          = string.Empty;
                    txtDireccion.Text     = string.Empty;
                    //bloquear combobox
                    cbRegion.DropDownStyle    = ComboBoxStyle.DropDownList;
                    cbProvincia.DropDownStyle = ComboBoxStyle.DropDownList;
                    cbComuna.DropDownStyle    = ComboBoxStyle.DropDownList;
                    //vaciar combobox
                    cbProvincia.DataSource = null;
                    cbProvincia.Items.Clear();
                    cbComuna.DataSource = null;
                    cbComuna.Items.Clear();
                    //Dasactivar estado
                    txtEstado.Visible = false;
                    lblEstado.Visible = false;
                    //Variable para interaccion de botones (0 = ninguno) (1 = modificar) - (2 = Nuevo) - (3 = Ver)
                    _guardar = 2;
                }
                else
                {
                    //Cambiar Titulo de Modal
                    lblTitulo.Text = _tituloModal;
                    //Instancia de Web service con credenciales NT
                    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;

                    //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();
                    ServiceProcess_Region.Region       auxRegion    = new ServiceProcess_Region.Region();
                    //Se trae informacion de comuna y provincia de la empresa selecciionada
                    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;
                    //Se habilita Boton
                    btnGuardar.Visible  = false;
                    btnCancelar.Visible = false;
                    // desactivar boton acepatar
                    btnVolver.Visible = true;
                    //Se carga combos de estado y region
                    cargarComboRegion();
                    //bloquear combobox
                    cbRegion.DropDownStyle    = ComboBoxStyle.DropDownList;
                    cbProvincia.DropDownStyle = ComboBoxStyle.DropDownList;
                    cbComuna.DropDownStyle    = ComboBoxStyle.DropDownList;
                    //se pasan datos a cajas de texto de cuadro de datos
                    txtRutEmpresa.Text        = _rut_empresa;
                    txtNombreEmpresa.Text     = _nombre;
                    txtGiro.Text              = _giro;
                    txtDireccion.Text         = _direccion;
                    cbRegion.SelectedIndex    = _region;
                    cbProvincia.SelectedValue = _id_provincia;
                    cbComuna.SelectedValue    = _id_comuna;
                    if (_estado.Equals("1"))
                    {
                        txtEstado.Text = "ACTIVO";
                    }
                    else
                    {
                        txtEstado.Text = "DASACTIVADO";
                    }

                    //se inactiva txtbox de rut de empresa
                    txtRutEmpresa.ReadOnly = true;
                    txtRutEmpresa.Enabled  = false;
                    //se inactiva txtbox de nombre
                    txtNombreEmpresa.ReadOnly = true;
                    txtNombreEmpresa.Enabled  = false;
                    //se inactiva txtbox de giro
                    txtGiro.ReadOnly = true;
                    txtGiro.Enabled  = false;
                    //se inactiva txtbox de direccion
                    txtDireccion.ReadOnly = true;
                    txtDireccion.Enabled  = false;
                    //se inactiva combo de region
                    cbRegion.Enabled = false;
                    //se inactiva combo de provincia
                    cbProvincia.Enabled = false;
                    //se inactiva combo de comuna
                    cbComuna.Enabled = false;
                    //se inactiva txtbox de ESTADO de empresa
                    txtEstado.ReadOnly = true;
                    txtEstado.Enabled  = false;
                    //Variable para interaccion de botones (0 = ninguno) (1 = modificar) - (2 = guardar) - (3 = Ver)
                    _guardar = 3;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error al cargar Informacion Modal Empresa, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #3
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);
            }
        }