private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { string valorUnico = "0"; int entidadId = 0; string documentoId = "0"; string tipoGarantiaId = ""; string temporalId = ""; DialogResult resp; int resultado = 0, index = 0; List <DataDB_ELR_NET.Parametro> parametros = new List <DataDB_ELR_NET.Parametro>(); DataRow MyFila = null; FormSolicitudCreditoR frmGPersonal = new FormSolicitudCreditoR(); FormSolicitudGarantiaVehiculo frmGVehiculo = new FormSolicitudGarantiaVehiculo(); WinControl_ELR_NET.ELRFormMensajeErrores frmMensajeErrores = new WinControl_ELR_NET.ELRFormMensajeErrores(); try { this.Cursor = Cursors.WaitCursor; temporalId = objUtil.GetTemporalID(); var senderGrid = (DataGridView)sender; if (MyData == null) { return; } if (MyData.Rows.Count <= 0) { return; } if (e.RowIndex < 0) { return; } valorUnico = senderGrid["unico", senderGrid.CurrentRow.Index].Value.ToString(); index = senderGrid.CurrentRow.Index; //ELIMINAMOS UN REGISTRO DE GARANTIA if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0) { resp = objUtil.MostrarMensajePregunta("Esta Seguro que desea Eliminar el Registro de Esta Garantia?"); if (resp == System.Windows.Forms.DialogResult.Yes) { parametros.Add(new DataDB_ELR_NET.Parametro("IdentificadorTemp", temporalId)); parametros.Add(new DataDB_ELR_NET.Parametro("Unico", valorUnico)); parametros.Add(new DataDB_ELR_NET.Parametro("Autor", nombreUsuario)); objDB.iniciarTransaccion(); resultado = objDB.EjecutarSP("SP_PRESTAMOS_ELIMINA_GARANTIA", parametros); if (resultado > 0) { objDB.confirmarTransaccion(); RealizarBusquedaSencilla(); } else { frmMensajeErrores.TemporalId = temporalId; frmMensajeErrores.objDB = objDB; frmMensajeErrores.ShowDialog(); } } } if (senderGrid.Columns[e.ColumnIndex] is DataGridViewLinkColumn && e.RowIndex >= 0) { //TODO - Button Clicked - Execute Code Here valorUnico = senderGrid["unico", senderGrid.CurrentRow.Index].Value.ToString(); //BUSCO LA FILA SELECCIONADA POS SU UNICO MyFila = MyData.Select("Unico = " + valorUnico.ToString())[0]; entidadId = objUtil.GetAsInt("Entidad_Id", MyFila); documentoId = objUtil.GetAsString("Documento_Id", MyFila); tipoGarantiaId = objUtil.GetAsString("Tipo_Garantia_Id", MyFila).Trim().ToUpper(); parametros.Clear(); if (tipoGarantiaId == "P") { parametros.Add(new DataDB_ELR_NET.Parametro("Id", entidadId)); parametros.Add(new DataDB_ELR_NET.Parametro("IdentificadorTemp", temporalId)); parametros.Add(new DataDB_ELR_NET.Parametro("autor", nombreUsuario)); objDB.iniciarTransaccion(); resultado = objDB.EjecutarSP("SP_TEMPORAL_CLASIFICADOR_ENTIDADES", parametros); if (resultado < 0) { MostrarErrorTemporal(temporalId); objDB.cancelarTransaccion(); } else { objDB.confirmarTransaccion(); frmGPersonal.nombreUsuario = nombreUsuario; frmGPersonal.solicitudId = solicitudId; frmGPersonal.entidadId = entidadId; frmGPersonal.VALOR_ID = entidadId.ToString(); frmGPersonal.DTVariablesSYS = DTVariablesSYS; frmGPersonal.DSGlobal = DSGlobal; frmGPersonal.EnEjecusion = true; frmGPersonal.temporalID = temporalId; frmGPersonal.EMPRESA_ID = empresaID; frmGPersonal.OFICINA_ID = oficinaID; frmGPersonal.esGarantiaPersonal = true; frmGPersonal.ShowDialog(); if (frmGPersonal.lOK) { this.GetData(); } } } if (tipoGarantiaId == "V") { parametros.Add(new DataDB_ELR_NET.Parametro("Id", valorUnico)); parametros.Add(new DataDB_ELR_NET.Parametro("IdentificadorTemp", temporalId)); parametros.Add(new DataDB_ELR_NET.Parametro("autor", nombreUsuario)); objDB.iniciarTransaccion(); resultado = objDB.EjecutarSP("SP_TEMPORAL_GARANTIA_VEHICULO", parametros); if (resultado < 0) { MostrarErrorTemporal(temporalId); objDB.cancelarTransaccion(); } else { objDB.confirmarTransaccion(); frmGVehiculo.nombreUsuario = nombreUsuario; frmGVehiculo.solicitudId = solicitudId; frmGVehiculo.VALOR_ID = valorUnico; frmGVehiculo.DTVariablesSYS = DTVariablesSYS; frmGVehiculo.DSGlobal = DSGlobal; frmGVehiculo.EnEjecusion = true; frmGVehiculo.temporalID = temporalId; frmGVehiculo.EMPRESA_ID = empresaID; frmGVehiculo.OFICINA_ID = oficinaID; frmGVehiculo.ShowDialog(); if (frmGVehiculo.lOK) { RealizarBusquedaSencilla(); } } } //Buscamos el Unico Para Ubicar sobre la fila senderGrid.CurrentCell = senderGrid["btnEliminar", index]; senderGrid.CurrentCell.Selected = true; } } catch (Exception ex) { objUtil.MostrarMensajeError(ex.Message); } finally { this.Cursor = Cursors.Default; frmGPersonal.Dispose(); frmGVehiculo.Dispose(); frmMensajeErrores.Dispose(); objDB.cancelarTransaccion(); } }
private void btnGenerar_Click(object sender, EventArgs e) { DialogResult resp; DataTable myData; string nombreSP; string descripcion; List <DataDB_ELR_NET.Parametro> parametros = new List <DataDB_ELR_NET.Parametro>(); string temporalId; bool resultado = false; int cantErrores = 0; string mensaje = ""; WinControl_ELR_NET.ELRFormMensajeErrores frmErrores = new WinControl_ELR_NET.ELRFormMensajeErrores(); try { fecha = dtpFecha.Value.Date; cantErrores = 0; resultado = false; lblProcesoActual.Text = "PROCESO EN EJECUSION..."; //VALIDAMOS LA FECHA DE CIERRE NO PUEDE SER MAYOR A LA ACTUAL if (objDB.DateToInt(fecha) > objDB.DateToInt(DateTime.Now.Date)) { resultado = false; objUtil.MostrarMensajeAdvertencia("LA FECHA A CERRAR NO PUEDE SER MAYOR A LA FECHA ACTUAL"); return; } cantErrores = 0; temporalId = objUtil.GetTemporalID(); progressBar1.Value = 0; progressBar1.Step = 1; progressBar1.Refresh(); resultado = true; if ((DTData.Rows.Count > 0) && (resultado == true)) { resultado = false; if (objDB.DateToInt(fechaUltGenerado) < objDB.DateToInt(fecha)) { resultado = true; } } if (resultado) { resp = objUtil.MostrarMensajePregunta("ESTA SEGURO DE REALIZAR EL CIERRE DE FECHA " + fecha.ToShortDateString() + "?"); if (resp != DialogResult.Yes) { resultado = false; } } if (resultado) { objDB.iniciarTransaccion(); parametros.Add(new DataDB_ELR_NET.Parametro("Fecha", objDB.DateToInt(fecha).ToString())); parametros.Add(new DataDB_ELR_NET.Parametro("Autor", nombreUsuario)); parametros.Add(new DataDB_ELR_NET.Parametro("IdentificadorTemp", temporalId)); foreach (DataRow item in DTData.Rows) { if (cantErrores == 0) { this.Cursor = Cursors.WaitCursor; resultado = false; nombreSP = item["Nombre_SP"].ToString(); descripcion = item["Descripcion"].ToString(); lblProcesoActual.Text = descripcion; //EJECUTAMOS EL STORE PROCEDURE if (objDB.EjecutarSP(nombreSP, parametros) < 0) { cantErrores++; resultado = false; break; } progressBar1.PerformStep(); this.Cursor = Cursors.Default; resultado = true; } } } //MOSTRAMOS LA VENTANA DE ERRORES if (cantErrores > 0) { frmErrores.objDB = objDB; frmErrores.TemporalId = temporalId; frmErrores.ShowDialog(); } if (resultado) { fechaUltGenerado = fecha; objDB.confirmarTransaccion(); mensaje = "PROCESO REALIZADO DE FORMA SATISFACTORIA"; if (contabilidadId > 0) { mensaje += ", A CONTINUACION EL SISTEMA GENERARA LOS MOVIMIENTOS CONTABLES"; } objUtil.MostrarMensajeInformacion(mensaje); //GENERAMOS LA CONTABILIDAD if (contabilidadId > 0) { GenerarContabilidad(); } } else { objDB.cancelarTransaccion(); } this.Cursor = Cursors.Default; } catch (Exception ex) { objDB.cancelarTransaccion(); objUtil.MostrarMensajeError(ex.Message); } finally { this.Cursor = Cursors.Default; frmErrores.Dispose(); myData = null; } }