private void DgvCargo_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex < 0) { return; } _nombre = dgvCargo.Rows[e.RowIndex].Cells["NOMBRE_CARGO"].Value.ToString(); _rut_empresa = dgvCargo.Rows[e.RowIndex].Cells["RUT_EMPRESA"].Value.ToString(); //instansear web service con seguridad 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(); auxCargo = auxServiceCargo.TraerCargoPorNombrePorEmpresaConEntidad_Escritorio(_nombre, _rut_empresa); _id_cargo = auxCargo.Id_cargo.ToString(); _descripcion = auxCargo.Descripcion; pbSeleccion.Visible = true; } catch (Exception ex) { MessageBox.Show("Error en metodo de accion DgvUnidad_CellClick, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void DgvCargo_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex < 0) { return; } _id_cargo = dgvCargo.Rows[e.RowIndex].Cells["ID_CARGO"].Value.ToString(); _rut_empresa = cbEmpresa.SelectedValue.ToString(); //instansear web service con seguridad 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(); auxCargo = auxServiceCargo.TraerCargoConEntidad_Escritorio(Convert.ToInt32(_id_cargo)); txtCargo.Text = auxCargo.Nombre.ToUpper(); pbSeleccion.Visible = true; pbSeleccionCargo.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); } }
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 cargarDataGridViewCargos(string rut_empresa) { try { //instansear web service con seguridad 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(); //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, 2]; //Recorrer data table int _fila = 0; for (int i = 0; i < dt.Rows.Count; i++) { //Capturar datos de la fila recorridad en objeto cargos 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"]; 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++; } } catch (Exception ex) { MessageBox.Show("Error en metodo cargarDataGridViewCargos, 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_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(); //Validacion espacion en blanco y combobox vacios if (txtNombre.Text.Equals("") || txtDescripcion.Text.Equals("") || txtEmpresa.Text.Equals("")) { if (txtNombre.Text.Equals("")) { MessageBox.Show("El Nombre del Cargo no Puede estar Vacio.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (txtDescripcion.Text.Equals("")) { MessageBox.Show("La Descripcion del Cargo no Puede estar Vacio.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (txtEmpresa.Text.Equals("")) { MessageBox.Show("Debe seleccionar una Empresa a la cual pertenesca el Cargo, en la Lista de la Izquierda.", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { //Validacion de longitud de caracteres if (txtNombre.Text.Trim().Length < 4 || txtNombre.Text.Trim().Length > 99 || txtDescripcion.Text.Trim().Length < 10 || txtDescripcion.Text.Trim().Length > 250) { if (txtNombre.Text.Trim().Length < 4 || txtNombre.Text.Trim().Length > 99) { MessageBox.Show("El Nombre del Cargo debe tener Minimo 4 caracteres y Maximo 99 .", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (txtDescripcion.Text.Trim().Length < 10 || txtDescripcion.Text.Trim().Length > 250) { MessageBox.Show("La Descripcion del Cargo debe tener Minimo 10 caracteres y Maximo 250 .", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { auxCargo = auxServiceCargo.TraerCargoPorNombrePorEmpresaConEntidad_Escritorio(txtNombre.Text.ToUpper(), rut_empresa); //Validar si Nombre cargo ya existe en la empresa if (auxCargo.Nombre == null || auxCargo.Nombre.ToUpper().Equals(txtNombre.Text.ToUpper())) { if (MessageBox.Show("Confirmar la modificacion del Cargo", "CONFIRMAR", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { //Insertar datos via web service auxServiceCargo.ActualizarCargoSinEntidad_Escritorio(id_cargo, txtNombre.Text.ToUpper(), txtDescripcion.Text.ToUpper(), rut_empresa); //Metodo Carga de GridView this.DialogResult = DialogResult.OK; this.Close(); } else { //se devuelve al Cuadro de datos } } else { MessageBox.Show("Este Nombre de Cargo ya Existe en la Empresa Seleccionada", "ATENCION", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } catch (Exception ex) { MessageBox.Show("Error en metodo de accion BtnGuardar_Click, Contactese con el Administrador Detalle de Error: " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void TxtFiltrar_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 ds = auxServiceCargo.TraerCargoConClaveSinEntidad_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_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 empresa 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++; } //vACIAR VARIABLES _id_cargo = null; _nombre = string.Empty; _descripcion = string.Empty; _rut_empresa = string.Empty; pbSeleccion.Visible = false; } else { //Mostrar GridView Vacio //vACIAR VARIABLES _id_cargo = null; _nombre = string.Empty; _descripcion = string.Empty; _rut_empresa = string.Empty; pbSeleccion.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); } }