//Metodo de accion click en gridview private void DgvEmpresas_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex < 0) { return; } _rut_empresa = dgvEmpresas.Rows[e.RowIndex].Cells["RUT"].Value.ToString(); //instansear web service con seguridad 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 = auxEmpresa.Rut_empresa; txtEmpresa.Text = auxEmpresa.Nombre; pbSeleccion.Visible = true; } catch (Exception ex) { MessageBox.Show("Error en metodo de accion DgvEmpresas_CellClick, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
// metodo para filtrar gridview private void TxtFiltrar_KeyUp(object sender, KeyEventArgs e) { try { dgvEmpresas.Rows.Clear(); dgvEmpresas.Refresh(); //instansear web service con seguridad 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(); //capturar dataset DataSet ds = auxServiceEmpresa.TraerEmpresaConClaveSinEntidad_Escritorio(txtFiltrar.Text.ToUpper()); if ((ds.Tables.Count != 0) && (ds.Tables[0].Rows.Count > 0)) { //Capturar Tabla DataTable dt = ds.Tables[0]; //contar cantidad de empresas int _cantidad_empresas = dt.Rows.Count; //crear array bidimencional string[,] ListaEmpresa = new string[_cantidad_empresas, 2]; //Recorrer data table int _fila = 0; for (int i = 0; i < dt.Rows.Count; i++) { //Capturar datos de la fila recorridad en objeto empresa auxEmpresa.Rut_empresa = (String)dt.Rows[i]["Rut_empresa"]; auxEmpresa.Nombre = (String)dt.Rows[i]["Nombre"]; auxEmpresa.Giro = (String)dt.Rows[i]["Giro"]; auxEmpresa.Direccion = (String)dt.Rows[i]["Direccion"]; auxEmpresa.Estado = Convert.ToInt32(dt.Rows[i]["Estado"]); auxEmpresa.Id_comuna = Convert.ToInt32(dt.Rows[i]["Id_comuna"]); if (auxEmpresa.Estado == 1) // si la empresa esta activa se carga en la lista { // cargar array con datos de fila ListaEmpresa[_fila, 0] = auxEmpresa.Rut_empresa; ListaEmpresa[_fila, 1] = auxEmpresa.Nombre; //agregar lista a gridview dgvEmpresas.Rows.Add(ListaEmpresa[_fila, 0], ListaEmpresa[_fila, 1]); _fila++; } } txtEmpresa.Clear(); pbSeleccion.Visible = false; } else { //Mostrar GridView Vacio } } catch (Exception ex) { MessageBox.Show("Error en metodo de accion TxtFiltrar_KeyUp, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//Metodo Carga GridView Usuario Empresa private void cargarDataGridViewEmpresa() { try { ServiceProcess_Usuario.Process_UsuarioSoapClient auxServiceUsuario = new ServiceProcess_Usuario.Process_UsuarioSoapClient(); auxServiceUsuario.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis; auxServiceUsuario.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(); //capturar dataset DataSet ds = auxServiceEmpresa.TraerTodasEmpresas_Escritorio(); //Capturar Tabla DataTable dt = ds.Tables[0]; //contar cantidad de empresas int _cantidad_empresas = dt.Rows.Count; //crear array bidimencional string[,] ListaEmpresas = new string[_cantidad_empresas, 2]; //Recorrer data table int _fila = 0; for (int i = 0; i < dt.Rows.Count; i++) { //Capturar datos de la fila recorridad en objeto empresa auxEmpresa.Rut_empresa = (String)dt.Rows[i]["Rut_empresa"]; auxEmpresa.Nombre = (String)dt.Rows[i]["Nombre"]; auxEmpresa.Giro = (String)dt.Rows[i]["Giro"]; auxEmpresa.Direccion = (String)dt.Rows[i]["Direccion"]; auxEmpresa.Estado = Convert.ToInt32(dt.Rows[i]["Estado"]); auxEmpresa.Id_comuna = Convert.ToInt32(dt.Rows[i]["Id_comuna"]); //CAPTURAR DATASET DataSet dsU = auxServiceUsuario.TraerUsuarioPorRutPorEmpresaSinEntidad_Escritorio(_rut_usuario, auxEmpresa.Rut_empresa); if ((dsU.Tables.Count != 0) && (dsU.Tables[0].Rows.Count > 0)) { //no carga nada al gridview por que ya es usuario de la empresa } else { //cargar array con datos de fila ListaEmpresas[_fila, 0] = auxEmpresa.Rut_empresa; ListaEmpresas[_fila, 1] = auxEmpresa.Nombre; //agregar lista a gridview dgvEmpresas.Rows.Add(ListaEmpresas[_fila, 0], ListaEmpresas[_fila, 1]); _fila++; } } } catch (Exception ex) { MessageBox.Show("Error en metodo cargarDataGridViewUsuario, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void CbEmpresa_SelectedIndexChanged(object sender, EventArgs e) { try { pbSeleccionEmpresa.Visible = false; if (Convert.ToInt32(cbEmpresa.SelectedIndex) > 0) { _rut_empresa = cbEmpresa.SelectedValue.ToString(); pbSeleccionUnidad.Visible = false; pbSeleccionEmpresa.Visible = true; 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); txtEmpresa.Text = auxEmpresa.Nombre; //limpiar GridView dgvUnidad.Rows.Clear(); dgvUnidad.Refresh(); //limpiar _id_unidad = string.Empty; //vaciar combobox cargarDataGridViewUnidad(); } else { pbSeleccionUnidad.Visible = false; pbSeleccionEmpresa.Visible = false; //limpiar GridView dgvUnidad.Rows.Clear(); dgvUnidad.Refresh(); //limpiar _id_unidad = string.Empty; _rut_empresa = string.Empty; //vaciar txtbox txtNombreEquipo.Text = string.Empty; txtEmpresa.Text = string.Empty; txtUnidad.Text = string.Empty; } } catch (Exception ex) { MessageBox.Show("Error al cargar Informacion CbEmpresa_SelectedIndexChanged, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void BtnDesactivar_Click(object sender, EventArgs e) { try { //Instancia de Web service con credenciales NT 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_CargosUsuarios.Process_CargosUsuariosSoapClient auxServiceCargosUsuarios = new ServiceProcess_CargosUsuarios.Process_CargosUsuariosSoapClient(); auxServiceCargosUsuarios.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis; auxServiceCargosUsuarios.ClientCredentials.UserName.Password = Cuenta.Clave_iis; ServiceProcess_Empresa.Empresa auxEmpresa = new ServiceProcess_Empresa.Empresa(); auxEmpresa = auxServiceEmpresa.TraerEmpresaConEntidad_Escritorio(_rut_empresa); if (MessageBox.Show("¿Esta Seguro de Desactivar Usuario " + _primer_nombre + " " + _primer_apellido + " Para la Empresa " + auxEmpresa.Nombre + "?", "CONFIRMAR", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { //Insertar datos via web service auxServiceCargosUsuarios.ActualizarCargosUsuarioSinEntidad_Escritorio(_rut_usuario, Convert.ToInt32(_id_cargo), 0); btnActivar.Visible = false; btnDesactivar.Visible = false; //Vaciar variables _rut_usuario = null; _primer_nombre = string.Empty; _segundo_nombre = string.Empty; _primer_apellido = string.Empty; _segundo_apellido = string.Empty; _direccion = string.Empty; _telefono_fijo = string.Empty; _telefono_movil = string.Empty; _estado = string.Empty; _id_comuna = string.Empty; _rut_empresa = string.Empty; _id_cargo = string.Empty; pbSeleccion.Visible = false; //limpiar GridView dgvUsuario.Rows.Clear(); dgvUsuario.Refresh(); //Metodo Carga de GridView cargarDataGridViewPpal(); MessageBox.Show("Usuario Desactivado Para Empresa " + auxEmpresa.Nombre + " .", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { //continua CON LA VISTA ACTUAL } } catch (Exception ex) { MessageBox.Show("Error en metodo de accion BtnDesactivar_Click, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void cargarDataGridViewUnidad() { try { dgvUnidad.Rows.Clear(); dgvUnidad.Refresh(); //instansear web service con seguridad ServiceProcess_Unidad.Process_UnidadSoapClient auxServiceUnidad = new ServiceProcess_Unidad.Process_UnidadSoapClient(); auxServiceUnidad.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis; auxServiceUnidad.ClientCredentials.UserName.Password = Cuenta.Clave_iis; ServiceProcess_Empresa.Empresa auxEmpresa = new ServiceProcess_Empresa.Empresa(); ServiceProcess_Unidad.Unidad auxUnidad = new ServiceProcess_Unidad.Unidad(); //capturar dataset DataSet ds = auxServiceUnidad.TraerUnidadPorEmpresaSinEntidad_Escritorio(_rut_empresa); if ((ds.Tables.Count != 0) && (ds.Tables[0].Rows.Count > 0)) { //Capturar Tabla DataTable dt = ds.Tables[0]; //contar cantidad de empresas int _cantidad_unidades = dt.Rows.Count; //crear array bidimencional string[,] ListaUnidades = new string[_cantidad_unidades, 2]; //Recorrer data table int _fila = 0; for (int i = 0; i < dt.Rows.Count; i++) { //Capturar datos de la fila recorridad en objeto Unidad int id_unidad = Convert.ToInt32(dt.Rows[i]["Id_unidad"]); string nombre_unidad = (String)dt.Rows[i]["Nombre"]; //cargar array con datos de fila ListaUnidades[_fila, 0] = id_unidad.ToString(); ListaUnidades[_fila, 1] = nombre_unidad; //agregar lista a gridview dgvUnidad.Rows.Add(ListaUnidades[_fila, 0], ListaUnidades[_fila, 1]); _fila++; } } else { MessageBox.Show("La Empresa Seleccionada No tienes Unidades creadas .", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); pbSeleccionUnidad.Visible = false; } } catch (Exception ex) { MessageBox.Show("Error en metodo cargarDataGridViewEquipo, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//Accion para rescatar fila eleginda del gridview private void DgvEmpresas_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex < 0) { return; } _rut_empresa = dgvEmpresas.Rows[e.RowIndex].Cells["RUT"].Value.ToString(); //instansear web service con seguridad 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); _nombre = auxEmpresa.Nombre; _giro = auxEmpresa.Giro; _direccion = auxEmpresa.Direccion; _estado = auxEmpresa.Estado.ToString(); _id_comuna = auxEmpresa.Id_comuna.ToString(); pbSeleccion.Visible = true; if (_rut_empresa.Equals("82982300-4"))//No se puede editar la empresa dueña del software { btnActivar.Visible = false; btnDesactivar.Visible = false; } else { if (_estado.Equals("0")) { btnActivar.Visible = true; btnDesactivar.Visible = false; } else { btnDesactivar.Visible = true; btnActivar.Visible = false; } } } catch (Exception ex) { MessageBox.Show("Error en metodo de accion DgvEmpresas_CellClick, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void cargarDataGridViewPpal() { try { //instansear web service con seguridad 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_Cargo.Process_CargoSoapClient auxServiceCargo = new ServiceProcess_Cargo.Process_CargoSoapClient(); auxServiceCargo.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis; auxServiceCargo.ClientCredentials.UserName.Password = Cuenta.Clave_iis; ServiceProcess_Cargo.Cargo auxCargo = new ServiceProcess_Cargo.Cargo(); ServiceProcess_Empresa.Empresa auxEmpresa = new ServiceProcess_Empresa.Empresa(); //capturar dataset DataSet ds = auxServiceCargo.TraerTodasCargos_Escritorio(); //Capturar Tabla DataTable dt = ds.Tables[0]; //contar cantidad de empresas int _cantidad_cargos = dt.Rows.Count; //crear array bidimencional string[,] ListaCargos = new string[_cantidad_cargos, 5]; //Recorrer data table int _fila = 0; for (int i = 0; i < dt.Rows.Count; i++) { //Capturar datos de la fila recorridad en objeto cargo auxCargo.Id_cargo = Convert.ToInt32(dt.Rows[i]["Id_Cargo"]); auxCargo.Nombre = (String)dt.Rows[i]["Nombre"]; auxCargo.Descripcion = (String)dt.Rows[i]["Descripcion"]; auxCargo.Rut_empresa = (String)dt.Rows[i]["Rut_empresa"]; //variables temporales de apoyo string _nombre_empresa = string.Empty; //cargar array con datos de fila ListaCargos[_fila, 0] = auxCargo.Id_cargo.ToString(); ListaCargos[_fila, 1] = auxCargo.Nombre; auxEmpresa = auxServiceEmpresa.TraerEmpresaConEntidad_Escritorio(auxCargo.Rut_empresa); ListaCargos[_fila, 2] = auxEmpresa.Nombre; ListaCargos[_fila, 3] = auxEmpresa.Rut_empresa; ListaCargos[_fila, 4] = auxCargo.Descripcion; //agregar lista a gridview dgvCargo.Rows.Add(ListaCargos[_fila, 0], ListaCargos[_fila, 1], ListaCargos[_fila, 2], ListaCargos[_fila, 3], ListaCargos[_fila, 4]); _fila++; } pbSeleccion.Visible = false; } catch (Exception ex) { MessageBox.Show("Error en metodo cargarDataGridViewPpal, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void BtnDesactivar_Click(object sender, EventArgs e) { try { //Instancia de Web service con credenciales NT 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); if (MessageBox.Show("¿Esta Seguro de Desactivar la Unidad " + _nombre + " de la Empresa " + auxEmpresa.Nombre + "?", "CONFIRMAR", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { //Instancia de Web service con credenciales NT ServiceProcess_Unidad.Process_UnidadSoapClient auxServiceUnidad = new ServiceProcess_Unidad.Process_UnidadSoapClient(); auxServiceUnidad.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis; auxServiceUnidad.ClientCredentials.UserName.Password = Cuenta.Clave_iis; //Insertar datos via web service auxServiceUnidad.ActualizarUnidadSinEntidad_Escritorio(Convert.ToInt32(_id_unidad), _nombre, _descripcion, 0, _rut_empresa); //ocultar botones btnActivar.Visible = false; btnDesactivar.Visible = false; //Vaciar variables _id_unidad = null; _nombre = string.Empty; _descripcion = string.Empty; _estado = string.Empty; _rut_empresa = string.Empty; //limpiar GridView dgvUnidad.Rows.Clear(); dgvUnidad.Refresh(); //Metodo Carga de GridView cargarDataGridViewPpal(); MessageBox.Show("Unidad Desactivada.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { //continua CON LA VISTA ACTUAL } } catch (Exception ex) { MessageBox.Show("Error en metodo de accion BtnDesactivar_Click, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//Metodo Carga GridView public void cargarDataGridViewPpal() { try { //instansear web service con seguridad 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(); //capturar dataset DataSet ds = auxServiceEmpresa.TraerTodasEmpresas_Escritorio(); //Capturar Tabla DataTable dt = ds.Tables[0]; //contar cantidad de empresas int _cantidad_empresas = dt.Rows.Count; //crear array bidimencional string[,] ListaEmpresa = new string[_cantidad_empresas, 2]; //Recorrer data table int _fila = 0; for (int i = 0; i < dt.Rows.Count; i++) { //Capturar datos de la fila recorridad en objeto empresa auxEmpresa.Rut_empresa = (String)dt.Rows[i]["Rut_empresa"]; auxEmpresa.Nombre = (String)dt.Rows[i]["Nombre"]; auxEmpresa.Giro = (String)dt.Rows[i]["Giro"]; auxEmpresa.Direccion = (String)dt.Rows[i]["Direccion"]; auxEmpresa.Estado = Convert.ToInt32(dt.Rows[i]["Estado"]); auxEmpresa.Id_comuna = Convert.ToInt32(dt.Rows[i]["Id_comuna"]); if (auxEmpresa.Estado == 1) // si la empresa esta activa se carga en la lista { // cargar array con datos de fila ListaEmpresa[_fila, 0] = auxEmpresa.Rut_empresa; ListaEmpresa[_fila, 1] = auxEmpresa.Nombre; //agregar lista a gridview dgvEmpresas.Rows.Add(ListaEmpresa[_fila, 0], ListaEmpresa[_fila, 1]); _fila++; } } pbSeleccion.Visible = false; } catch (Exception ex) { MessageBox.Show("Error en metodo cargarDataGridViewPpal, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void TxtFiltrar_KeyUp(object sender, KeyEventArgs e) { try { dgvUnidad.Rows.Clear(); dgvUnidad.Refresh(); //instansear web service con seguridad 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_Unidad.Process_UnidadSoapClient auxServiceUnidad = new ServiceProcess_Unidad.Process_UnidadSoapClient(); auxServiceUnidad.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis; auxServiceUnidad.ClientCredentials.UserName.Password = Cuenta.Clave_iis; ServiceProcess_Empresa.Empresa auxEmpresa = new ServiceProcess_Empresa.Empresa(); ServiceProcess_Unidad.Unidad auxUnidad = new ServiceProcess_Unidad.Unidad(); //capturar dataset DataSet ds = auxServiceUnidad.TraerUnidadConClaveSinEntidad_Escritorio(txtFiltrar.Text.ToUpper()); if ((ds.Tables.Count != 0) && (ds.Tables[0].Rows.Count > 0)) { //Capturar Tabla DataTable dt = ds.Tables[0]; //contar cantidad de empresas int _cantidad_unidades = dt.Rows.Count; //crear array bidimencional string[,] ListaUnidad = new string[_cantidad_unidades, 6]; //Recorrer data table int _fila = 0; for (int i = 0; i < dt.Rows.Count; i++) { //Capturar datos de la fila recorridad en objeto empresa auxUnidad.Id_unidad = Convert.ToInt32(dt.Rows[i]["Id_unidad"]); auxUnidad.Nombre = (String)dt.Rows[i]["Nombre"]; auxUnidad.Descripcion = (String)dt.Rows[i]["Descripcion"]; auxUnidad.Estado = Convert.ToInt32(dt.Rows[i]["Estado"]); auxUnidad.Rut_empresa = (String)dt.Rows[i]["Rut_empresa"]; //variables temporales de apoyo string _estado = string.Empty; string _nombre_empresa = string.Empty; //cargar array con datos de fila ListaUnidad[_fila, 0] = auxUnidad.Id_unidad.ToString(); ListaUnidad[_fila, 1] = auxUnidad.Nombre; auxEmpresa = auxServiceEmpresa.TraerEmpresaConEntidad_Escritorio(auxUnidad.Rut_empresa); ListaUnidad[_fila, 2] = auxEmpresa.Nombre; ListaUnidad[_fila, 3] = auxEmpresa.Rut_empresa; if (auxUnidad.Estado == 0) { _estado = "DESACTIVADO"; } else { _estado = "ACTIVADO"; } ListaUnidad[_fila, 4] = _estado; ListaUnidad[_fila, 5] = auxUnidad.Descripcion; //agregar lista a gridview dgvUnidad.Rows.Add(ListaUnidad[_fila, 0], ListaUnidad[_fila, 1], ListaUnidad[_fila, 2], ListaUnidad[_fila, 3], ListaUnidad[_fila, 4], ListaUnidad[_fila, 5]); _fila++; } //vACIAR VARIABLES _id_unidad = null; _nombre = string.Empty; _descripcion = string.Empty; _estado = string.Empty; _rut_empresa = string.Empty; pbSeleccion.Visible = false; btnActivar.Visible = false; btnDesactivar.Visible = false; } else { //Mostrar GridView Vacio //vACIAR VARIABLES _id_unidad = null; _nombre = string.Empty; _descripcion = string.Empty; _estado = string.Empty; _rut_empresa = string.Empty; pbSeleccion.Visible = false; btnActivar.Visible = false; btnDesactivar.Visible = false; } } catch (Exception ex) { MessageBox.Show("Error en metodo de accion TxtFiltrar_KeyUp, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void BtnActivar_Click(object sender, EventArgs e) { try { if (_rut_usuario == null) { MessageBox.Show("Debe Seleccionar una Cuenta Antes de Activar cuenta.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { //Instancia de Web service con credenciales NT ServiceProcess_Cuenta.Process_CuentaSoapClient auxServiceCuenta = new ServiceProcess_Cuenta.Process_CuentaSoapClient(); auxServiceCuenta.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis; auxServiceCuenta.ClientCredentials.UserName.Password = Cuenta.Clave_iis; ServiceProcess_Usuario.Process_UsuarioSoapClient auxServiceUsuario = new ServiceProcess_Usuario.Process_UsuarioSoapClient(); auxServiceUsuario.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis; auxServiceUsuario.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_Usuario.Usuario auxUsuario = new ServiceProcess_Usuario.Usuario(); ServiceProcess_Cuenta.Cuenta auxCuenta = new ServiceProcess_Cuenta.Cuenta(); auxCuenta = auxServiceCuenta.TraerCuentaConEmpresaConEntidad_Escritorio(_rut_usuario, _rut_empresa); ServiceProcess_Empresa.Empresa auxEmpresa = new ServiceProcess_Empresa.Empresa(); auxEmpresa = auxServiceEmpresa.TraerEmpresaConEntidad_Escritorio(_rut_empresa); if (MessageBox.Show("¿Esta Seguro de Activar Cuenta " + _rut_usuario + " Para la Empresa " + auxEmpresa.Nombre + "?", "CONFIRMAR", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { //Insertar datos via web service auxServiceCuenta.ActualizarCuentaSinEntidad_Escritorio(auxCuenta.Rut_usuario, auxCuenta.Rut_empresa, 1, auxCuenta.Id_rol, auxCuenta.Correo); btnActivar.Visible = false; btnDesactivar.Visible = false; //Vaciar variables _rut_usuario = null; _rut_empresa = string.Empty; _contrasena = string.Empty; _estado = string.Empty; _id_rol = string.Empty; _correo = string.Empty; pbSeleccion.Visible = false; //limpiar GridView dgvCuenta.Rows.Clear(); dgvCuenta.Refresh(); //Metodo Carga de GridView cargarDataGridViewPpal(); MessageBox.Show("Cuenta Activada Para Empresa " + auxEmpresa.Nombre + " .", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { //continua CON LA VISTA ACTUAL } } } catch (Exception ex) { MessageBox.Show("Error en metodo de accion BtnActivar_Click, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void cargarDataGridViewPpal() { try { //instansear web service con seguridad 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(); ServiceProcess_Cuenta.Process_CuentaSoapClient auxServiceCuenta = new ServiceProcess_Cuenta.Process_CuentaSoapClient(); auxServiceCuenta.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis; auxServiceCuenta.ClientCredentials.UserName.Password = Cuenta.Clave_iis; ServiceProcess_Cuenta.Cuenta auxCuenta = new ServiceProcess_Cuenta.Cuenta(); ServiceProcess_Rol.Process_RolSoapClient auxServiceRol = new ServiceProcess_Rol.Process_RolSoapClient(); auxServiceRol.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis; auxServiceRol.ClientCredentials.UserName.Password = Cuenta.Clave_iis; ServiceProcess_Rol.Rol auxRol = new ServiceProcess_Rol.Rol(); ServiceProcess_Usuario.Process_UsuarioSoapClient auxServiceUsuario = new ServiceProcess_Usuario.Process_UsuarioSoapClient(); auxServiceUsuario.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis; auxServiceUsuario.ClientCredentials.UserName.Password = Cuenta.Clave_iis; ServiceProcess_Usuario.Usuario auxUsuario = new ServiceProcess_Usuario.Usuario(); //capturar dataset DataSet ds = auxServiceCuenta.TraerTodasCuentas_Escritorio(); //Capturar Tabla DataTable dt = ds.Tables[0]; //contar cantidad de empresas int _cantidad_Cuentas = dt.Rows.Count; //crear array bidimencional string[,] ListaCuenta = new string[_cantidad_Cuentas, 8]; //Recorrer data table int _fila = 0; for (int i = 0; i < dt.Rows.Count; i++) { //Capturar datos de la fila recorridad en objeto empresa auxCuenta.Rut_usuario = (String)dt.Rows[i]["Rut_usuario"]; auxCuenta.Rut_empresa = (String)dt.Rows[i]["Rut_empresa"]; auxCuenta.Contrasena = (String)dt.Rows[i]["Contrasena"]; auxCuenta.Estado = Convert.ToInt32(dt.Rows[i]["Estado"]); auxCuenta.Id_rol = Convert.ToInt32(dt.Rows[i]["Id_rol"]); auxCuenta.Correo = (String)dt.Rows[i]["Correo"]; //variables temporales de apoyo string _estado_iteracion = string.Empty; //cargar array con datos de fila ListaCuenta[_fila, 0] = auxCuenta.Rut_usuario; auxUsuario = auxServiceUsuario.TraerUsuarioConEntidad_Escritorio(auxCuenta.Rut_usuario); ListaCuenta[_fila, 1] = auxUsuario.Primer_nombre + " " + auxUsuario.Primer_apellido; auxEmpresa = auxServiceEmpresa.TraerEmpresaConEntidad_Escritorio(auxCuenta.Rut_empresa); ListaCuenta[_fila, 2] = auxEmpresa.Nombre; ListaCuenta[_fila, 3] = auxCuenta.Rut_empresa; ListaCuenta[_fila, 4] = auxCuenta.Correo; auxRol = auxServiceRol.TraerRolConEntidad_Escritorio(auxCuenta.Id_rol); ListaCuenta[_fila, 5] = auxCuenta.Id_rol.ToString(); ListaCuenta[_fila, 6] = auxRol.Nombre; if (auxCuenta.Estado == 0) { _estado_iteracion = "DESACTIVADO"; } else { _estado_iteracion = "ACTIVADO"; } ListaCuenta[_fila, 7] = _estado_iteracion; //agregar lista a gridview dgvCuenta.Rows.Add(ListaCuenta[_fila, 0], ListaCuenta[_fila, 1], ListaCuenta[_fila, 2], ListaCuenta[_fila, 3], ListaCuenta[_fila, 4], ListaCuenta[_fila, 5],ListaCuenta[_fila, 6], ListaCuenta[_fila, 7]); _fila++; } pbSeleccion.Visible = false; } catch (Exception ex) { MessageBox.Show("Error en metodo cargarDataGridViewPpal, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void TxtFiltrarEmpresa_KeyUp(object sender, KeyEventArgs e) { try { dgvEmpresas.Rows.Clear(); dgvEmpresas.Refresh(); //instansear web service con seguridad 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_Usuario.Process_UsuarioSoapClient auxServiceUsuario = new ServiceProcess_Usuario.Process_UsuarioSoapClient(); auxServiceUsuario.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis; auxServiceUsuario.ClientCredentials.UserName.Password = Cuenta.Clave_iis; ServiceProcess_Usuario.Usuario auxUsuario = new ServiceProcess_Usuario.Usuario(); ServiceProcess_Empresa.Empresa auxEmpresa = new ServiceProcess_Empresa.Empresa(); //capturar dataset DataSet ds = auxServiceEmpresa.TraerEmpresaConClaveSinEntidad_Escritorio(txtFiltrarEmpresa.Text.ToUpper()); if ((ds.Tables.Count != 0) && (ds.Tables[0].Rows.Count > 0)) { //Capturar Tabla DataTable dt = ds.Tables[0]; //contar cantidad de empresas int _cantidad_empresas = dt.Rows.Count; //crear array bidimencional string[,] ListaEmpresas = new string[_cantidad_empresas, 2]; //Recorrer data table int _fila = 0; for (int i = 0; i < dt.Rows.Count; i++) { //Capturar datos de la fila recorridad en objeto empresa auxEmpresa.Rut_empresa = (String)dt.Rows[i]["Rut_empresa"]; auxEmpresa.Nombre = (String)dt.Rows[i]["Nombre"]; auxEmpresa.Giro = (String)dt.Rows[i]["Giro"]; auxEmpresa.Direccion = (String)dt.Rows[i]["Direccion"]; auxEmpresa.Estado = Convert.ToInt32(dt.Rows[i]["Estado"]); auxEmpresa.Id_comuna = Convert.ToInt32(dt.Rows[i]["Id_comuna"]); //CAPTURAR DATASET DataSet dsU = auxServiceUsuario.TraerUsuarioPorRutPorEmpresaSinEntidad_Escritorio(_rut_usuario, auxEmpresa.Rut_empresa); if ((dsU.Tables.Count != 0) && (dsU.Tables[0].Rows.Count > 0)) { //no carga nada al gridview por que ya es usuario de la empresa } else { //cargar array con datos de fila ListaEmpresas[_fila, 0] = auxEmpresa.Rut_empresa; ListaEmpresas[_fila, 1] = auxEmpresa.Nombre; //agregar lista a gridview dgvEmpresas.Rows.Add(ListaEmpresas[_fila, 0], ListaEmpresas[_fila, 1]); _fila++; } } lblPaso1.Font = new System.Drawing.Font(lblPaso1.Font, FontStyle.Regular); lblPaso2.Font = new System.Drawing.Font(lblPaso1.Font, FontStyle.Bold); lblPaso3.Font = new System.Drawing.Font(lblPaso1.Font, FontStyle.Regular); pbSeleccion1.Visible = true; pbSeleccion2.Visible = false; pbSeleccion3.Visible = false; pbFlecha1.Visible = true; pbFlecha2.Visible = false; dgvCargo.Rows.Clear(); dgvCargo.Refresh(); _rut_empresa = null; _id_cargo = null; } else { lblPaso1.Font = new System.Drawing.Font(lblPaso1.Font, FontStyle.Regular); lblPaso2.Font = new System.Drawing.Font(lblPaso1.Font, FontStyle.Bold); lblPaso3.Font = new System.Drawing.Font(lblPaso1.Font, FontStyle.Regular); pbSeleccion1.Visible = true; pbSeleccion2.Visible = false; pbSeleccion3.Visible = false; pbFlecha1.Visible = true; pbFlecha2.Visible = false; dgvCargo.Rows.Clear(); dgvCargo.Refresh(); _rut_empresa = null; _id_cargo = null; } } catch (Exception ex) { MessageBox.Show("Error en metodo de accion TxtFiltrarEmpresa_KeyUp, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void TxtFiltrarCargo_KeyUp(object sender, KeyEventArgs e) { try { dgvCargo.Rows.Clear(); dgvCargo.Refresh(); //instansear web service con seguridad 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_Cargo.Process_CargoSoapClient auxServiceCargo = new ServiceProcess_Cargo.Process_CargoSoapClient(); auxServiceCargo.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis; auxServiceCargo.ClientCredentials.UserName.Password = Cuenta.Clave_iis; ServiceProcess_Cargo.Cargo auxCargo = new ServiceProcess_Cargo.Cargo(); ServiceProcess_Empresa.Empresa auxEmpresa = new ServiceProcess_Empresa.Empresa(); //capturar dataset DataSet dsF = auxServiceCargo.TraerCargoConClaveSinEntidad_Escritorio(txtFiltrarCargo.Text.ToUpper()); if ((dsF.Tables.Count != 0) && (dsF.Tables[0].Rows.Count > 0)) { //capturar dataset DataSet ds = auxServiceCargo.TraerCargoConEmpresaSinEntidad_Escritorio(_rut_empresa); //Capturar Tabla DataTable dt = ds.Tables[0]; //contar cantidad de empresas int _cantidad_cargos = dt.Rows.Count; //crear array bidimencional string[,] ListaCargos = new string[_cantidad_cargos, 5]; //Recorrer data table int _fila = 0; for (int i = 0; i < dt.Rows.Count; i++) { //Capturar datos de la fila recorridad en objeto cargo auxCargo.Id_cargo = Convert.ToInt32(dt.Rows[i]["Id_Cargo"]); auxCargo.Nombre = (String)dt.Rows[i]["Nombre"]; auxCargo.Descripcion = (String)dt.Rows[i]["Descripcion"]; auxCargo.Rut_empresa = (String)dt.Rows[i]["Rut_empresa"]; //variables temporales de apoyo string _nombre_empresa = string.Empty; //cargar array con datos de fila ListaCargos[_fila, 0] = auxCargo.Id_cargo.ToString(); ListaCargos[_fila, 1] = auxCargo.Nombre; //agregar lista a gridview dgvCargo.Rows.Add(ListaCargos[_fila, 0], ListaCargos[_fila, 1]); _fila++; } lblPaso1.Font = new System.Drawing.Font(lblPaso1.Font, FontStyle.Regular); lblPaso2.Font = new System.Drawing.Font(lblPaso1.Font, FontStyle.Regular); lblPaso3.Font = new System.Drawing.Font(lblPaso1.Font, FontStyle.Bold); pbSeleccion1.Visible = true; pbSeleccion2.Visible = true; pbSeleccion3.Visible = false; pbFlecha1.Visible = true; pbFlecha2.Visible = true; _id_cargo = null; } else { lblPaso1.Font = new System.Drawing.Font(lblPaso1.Font, FontStyle.Regular); lblPaso2.Font = new System.Drawing.Font(lblPaso1.Font, FontStyle.Regular); lblPaso3.Font = new System.Drawing.Font(lblPaso1.Font, FontStyle.Bold); pbSeleccion1.Visible = true; pbSeleccion2.Visible = true; pbSeleccion3.Visible = false; pbFlecha1.Visible = true; pbFlecha2.Visible = true; _id_cargo = null; } } catch (Exception ex) { MessageBox.Show("Error en metodo de accion TxtFiltrarCargo_KeyUp, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public FormEquipoModal(string titulo_modal, string accion, string id_equipo, string rut_empresa, string id_unidad) { InitializeComponent(); try { if (Convert.ToInt32(accion) == 1) { 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_Equipo.Process_EquipoSoapClient auxServiceEquipo = new ServiceProcess_Equipo.Process_EquipoSoapClient(); auxServiceEquipo.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis; auxServiceEquipo.ClientCredentials.UserName.Password = Cuenta.Clave_iis; ServiceProcess_Unidad.Process_UnidadSoapClient auxServiceUnidad = new ServiceProcess_Unidad.Process_UnidadSoapClient(); auxServiceUnidad.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis; auxServiceUnidad.ClientCredentials.UserName.Password = Cuenta.Clave_iis; ServiceProcess_Unidad.Unidad auxUnidad = new ServiceProcess_Unidad.Unidad(); ServiceProcess_Equipo.Equipo auxEquipo = new ServiceProcess_Equipo.Equipo(); ServiceProcess_Empresa.Empresa auxEmpresa = new ServiceProcess_Empresa.Empresa(); auxEquipo = auxServiceEquipo.TraerEquipoConEntidad_Escritorio(Convert.ToInt32(id_equipo)); auxEmpresa = auxServiceEmpresa.TraerEmpresaConEntidad_Escritorio(rut_empresa); _id_equipo = id_equipo; _rut_empresa = rut_empresa; _id_unidad = id_unidad; _guardar = accion; lblTitulo.Text = titulo_modal; cargarComboEmpresa(); cbEmpresa.SelectedValue = auxEmpresa.Rut_empresa; cbEmpresa.Enabled = false; txtEmpresa.Text = auxEmpresa.Nombre; txtEmpresa.Enabled = false; pbSeleccionEmpresa.Visible = true; cargarDataGridViewUnidad(); auxUnidad = auxServiceUnidad.TraerUnidadConEntidad_Escritorio(Convert.ToInt32(id_unidad), rut_empresa); txtUnidad.Text = auxUnidad.Nombre; pbSeleccionUnidad.Visible = true; txtUnidad.Enabled = false; txtNombreEquipo.Text = auxEquipo.Nombre; } else { _id_equipo = id_equipo; _id_unidad = id_unidad; _guardar = accion; lblTitulo.Text = titulo_modal; cargarComboEmpresa(); pbSeleccionEmpresa.Visible = false; pbSeleccionUnidad.Visible = false; txtEmpresa.Enabled = false; txtUnidad.Enabled = false; } } catch (Exception ex) { MessageBox.Show("Error al cargar Informacion Modal Equipo, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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); } }
public FormCargoModal(string _tituloModal, int _accion, int _id_cargo, string _nombre, string _descripcion, string _rut_empresa) { 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_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(); //Se carga variable de id unidad id_cargo = _id_cargo; //Capturar rut empresa rut_empresa = _rut_empresa; //Se habilita Boton btnGuardar.Visible = true; btnCancelar.Visible = true; // desactivar boton volver btnVolver.Visible = false; //se inactiva txtbox de rut de empresa txtEmpresa.ReadOnly = true; txtEmpresa.Enabled = false; //desbloquear cajas de texto txtNombre.ReadOnly = false; txtDescripcion.ReadOnly = false; //se pasan datos a cajas de texto desde formulario principal txtNombre.Text = _nombre; txtDescripcion.Text = _descripcion; auxEmpresa = auxServiceEmpresa.TraerEmpresaConEntidad_Escritorio(_rut_empresa); txtEmpresa.Text = auxEmpresa.Nombre; //Variable para interaccion de botones (0 = ninguno) (1 = modificar) - (2 = guardar) - (3 = Ver) _guardar = 1; } else { //Cambiar Titulo de Modal lblTitulo.Text = _tituloModal; //Instancia de Web service con credenciales NT 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(); //Se desactiva Botones btnGuardar.Visible = false; btnCancelar.Visible = false; // activar boton volver btnVolver.Visible = true; //se pasan datos a cajas de texto de cuadro de datos txtNombre.Text = _nombre; txtDescripcion.Text = _descripcion; auxEmpresa = auxServiceEmpresa.TraerEmpresaConEntidad_Escritorio(_rut_empresa); txtEmpresa.Text = auxEmpresa.Nombre; //se inactiva txtbox de nombre unidad txtNombre.ReadOnly = true; txtNombre.Enabled = false; //se inactiva txtbox de descripcion txtDescripcion.ReadOnly = true; txtDescripcion.Enabled = false; //se inactiva txtbox de empresa txtEmpresa.ReadOnly = true; txtEmpresa.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 Unidad, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void BtnGuardar_Click(object sender, EventArgs e) { try { //Instancia de Web service con credenciales NT 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_Validadores.Process_ValidadoresSoapClient auxServiceValidadores = new ServiceProcess_Validadores.Process_ValidadoresSoapClient(); auxServiceValidadores.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis; auxServiceValidadores.ClientCredentials.UserName.Password = Cuenta.Clave_iis; if (_guardar == 1)//Modificar empresa { //Validacion espacion en blanco y combobox vacios if (txtRutEmpresa.Text.Equals("") || txtNombreEmpresa.Text.Equals("") || txtGiro.Text.Equals("") || txtDireccion.Text.Equals("") || txtEstado.Text.Equals("") || Convert.ToInt32(cbRegion.SelectedIndex) == 0 || cbProvincia.SelectedValue == null || cbComuna.SelectedValue == null) { if (txtRutEmpresa.Text.Equals("")) { MessageBox.Show("El Rut de la Empresa no Puede estar Vacio.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (txtNombreEmpresa.Text.Equals("")) { MessageBox.Show("El Nombre de la Empresa no Puede estar Vacio.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (txtGiro.Text.Equals("")) { MessageBox.Show("El Giro de la Empresa no Puede estar Vacio.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (txtEstado.Text.Equals("")) { MessageBox.Show("El Estado de la Empresa no Puede estar Vacio.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (Convert.ToInt32(cbRegion.SelectedIndex) == 0) { MessageBox.Show("Debe seleccionar una Region.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (cbProvincia.SelectedValue == null) { MessageBox.Show("Debe seleccionar una Provincia.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (cbComuna.SelectedValue == null) { MessageBox.Show("Debe seleccionar una Comuna.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { //Validacion de longitud de caracteres if (txtRutEmpresa.Text.Trim().Length < 9 || txtRutEmpresa.Text.Trim().Length > 12 || txtNombreEmpresa.Text.Trim().Length < 4 || txtNombreEmpresa.Text.Trim().Length > 50 || txtGiro.Text.Trim().Length < 4 || txtGiro.Text.Trim().Length > 50 || txtDireccion.Text.Trim().Length < 4 || txtDireccion.Text.Trim().Length > 50) { if (txtRutEmpresa.Text.Trim().Length < 9 || txtRutEmpresa.Text.Trim().Length > 12) { MessageBox.Show("El Rut de la empresa debe tener Minimo 9 caracteres y Maximo 12 .", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (txtNombreEmpresa.Text.Trim().Length < 4 || txtNombreEmpresa.Text.Trim().Length > 50) { MessageBox.Show("El Nombre de la empresa debe tener Minimo 4 caracteres y Maximo 50 .", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (txtGiro.Text.Trim().Length < 4 || txtGiro.Text.Trim().Length > 50) { MessageBox.Show("El Giro de la empresa debe tener Minimo 4 caracteres y Maximo 50 .", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (txtDireccion.Text.Trim().Length < 4 || txtDireccion.Text.Trim().Length > 50) { MessageBox.Show("La Direccion de la empresa debe tener Minimo 4 caracteres y Maximo 50 .", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { //confirmacion de crear nueva empresa if (MessageBox.Show("Confirmar La Modificacion de la Empresa Seleccionada", "CONFIRMAR", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { //ESTADO int _estado; if (txtEstado.Equals("ACTIVO")) { _estado = 1; } else { _estado = 0; } //Insertar datos via web service auxServiceEmpresa.ActualizarEmpresaSinEntidad_Escritorio(txtRutEmpresa.Text.ToUpper(), txtNombreEmpresa.Text.ToUpper(), txtGiro.Text.ToUpper(), txtDireccion.Text.ToUpper(), _estado, Convert.ToInt32(cbComuna.SelectedValue)); //Metodo Carga de GridView this.DialogResult = DialogResult.OK; this.Close(); } else { //se devuelve al Cuadro de datos } } } } else//Nueva empresa { //Validacion espacion en blanco y combobox vacios if (txtRutEmpresa.Text.Equals("") || txtNombreEmpresa.Text.Equals("") || txtGiro.Text.Equals("") || txtDireccion.Text.Equals("") || Convert.ToInt32(cbRegion.SelectedIndex) == 0 || cbProvincia.SelectedValue == null || cbComuna.SelectedValue == null || Convert.ToInt32(cbProvincia.SelectedIndex) == 0 || Convert.ToInt32(cbComuna.SelectedIndex) == 0) { if (txtRutEmpresa.Text.Equals("")) { MessageBox.Show("El Rut de la Empresa no Puede estar Vacio.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (txtNombreEmpresa.Text.Equals("")) { MessageBox.Show("El Nombre de la Empresa no Puede estar Vacio.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (txtGiro.Text.Equals("")) { MessageBox.Show("El Giro de la Empresa no Puede estar Vacio.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (Convert.ToInt32(cbRegion.SelectedIndex) == 0) { MessageBox.Show("Debe seleccionar una Region.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (cbProvincia.SelectedValue == null) { MessageBox.Show("Debe seleccionar una Provincia.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (cbComuna.SelectedValue == null) { MessageBox.Show("Debe seleccionar una Comuna.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (Convert.ToInt32(cbProvincia.SelectedIndex) == 0) { MessageBox.Show("Debe seleccionar una Provincia.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (Convert.ToInt32(cbComuna.SelectedIndex) == 0) { MessageBox.Show("Debe seleccionar una Comuna.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { //Validacion de longitud de caracteres if (txtRutEmpresa.Text.Trim().Length < 9 || txtRutEmpresa.Text.Trim().Length > 12 || txtNombreEmpresa.Text.Trim().Length < 4 || txtNombreEmpresa.Text.Trim().Length > 50 || txtGiro.Text.Trim().Length < 4 || txtGiro.Text.Trim().Length > 50 || txtDireccion.Text.Trim().Length < 4 || txtDireccion.Text.Trim().Length > 50) { if (txtRutEmpresa.Text.Trim().Length < 9 || txtRutEmpresa.Text.Trim().Length > 12) { MessageBox.Show("El Rut de la empresa debe tener Minimo 9 caracteres y Maximo 12 .", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (txtNombreEmpresa.Text.Trim().Length < 4 || txtNombreEmpresa.Text.Trim().Length > 50) { MessageBox.Show("El Nombre de la empresa debe tener Minimo 4 caracteres y Maximo 50 .", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (txtGiro.Text.Trim().Length < 4 || txtGiro.Text.Trim().Length > 50) { MessageBox.Show("El Giro de la empresa debe tener Minimo 4 caracteres y Maximo 50 .", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (txtDireccion.Text.Trim().Length < 4 || txtDireccion.Text.Trim().Length > 50) { MessageBox.Show("La Direccion de la empresa debe tener Minimo 4 caracteres y Maximo 50 .", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { //Validacion de rut if (!auxServiceValidadores.rutValidacionService(txtRutEmpresa.Text.ToUpper())) { MessageBox.Show("El RUT de la Empresa ingresado no es Valido.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { //carga clase empresa ServiceProcess_Empresa.Empresa auxEmpresa = new ServiceProcess_Empresa.Empresa(); auxEmpresa = auxServiceEmpresa.TraerEmpresaConEntidad_Escritorio(txtRutEmpresa.Text); //Validar si empresa nueva ya esta registrada en sistema if (auxEmpresa.Rut_empresa == null) { //confirmacion de crear nueva empresa if (MessageBox.Show("Confirmar La Creacion de la Empresa.", "CONFIRMAR", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { //ESTADO int _estado; _estado = 1; //Insertar datos via web service auxServiceEmpresa.InsertarEmpresaSinEntidad_Escritorio(txtRutEmpresa.Text.ToUpper(), txtNombreEmpresa.Text.ToUpper(), txtGiro.Text.ToUpper(), txtDireccion.Text.ToUpper(), _estado, Convert.ToInt32(cbComuna.SelectedValue)); //Metodo Carga de GridView this.DialogResult = DialogResult.OK; this.Close(); } else { //se devuelve al Cuadro de datos } } else { MessageBox.Show("La Empresa que intenta registrar ya esta en el Sistema.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } }//fin if principal } catch (Exception ex) { MessageBox.Show("Error en Metodo de Accion BtnGuardar_Click, Contactese con el Administrador Detalle de Error: " + ex.Message, "Mensaje de sistema"); }//fin try catch }
private void TxtFiltrarUsuario_KeyUp(object sender, KeyEventArgs e) { try { dgvUsuario.Rows.Clear(); dgvUsuario.Refresh(); //instansear web service con seguridad ServiceProcess_Usuario.Process_UsuarioSoapClient auxServiceUsuario = new ServiceProcess_Usuario.Process_UsuarioSoapClient(); auxServiceUsuario.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis; auxServiceUsuario.ClientCredentials.UserName.Password = Cuenta.Clave_iis; ServiceProcess_Usuario.Usuario auxUsuario = new ServiceProcess_Usuario.Usuario(); 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(); ServiceProcess_Cuenta.Process_CuentaSoapClient auxServiceCuenta = new ServiceProcess_Cuenta.Process_CuentaSoapClient(); auxServiceCuenta.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis; auxServiceCuenta.ClientCredentials.UserName.Password = Cuenta.Clave_iis; ServiceProcess_Cuenta.Cuenta auxCuenta = new ServiceProcess_Cuenta.Cuenta(); if (txtFiltrarUsuario.Text.Equals("")) { cargarDataGridViewUsuario(); } else { //capturar dataset DataSet ds = auxServiceUsuario.TraerUsuarioConClavePorEmpresaSinEntidad_Escritorio(_rut_empresa, txtFiltrarUsuario.Text.ToUpper()); if ((ds.Tables.Count != 0) && (ds.Tables[0].Rows.Count > 0)) { //Capturar Tabla DataTable dt = ds.Tables[0]; //contar cantidad de empresas int _cantidad_Usuarios = dt.Rows.Count; //crear array bidimencional string[,] ListaUsuarios = new string[_cantidad_Usuarios, 2]; //Recorrer data table int _fila = 0; for (int i = 0; i < dt.Rows.Count; i++) { //Capturar datos de la fila recorridad en objeto empresa string rut_usuario = (String)dt.Rows[i]["Rut_usuario"]; string nombre = (String)dt.Rows[i]["Primer_nombre"] + " " + (String)dt.Rows[i]["Primer_apellido"]; string rut_empresa = (String)dt.Rows[i]["Rut_empresa"]; //CAPTURAR DATASET DataSet dsU = auxServiceCuenta.TraerCuentaConEmpresaSinEntidad_Escritorio(rut_usuario, _rut_empresa); if ((dsU.Tables.Count != 0) && (dsU.Tables[0].Rows.Count > 0)) { //no carga nada al gridview por que ya es usuario de la empresa } else { //cargar array con datos de fila ListaUsuarios[_fila, 0] = rut_usuario; ListaUsuarios[_fila, 1] = nombre; //agregar lista a gridview dgvUsuario.Rows.Add(ListaUsuarios[_fila, 0], ListaUsuarios[_fila, 1]); _fila++; } } pbSeleccionUsuario.Visible = false; pbSeleccionEmpresa.Visible = true; pbSeleccion.Visible = false; txtUsuario.Text = string.Empty; txtCorreo.Text = string.Empty; _rut_usuario = null; _correo = null; _id_rol = null; //vaciar combobox cbRol.DataSource = null; cbRol.Items.Clear(); //cargar como rol cargarComboRol(); } else { pbSeleccionUsuario.Visible = false; pbSeleccionEmpresa.Visible = true; pbSeleccion.Visible = false; txtUsuario.Text = string.Empty; txtCorreo.Text = string.Empty; _rut_usuario = null; _correo = null; _id_rol = null; //vaciar combobox cbRol.DataSource = null; cbRol.Items.Clear(); //cargar como rol cargarComboRol(); } } } catch (Exception ex) { MessageBox.Show("Error en metodo de accion TxtFiltrarUsuario_KeyUp, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void CbEmpresa_SelectedIndexChanged(object sender, EventArgs e) { try { 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(); if (Convert.ToInt32(cbEmpresa.SelectedIndex) > 0) { string rut_empresa = cbEmpresa.SelectedValue.ToString(); auxEmpresa = auxServiceEmpresa.TraerEmpresaConEntidad_Escritorio(rut_empresa); _rut_empresa = rut_empresa; txtEmpresa.Text = auxEmpresa.Nombre; //limpiar GridView dgvUsuario.Rows.Clear(); dgvUsuario.Refresh(); //limpiar dgvUsuario.Rows.Clear(); dgvUsuario.Refresh(); pbSeleccionUsuario.Visible = false; pbSeleccionEmpresa.Visible = true; pbSeleccion.Visible = false; txtUsuario.Text = string.Empty; txtCorreo.Text = string.Empty; _rut_usuario = null; _correo = null; _id_rol = null; //vaciar combobox cbRol.DataSource = null; cbRol.Items.Clear(); //cargar como rol cargarComboRol(); cargarDataGridViewUsuario(); } else { //limpiar GridView dgvUsuario.Rows.Clear(); dgvUsuario.Refresh(); pbSeleccionUsuario.Visible = false; pbSeleccionEmpresa.Visible = false; pbSeleccion.Visible = false; txtUsuario.Text = string.Empty; txtEmpresa.Text = string.Empty; txtCorreo.Text = string.Empty; //vaciar combobox cbRol.DataSource = null; cbRol.Items.Clear(); //cargar como rol cargarComboRol(); } } catch (Exception ex) { MessageBox.Show("Error al cargar Informacion CbEmpresa_SelectedIndexChanged, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//Metodo Carga GridView private void cargarDataGridViewPpal() { try { //instansear web service con seguridad ServiceProcess_Usuario.Process_UsuarioSoapClient auxServiceUsuario = new ServiceProcess_Usuario.Process_UsuarioSoapClient(); auxServiceUsuario.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis; auxServiceUsuario.ClientCredentials.UserName.Password = Cuenta.Clave_iis; ServiceProcess_Usuario.Usuario auxUsuario = new ServiceProcess_Usuario.Usuario(); 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(); //capturar dataset DataSet ds = auxServiceUsuario.TraerTodasUsuariosJoin_Escritorio(); //Capturar Tabla DataTable dt = ds.Tables[0]; //contar cantidad de empresas int _cantidad_usuarios = dt.Rows.Count; //crear array bidimencional string[,] ListaUsuario = new string[_cantidad_usuarios, 7]; //Recorrer data table int _fila = 0; for (int i = 0; i < dt.Rows.Count; i++) { //Capturar datos de la fila recorridad en objeto empresa auxUsuario.Rut_usuario = (String)dt.Rows[i]["Rut_usuario"]; auxUsuario.Primer_nombre = (String)dt.Rows[i]["Primer_nombre"]; auxUsuario.Segundo_nombre = (String)dt.Rows[i]["Segundo_nombre"]; auxUsuario.Primer_apellido = (String)dt.Rows[i]["Primer_apellido"]; auxUsuario.Segundo_apellido = (String)dt.Rows[i]["Segundo_apellido"]; auxUsuario.Direccion = (String)dt.Rows[i]["Direccion"]; auxUsuario.Telefono_fijo = Convert.ToInt32(dt.Rows[i]["Telefono_fijo"]); auxUsuario.Telefono_movil = Convert.ToInt32(dt.Rows[i]["Telefono_movil"]); auxUsuario.Id_comuna = Convert.ToInt32(dt.Rows[i]["Id_comuna"]); //variables temporales de apoyo string _estado_resultado = string.Empty; string _estado_iteracion = (String)dt.Rows[i]["Estado"]; int _id_cargo_iteracion = Convert.ToInt32(dt.Rows[i]["Id_cargo"]); string _rut_empresa_iteracion = (String)dt.Rows[i]["Rut_empresa"]; //cargar array con datos de fila ListaUsuario[_fila, 0] = auxUsuario.Primer_nombre + " " + auxUsuario.Segundo_nombre + " " + auxUsuario.Primer_apellido + " " + auxUsuario.Segundo_apellido; ListaUsuario[_fila, 1] = auxUsuario.Rut_usuario; ListaUsuario[_fila, 2] = auxUsuario.Direccion; auxEmpresa = auxServiceEmpresa.TraerEmpresaConEntidad_Escritorio(_rut_empresa_iteracion); ListaUsuario[_fila, 3] = auxEmpresa.Nombre; if (Convert.ToInt32(_estado_iteracion) == 0) { _estado_resultado = "DESACTIVADO"; } else { _estado_resultado = "ACTIVADO"; } ListaUsuario[_fila, 4] = _estado_resultado; ListaUsuario[_fila, 5] = _id_cargo_iteracion.ToString(); ListaUsuario[_fila, 6] = _rut_empresa_iteracion; //agregar lista a gridview dgvUsuario.Rows.Add(ListaUsuario[_fila, 0], ListaUsuario[_fila, 1], ListaUsuario[_fila, 2], ListaUsuario[_fila, 3], ListaUsuario[_fila, 4], ListaUsuario[_fila, 5], ListaUsuario[_fila, 6]); _fila++; } pbSeleccion.Visible = false; } catch (Exception ex) { MessageBox.Show("Error en metodo cargarDataGridViewPpal, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public FormCuentaModal(string Titulo, string accion, string rut_usuario, string rut_empresa, string contrasena, string estado, string id_rol, string correo) { InitializeComponent(); try { ServiceProcess_Usuario.Process_UsuarioSoapClient auxServiceUsuario = new ServiceProcess_Usuario.Process_UsuarioSoapClient(); auxServiceUsuario.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis; auxServiceUsuario.ClientCredentials.UserName.Password = Cuenta.Clave_iis; ServiceProcess_Usuario.Usuario auxUsuario = new ServiceProcess_Usuario.Usuario(); 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); auxUsuario = auxServiceUsuario.TraerUsuarioConEntidad_Escritorio(rut_usuario); if (accion.Equals("1"))// modificar { lblTitulo.Text = Titulo; //bloquear textbox txtCuenta.Enabled = false; txtUsuario.Enabled = false; txtEmpresa.Enabled = false; txtEstado.Enabled = false; //pasar datos a textbox txtCuenta.Text = rut_usuario; txtUsuario.Text = auxUsuario.Primer_nombre + " " + auxUsuario.Primer_apellido; txtEmpresa.Text = auxEmpresa.Nombre; if (estado.Equals("ACTIVADO")) { txtEstado.Text = "ACTIVADO"; _estado = "1"; } else { txtEstado.Text = "DASACTIVADO"; _estado = "0"; } txtCorreo.Text = correo; cargarComboRol(); cbRol.SelectedValue = id_rol; btnCancelar.Visible = true; btnGuardar.Visible = true; btnVolver.Visible = false; _rut_usuario = rut_usuario; _rut_empresa = rut_empresa; _contrasena = contrasena; _id_rol = id_rol; _correo = correo; } else { lblTitulo.Text = Titulo; //bloquear textbox txtCuenta.Enabled = false; txtUsuario.Enabled = false; txtEmpresa.Enabled = false; txtEstado.Enabled = false; txtCorreo.Enabled = false; //pasar datos a textbox txtCuenta.Text = rut_usuario; txtUsuario.Text = auxUsuario.Primer_nombre + " " + auxUsuario.Primer_apellido; txtEmpresa.Text = auxEmpresa.Nombre; if (estado.Equals("ACTIVADO")) { txtEstado.Text = "ACTIVADO"; _estado = "1"; } else { txtEstado.Text = "DASACTIVADO"; _estado = "0"; } txtCorreo.Text = correo; cargarComboRol(); cbRol.SelectedValue = Convert.ToInt32(id_rol); cbRol.Enabled = false; btnCancelar.Visible = false; btnGuardar.Visible = false; btnVolver.Visible = true; } } catch (Exception ex) { MessageBox.Show("Error al cargar Informacion Modal Cuenta, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void TxtFiltrar_KeyUp(object sender, KeyEventArgs e) { try { dgvEquipo.Rows.Clear(); dgvEquipo.Refresh(); dgvMiembros.Rows.Clear(); dgvMiembros.Refresh(); //instansear web service con seguridad ServiceProcess_Equipo.Process_EquipoSoapClient auxServiceEquipo = new ServiceProcess_Equipo.Process_EquipoSoapClient(); auxServiceEquipo.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis; auxServiceEquipo.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_Unidad.Process_UnidadSoapClient auxServiceUnidad = new ServiceProcess_Unidad.Process_UnidadSoapClient(); auxServiceUnidad.ClientCredentials.UserName.UserName = Cuenta.Usuario_iis; auxServiceUnidad.ClientCredentials.UserName.Password = Cuenta.Clave_iis; ServiceProcess_Empresa.Empresa auxEmpresa = new ServiceProcess_Empresa.Empresa(); ServiceProcess_Unidad.Unidad auxUnidad = new ServiceProcess_Unidad.Unidad(); //capturar dataset DataSet ds = auxServiceEquipo.TraerEquipoPorClaveSinEntidad_Escritorio(Convert.ToInt32(_id_unidad), _rut_empresa, txtFiltrar.Text.ToUpper()); if ((ds.Tables.Count != 0) && (ds.Tables[0].Rows.Count > 0)) { //Capturar Tabla DataTable dt = ds.Tables[0]; //contar cantidad de empresas int _cantidad_equipos = dt.Rows.Count; //crear array bidimencional string[,] ListaEquipos = new string[_cantidad_equipos, 6]; //Recorrer data table int _fila = 0; for (int i = 0; i < dt.Rows.Count; i++) { //Capturar datos de la fila recorridad en objeto rol int id_equipo = Convert.ToInt32(dt.Rows[i]["Id_equipo"]); string nombre_equipo = (String)dt.Rows[i]["Nombre"]; string rut_empresa = (String)dt.Rows[i]["Rut_empresa"]; auxEmpresa = auxServiceEmpresa.TraerEmpresaConEntidad_Escritorio(rut_empresa); string nombre_empresa = auxEmpresa.Nombre; int id_unidad = Convert.ToInt32(dt.Rows[i]["Id_unidad"]); auxUnidad = auxServiceUnidad.TraerUnidadConEntidad_Escritorio(id_unidad, rut_empresa); string nombre_unidad = auxUnidad.Nombre; //cargar array con datos de fila ListaEquipos[_fila, 0] = id_equipo.ToString(); ListaEquipos[_fila, 1] = nombre_equipo; ListaEquipos[_fila, 2] = rut_empresa; ListaEquipos[_fila, 3] = nombre_empresa; ListaEquipos[_fila, 4] = id_unidad.ToString(); ListaEquipos[_fila, 5] = nombre_unidad; //agregar lista a gridview dgvEquipo.Rows.Add(ListaEquipos[_fila, 0], ListaEquipos[_fila, 1], ListaEquipos[_fila, 2], ListaEquipos[_fila, 3], ListaEquipos[_fila, 4], ListaEquipos[_fila, 5]); _fila++; } _id_equipo = null; _nombre = string.Empty; } else { _id_equipo = null; _nombre = string.Empty; } } catch (Exception ex) { MessageBox.Show("Error en metodo de accion TxtFiltrar_KeyUp, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }