private void dtgNominaDetalle_CellContentClick(object sender, DataGridViewCellEventArgs e) { string valorUnico = "0"; int index = 0; DataRow fila0; FormNominaVerDetalle frm = new FormNominaVerDetalle(); try { if (dtgNominaDetalle.RowCount > 0) { index = dtgNominaDetalle.CurrentRow.Index; valorUnico = dtgNominaDetalle["Unico", index].Value.ToString(); if (dtgNominaDetalle.Columns[e.ColumnIndex] is DataGridViewLinkColumn || dtgNominaDetalle.Columns[e.ColumnIndex] is DataGridViewButtonColumn) { fila0 = DTDetalle.Select("Unico = " + valorUnico)[0]; frm.fila0 = fila0; frm.ShowDialog(); } } } catch (Exception ex) { objUtil.MostrarMensajeError(ex.Message); } }
public override void TotalizarDetalle() { object calcObject; double totalDebito = 0.0, totalCredito = 0.0, total = 0.0; try { calcObject = DTDetalle.Compute("Sum(Valor)", "Origen = 'DR'"); if (calcObject != null) { if (calcObject.ToString().Trim() != "") { totalDebito = double.Parse(calcObject.ToString()); } } calcObject = DTDetalle.Compute("Sum(Valor)", "Origen = 'CR'"); if (calcObject != null) { if (calcObject.ToString().Trim() != "") { totalCredito = double.Parse(calcObject.ToString()); } } total = totalDebito - totalCredito; lblTotal.Text = "TOTAL >>> " + total.ToString("N2"); } catch (Exception) { throw; } }
private void dataGridView1_SelectionChanged(object sender, EventArgs e) { string valorUnico = "0"; try { fila0 = null; if (DTDetalle == null) { return; } if (DTDetalle.Rows.Count <= 0) { return; } if (dataGridView1.RowCount <= 0) { return; } valorUnico = dataGridView1["Unico", dataGridView1.CurrentRow.Index].Value.ToString(); fila0 = DTDetalle.Select("Unico = " + valorUnico)[0]; } catch (Exception) { } }
private void dtgvDetalle_CellContentClick(object sender, DataGridViewCellEventArgs e) { int valorItemNumero = 0; DataRow MyFila = null; FormFacturaEditItem frmEdit = new FormFacturaEditItem(); int index = 0; try { var senderGrid = (DataGridView)sender; if (e.RowIndex >= 0) { //TODO - Button Clicked - Execute Code Here index = senderGrid.CurrentRow.Index; valorItemNumero = int.Parse(senderGrid["ItemNumero", index].Value.ToString()); if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn) { EliminarLineaDetalleTemp(); if (dtgvDetalle.RowCount - 1 >= index) { dtgvDetalle.CurrentCell = dtgvDetalle["clnEliminar", index]; } else if (dtgvDetalle.RowCount > 0) { index = dtgvDetalle.RowCount - 1; dtgvDetalle.CurrentCell = dtgvDetalle["clnEliminar", index]; } } else if (senderGrid.Columns[e.ColumnIndex] is DataGridViewLinkColumn) { MyFila = DTDetalle.Select("ItemNumero = " + valorItemNumero.ToString())[0]; frmEdit.MyFila = MyFila; frmEdit.ShowDialog(); if (frmEdit.lOK) { if (ActualizarDetalleFormRow(MyFila, "ItemNumero")) { TotalizarDetalle(); } else { MyFila.RejectChanges(); } } } } } catch (Exception ex) { objUtil.MostrarMensajeError(ex.Message); } }
private void btnAplicarTodos_Click(object sender, EventArgs e) { bool esConsulta = false; bool esInsertar = false; bool esModificar = false; bool esCambiar_Fecha = false; bool esAnular = false; bool esAprobar = false; bool esRechazar = false; bool esGenerar = false; bool esImprimir = false; string valorUnico = "0"; Button btn; try { this.Cursor = Cursors.WaitCursor; btn = (Button)sender; if (btn == btnAplicarTodos) { esConsulta = true; esInsertar = true; esModificar = true; esCambiar_Fecha = true; esAnular = true; esAprobar = true; esRechazar = true; esGenerar = true; esImprimir = true; } for (int i = 0; i < DataGridDetalle.RowCount; i++) { valorUnico = DataGridDetalle["Unico", i].Value.ToString(); fila0 = DTDetalle.Select("Unico = " + valorUnico)[0]; fila0["EsActivo"] = esConsulta; fila0["EsConsulta"] = esConsulta; fila0["esInsertar"] = esInsertar; fila0["esModificar"] = esModificar; fila0["esCambiar_Fecha"] = esCambiar_Fecha; fila0["esAnular"] = esAnular; fila0["esAprobar"] = esAprobar; fila0["esRechazar"] = esRechazar; fila0["esGenerar"] = esGenerar; if (DataGridDetalle.Columns.Contains("EsImprimir")) { fila0["EsImprimir"] = esImprimir; } objDB.UpdateFromRow(TablaDetalle, fila0, "Unico", "IdentificadorTeemp"); } } catch (Exception ex) { objUtil.MostrarMensajeError(ex.Message); } finally { this.Cursor = Cursors.Default; } }
public override void TotalizarDetalle() { object calcObject; double totalInteres = 0; double totalDemora = 0; double totalOtros = 0; try { //base.TotalizarDetalle(); calcObject = DTDetalle.Compute("Sum(D_Interes)", ""); if (calcObject != null) { if (calcObject.ToString().Trim() != "") { totalInteres = double.Parse(calcObject.ToString()); } } calcObject = DTDetalle.Compute("Sum(D_Demora)", ""); if (calcObject != null) { if (calcObject.ToString().Trim() != "") { totalDemora = double.Parse(calcObject.ToString()); } } calcObject = DTDetalle.Compute("Sum(D_Otros)", ""); if (calcObject != null) { if (calcObject.ToString().Trim() != "") { totalOtros = double.Parse(calcObject.ToString()); } } total = totalInteres + totalDemora + totalOtros; SetValorEncabezado("Total_Interes", totalInteres); SetValorEncabezado("Total_Demora", totalDemora); SetValorEncabezado("Total_Otros", totalOtros); SetValorEncabezado("Total", total); lblTotalInteres.Text = totalInteres.ToString("C2"); lblTotalDemora.Text = totalDemora.ToString("C2"); lblTotalOtros.Text = totalOtros.ToString("C2"); lblTotal.Text = total.ToString("C2"); } catch (Exception ex) { objUtil.MostrarMensajeError("Error al Totalizar, " + ex.Message); } }
public override void CalcularLineaDetalle() { //base.CalcularLineaDetalle(); double cantidad = 0, precio = 0, tasaItbis = 0, itbis = 0, subTotal = 0, total = 0; int index = 0; int valorId = 0; DataRow fila0; bool esExcentoItbis, esPrecioConItbis; try { index = DataGridDetalle.CurrentRow.Index; valorId = int.Parse(DataGridDetalle["ItemNumero", index].Value.ToString()); fila0 = DTDetalle.Select("ItemNumero = " + valorId)[0]; cantidad = double.Parse(DataGridDetalle["Cantidad", index].Value.ToString()); precio = double.Parse(DataGridDetalle["Precio", index].Value.ToString()); tasaItbis = objUtil.GetAsDouble("Tasa_Itbis", fila0); esExcentoItbis = objUtil.GetAsBoolean("EsExcentoItbis", fila0); esPrecioConItbis = objUtil.GetAsBoolean("PrecioConItbis", fila0); if (esExcentoItbis) { tasaItbis = 0; } subTotal = Math.Round(cantidad * precio, 2); if ((esPrecioConItbis) && (tasaItbis > 0)) { itbis = precio - Math.Round((precio / (1 + tasaItbis / 100.0)), 2); precio = precio - itbis; subTotal = cantidad * precio; itbis = cantidad * itbis; } else { itbis = (subTotal * tasaItbis) / 100.0; } total = subTotal + itbis; fila0["Sub_Total"] = subTotal; fila0["Itbis"] = itbis; fila0["Total"] = total; fila0["Tasa_Itbis"] = tasaItbis; TotalizarDetalle(); } catch (Exception ex) { objUtil.MostrarMensajeError("Calcular Linea Detalle, " + ex.Message); } }
private void AgregarProducto() { DataRow MyFila; double cantidad = 1; double subTotal = 0, total = 0; try { cantidad = double.Parse(txtCantidad.Text); if ((drProducto != null) && (nivelPrecio != "")) { subTotal = cantidad * precioSinItbis; itbis = cantidad * itbis; total = cantidad * precioLista; MyFila = DTDetalle.NewRow(); MyFila["Producto_Id"] = drProducto["Producto_Id"]; MyFila["Descripcion"] = drProducto["Nombre_Corto"]; MyFila["Categoria_Id"] = drProducto["Categoria_Id"]; MyFila["UMedida_Id"] = drProducto["UMedida_Id"]; MyFila["Cantidad"] = cantidad; MyFila["Precio_Sin_Itbis"] = Math.Round(precioSinItbis, 2); MyFila["Precio"] = Math.Round(precioLista, 2); MyFila["Sub_Total"] = Math.Round(subTotal, 2); MyFila["Descuento"] = 0; MyFila["Tasa_Itbis"] = Math.Round(tasaItbis, 2); MyFila["Itbis"] = Math.Round(itbis, 2); MyFila["Monto"] = Math.Round(total, 2); MyFila["EsOferta"] = esOferta; MyFila["Nivel_Precio"] = nivelPrecio; AgregarLineaDetalle(MyFila); txtCantidad.Text = "1"; } precioLista = 0; precioSinItbis = 0; itbis = 0; nivelPrecio = ""; txtProductoId.Text = "0000"; txtProductoId.drFilaSel = null; drProducto = null; cboNivelPrecio.SelectedValue = ""; txtProductoId.SelectAll(); txtProductoId.Focus(); } catch (Exception ex) { objUtil.MostrarMensajeError(ex.Message); } }
private void AddItem() { DataRow MyFila; double cantidad = 1; try { cantidad = objUtil.ConvertirANumero(txtCantidad.Text); if (drProducto != null) { if (cantidad <= 0) { objUtil.MostrarMensajeAdvertencia("LA CANTIDAD DEBE SER MAYOR A CERO(0)"); txtCantidad.Focus(); return; } MyFila = DTDetalle.NewRow(); MyFila["Producto_Id"] = drProducto["Producto_Id"]; MyFila["Descripcion"] = drProducto["Nombre_Corto"]; MyFila["Categoria_Id"] = drProducto["Categoria_Id"]; MyFila["UMedida_Id"] = drProducto["UMedida_Id"]; MyFila["Cantidad"] = cantidad; MyFila["Precio"] = 0; MyFila["Sub_Total"] = 0; MyFila["Descuento"] = 0; MyFila["Tasa_Itbis"] = 0; MyFila["Itbis"] = 0; MyFila["Total"] = 0; MyFila["EsExcentoItbis"] = false; MyFila["PrecioConItbis"] = false; AgregarLineaDetalle(MyFila, "Identificador_Id"); txtCodigoProducto.Text = ""; txtCantidad.Text = "1"; drProducto = null; btnAgregarItem.Enabled = false; lblProdDescripcion.BackColor = SystemColors.Control; lblProdDescripcion.Text = @"NOMBRE/DESCRIPCION ITEM VENTA"; txtCodigoProducto.Focus(); } } catch (Exception ex) { lblProdDescripcion.Text = "ERROR: " + ex.Message; lblProdDescripcion.BackColor = Color.Red; } }
private void cboTipoSaldo_SelectedValueChanged(object sender, EventArgs e) { try { btnGrabar.Enabled = false; lblMontoCuota.Text = "0.00"; DTDetalle.Clear(); } catch (Exception ex) { objUtil.MostrarMensajeError(ex.Message); } }
void editarCantidadPrecio(int itemNumero = 0) { DataRow fila0 = null; int index = 0; string tipo = "P"; FormFacturaEditItem frmEdit = new FormFacturaEditItem(); try { if (itemNumero <= 0) { if (DataGridDetalle == null) { return; } if (DataGridDetalle.RowCount <= 0) { return; } index = DataGridDetalle.CurrentRow.Index; itemNumero = int.Parse(DataGridDetalle["ItemNumero", index].Value.ToString()); } fila0 = DTDetalle.Select("ItemNumero = " + itemNumero.ToString())[0]; tipo = objUtil.GetAsString("Tipo", fila0, "P"); if (tipo != "NC") { frmEdit.MyFila = fila0; frmEdit.ShowDialog(); if (frmEdit.lOK) { if (ActualizarDetalleFormRow(fila0, "ItemNumero")) { TotalizarDetalle(); } else { fila0.RejectChanges(); } } } } catch (Exception ex) { objUtil.MostrarMensajeError(ex.Message); } }
public override void TotalizarDetalle() { object calcObject; double totalDebito = 0; double totalCredito = 0; double diferencia = 0; try { //base.TotalizarDetalle(); calcObject = DTDetalle.Compute("Sum(Debito)", "itemNumero > 0"); if (calcObject != null) { if (calcObject.ToString().Trim() != "") { totalDebito = double.Parse(calcObject.ToString()); } } calcObject = DTDetalle.Compute("Sum(Credito)", "itemNumero > 0"); if (calcObject != null) { if (calcObject.ToString().Trim() != "") { totalCredito = double.Parse(calcObject.ToString()); } } diferencia = totalDebito - totalCredito; SetValorEncabezado("Monto", totalDebito); SetValorEncabezado("Total_Debito", totalDebito); SetValorEncabezado("Total_Credito", totalCredito); SetValorEncabezado("Diferencia", diferencia); lblTotalDebito.Text = totalDebito.ToString("N2"); lblTotalCredito.Text = totalCredito.ToString("N2"); lblDiferencia.Text = diferencia.ToString("N2"); } catch (Exception) { throw; } finally { calcObject = null; } }
private void dtgvDetalle_CellEndEdit(object sender, DataGridViewCellEventArgs e) { int index; string valorUnico = "0"; DataRow item = null; double cantidad, tasaItbis, precio; double itbis, subTotal, total; try { index = dtgvDetalle.CurrentRow.Index; valorUnico = dtgvDetalle["unico", index].Value.ToString(); item = DTDetalle.Select("Unico = " + valorUnico)[0]; cantidad = objUtil.GetAsDouble("Cantidad_ADevolver", item); tasaItbis = objUtil.GetAsDouble("Tasa_Itbis", item); precio = objUtil.GetAsDouble("Precio", item); //CALCULAMOS PRECIO SIN ITBIS tasaItbis = tasaItbis / 100.0; precio = precio / (1 + tasaItbis); subTotal = cantidad * precio; tasaItbis = objUtil.GetAsDouble("Tasa_Itbis", item); itbis = (subTotal * tasaItbis) / 100.0; total = subTotal + itbis; item["Cantidad_ADevolver"] = cantidad; item["Sub_Total"] = subTotal; item["Itbis"] = itbis; item["Total"] = total; //Actualizamos el Detalle ActualizarDetalleFormRow(item); TotalizarDetalle(); } catch (Exception ex) { objUtil.MostrarMensajeError(ex.Message); } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { int valorUnico = 0; DataRow myFila = null; FormPrestamosDescuentosR frm = new FormPrestamosDescuentosR(); try { this.Cursor = Cursors.WaitCursor; var senderGrid = (DataGridView)sender; if (senderGrid.Columns[e.ColumnIndex] is DataGridViewLinkColumn && e.RowIndex >= 0) { //TODO - Button Clicked - Execute Code Here valorUnico = int.Parse(senderGrid["unico", senderGrid.CurrentRow.Index].Value.ToString()); //BUSCO LA FILA SELECCIONADA POS SU UNICO myFila = DTDetalle.Select("Unico = " + valorUnico.ToString())[0]; frm.Fila = myFila; frm.ShowDialog(); if (frm.LOK) { TotalizarDetalle(); ActualizarDetalleFormRow(myFila); } } } catch (Exception ex) { objUtil.MostrarMensajeError(ex.Message); } finally { this.Cursor = Cursors.Default; } }
private void chkMarcarTodos_CheckedChanged(object sender, EventArgs e) { string valorUnico = "0"; DataRow fila0; try { for (int i = 0; i < dtgOpciones.RowCount; i++) { valorUnico = dtgOpciones["Unico", i].Value.ToString(); fila0 = DTDetalle.Select("Unico = " + valorUnico)[0]; if (fila0 != null) { fila0["EsAplicar"] = chkMarcarTodos.Checked; } } } catch (Exception ex) { objUtil.MostrarMensajeError(ex.Message); } }
private void txtTasa_TextChanged(object sender, EventArgs e) { double tasa = 0, plazo = 0; DataRow fila0 = null; try { if (DSDatos == null) { return; } if (DSDatos.Tables.Count <= 0) { return; } fila0 = DSDatos.Tables[0].Rows[0]; plazo = objDB.GetAsDouble("Plazo", fila0); tasa = objDB.GetAsDouble("Tasa_Interes", fila0); if (plazo != objUtil.ConvertirANumero(txtPlazo.Text) || tasa != objUtil.ConvertirANumero(txtTasa.Text)) { SetValorEncabezado("Plazo", plazo); SetValorEncabezado("Tasa_Interes", tasa); //Deshabilitamos el boton guardar para obligar a volver a generar btnGrabar.Enabled = false; //btnGenerar.Enabled = true; DTDetalle.Clear(); } } catch (Exception ex) { objUtil.MostrarMensajeError(ex.Message); } }
private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { string valorUnico = "0"; try { if (DTDetalle == null) { return; } if (DTDetalle.Rows.Count <= 0) { return; } if (dataGridView1.RowCount <= 0) { return; } if (e.ColumnIndex < 0) { return; } if (e.RowIndex < 0) { return; } valorUnico = dataGridView1["Unico", e.RowIndex].Value.ToString(); dataGridView1[e.ColumnIndex, e.RowIndex].Selected = true; fila0 = DTDetalle.Select("Unico = " + valorUnico)[0]; } catch (Exception) { } }
void Generar() { double monto = 0; double montoCuota = 0; double tasaAnual = 0; int plazo = 0; string tipoSaldo; string formaPago = "M"; string concepto = ""; DataRow MyFila; DateTime fecha; double saldoInicial = 0; double saldoFinal = 0; double interes = 0; double capital = 0; double tasa = 0; double total = 0.00; double totalCapital = 0; double diferencia = 0; double montoInicial = 0; int metodo = 0; double dias = 0; try { btnGrabar.Enabled = false; usaCliente0 = true; //VALIDAMOS QUE LA FECHA DE PRIMER PAGO SEA MAYOR A FECHA ACTUAL fecha = dtpFechaPrimerPago.Value.Date; metodo = cboMetodo.SelectedIndex; monto = objUtil.ConvertirANumero(txtMonto.Text); plazo = int.Parse(txtPlazo.Text); tasaAnual = double.Parse(txtTasa.Text); tipoSaldo = cboTipoSaldo.SelectedValue.ToString(); formaPago = cboFrecuenciaPago.SelectedValue.ToString(); if (monto <= 0) { objUtil.MostrarMensajeAdvertencia("Debe Indicar El Monto del Prestamo"); } else if (txtTasa.Text.Trim() == "") { objUtil.MostrarMensajeAdvertencia("Debe Indicar la Tasa de Interes"); } else if (txtPlazo.Text.Trim() == "") { objUtil.MostrarMensajeAdvertencia("Debe Indicar el Plazo o Cantidad de Cuota"); } else if (cboTipoSaldo.Text.Trim() == "") { objUtil.MostrarMensajeAdvertencia("Debe Indicar el tipo de Saldo"); } else if (cboFrecuenciaPago.Text.Trim() == "") { objUtil.MostrarMensajeAdvertencia("Debe Indicar La Frecuencia o Forma de Pago"); } else if (tasaMinima > 0 && tasaAnual < tasaMinima) { objUtil.MostrarMensajeError("La Tasa de Interes No Puede Ser Menor A: " + tasaMinima.ToString("N2")); } else { SetValorEncabezado("Monto_Aprobado", monto); SetValorEncabezado("Monto_Inicial", montoInicial); saldoInicial = monto; if (formaPago == "M") { dias = 30; } else if (formaPago == "T") { dias = 360; } else if (formaPago == "Q") { dias = 15; } else if (formaPago == "S") { dias = 7; } else if (formaPago == "D") { dias = 1; } if ((tasaAnual < 0) || (plazo <= 0)) { throw new Exception("Error La Tasa No Puede Ser Menor a Cero, Plazo o Cuota debe Ser Mayor a Cero"); } if (metodo > 0) { montoCuota = objPrestamo.GetCuota(monto, plazo, tasaAnual, "I"); tasa = (tasaAnual / 12.0) / 100.0; if (montoCuota == 0) { montoCuota = monto / plazo; } } else { interes = monto * (tasaAnual / 100.0) * (dias / 360); montoCuota = (monto / plazo) + interes; } //LIMPIAMOS EL DETALLE TEMPORAL LimpiarDetalleTemporal(); totalCapital = 0; diferencia = 0; for (int i = 1; i <= plazo; i++) { concepto = "CUOTA " + i.ToString() + " DE " + plazo.ToString(); MyFila = null; MyFila = DTDetalle.NewRow(); MyFila["ItemNumero"] = i; MyFila["Cuota_No"] = i; MyFila["Concepto"] = concepto; if (i > 1) { if (formaPago == "M") { fecha = fecha.AddMonths(1); } else if (formaPago == "T") { fecha = fecha.AddMonths(1); } else if (formaPago == "Q") { fecha = fecha.AddDays(15); } else if (formaPago == "S") { fecha = fecha.AddDays(7); } else if (formaPago == "D") { fecha = fecha.AddDays(1); } else { throw new Exception("Forma de Pago No Existe"); } } MyFila["Fecha"] = fecha; if (montoInicial > 0 && metodo > 0) { if (i == 1) { interes = (saldoInicial * (tasaAnual / 12.0)) / 100; capital = montoCuota - interes; } } else if (metodo > 0) { interes = saldoInicial * tasa; if (saldoInicial > montoCuota) { capital = montoCuota - interes; } else if (saldoInicial < montoCuota) { capital = saldoInicial; } else { capital = saldoInicial - interes; } } else { capital = monto / plazo; } totalCapital += capital; //VALIDAMOS QUE EL TOTAL DE CAPITAL = MONTO DEL PRESTAMO if ((i == plazo) && (montoInicial <= 0)) { diferencia = monto - totalCapital; if (diferencia > 0) { capital += diferencia; interes -= diferencia; } else { capital -= diferencia; interes += diferencia; } } MyFila["Saldo_Inicial"] = saldoInicial; MyFila["Capital"] = capital; MyFila["Interes"] = interes; MyFila["Monto"] = (capital + interes); if (saldoInicial > montoCuota) { saldoFinal = saldoInicial - capital; } else { saldoFinal = saldoInicial - (capital + interes); } if (saldoFinal < 0) { saldoFinal = 0; } MyFila["Saldo_Final"] = saldoFinal; saldoInicial = saldoFinal; AgregarLineaDetalle(MyFila); } capital = GetSumDetalle("Capital"); interes = GetSumDetalle("Interes"); total = capital + interes; lblTotalCapital.Text = capital.ToString("N2"); lblTotalInteres.Text = interes.ToString("N2"); lblTotal.Text = total.ToString("N2"); lblMontoCuota.Text = montoCuota.ToString("N2"); //GUARDAMOS DATOS DEL ENCABEZADO SetValorEncabezado("Tipo_Saldo", tipoSaldo); SetValorEncabezado("Tasa_Interes", tasaAnual); SetValorEncabezado("Frecuencia_Pago", formaPago); SetValorEncabezado("Plazo", plazo); SetValorEncabezado("Monto_Cuota", montoCuota); SetValorEncabezado("Monto_Prestamo", monto); SetValorEncabezado("Fecha_Termino", fecha); SetValorEncabezado("Fecha_Primer_Pago", dtpFechaPrimerPago.Value); PostEncabezadoTemp(); btnGrabar.Enabled = true; } } catch (Exception ex) { objUtil.MostrarMensajeError(ex.Message); } }
private void addItem() { DataRow MyFila; double precioLista = 0, precioSinItbis = 0, tasaItbis = 0, itbis = 0, cantidad = 1; double subTotal = 0, total = 0; bool esPrecioConItbis = true, esExcentoItbis = false, esOferta = false; string nivelPrecio = "R"; try { nivelPrecio = "R"; if (drCliente != null) { nivelPrecio = nivelPrecio = objUtil.GetAsString("Nivel_Precio", drCliente).ToUpper(); } ; cantidad = objUtil.ConvertirANumero(txtCantidad.Text); if (drProducto != null) { tasaItbis = objUtil.GetAsDouble("Tasa_Itbis", drProducto); if (nivelPrecio == "A") { precioLista = objUtil.GetAsDouble("PrecioA", drProducto); } else if (nivelPrecio == "B") { precioLista = objUtil.GetAsDouble("PrecioB", drProducto); } else if (nivelPrecio == "C") { precioLista = objUtil.GetAsDouble("PrecioC", drProducto); } if (nivelPrecio == "R" || precioLista <= 0) { precioLista = objUtil.GetAsDouble("PrecioR", drProducto); } esExcentoItbis = objUtil.GetAsBoolean("EsExcentoItbis", drProducto); esOferta = objUtil.GetAsBoolean("EsOferta", drProducto); if (esOferta) { precioLista = objUtil.GetAsDouble("PrecioO", drProducto); nivelPrecio = "O"; } precioSinItbis = precioLista; if (cantidad <= 0) { objUtil.MostrarMensajeAdvertencia("LA CANTIDAD DEBE SER MAYOR A CERO(0)"); txtCantidad.Focus(); return; } if (tipoNCF <= 0 || esExcentoItbis) { tasaItbis = 0; } //CALCULAMOS PRECIO SIN EL ITEBIS if (tasaItbis > 0) { precioSinItbis = Math.Round(precioLista / (1 + tasaItbis / 100.0), 2); itbis = precioLista - precioSinItbis; } subTotal = cantidad * precioSinItbis; itbis = cantidad * itbis; total = cantidad * precioLista; MyFila = DTDetalle.NewRow(); MyFila["Producto_Id"] = drProducto["Producto_Id"]; MyFila["Descripcion"] = drProducto["Nombre_Corto"]; MyFila["Categoria_Id"] = drProducto["Categoria_Id"]; MyFila["UMedida_Id"] = drProducto["UMedida_Id"]; MyFila["Cantidad"] = cantidad; MyFila["Precio_Sin_Itbis"] = Math.Round(precioSinItbis, 2); MyFila["Precio"] = Math.Round(precioLista, 2); MyFila["Sub_Total"] = Math.Round(subTotal, 2); MyFila["Descuento"] = 0; MyFila["Tasa_Itbis"] = Math.Round(tasaItbis, 2); MyFila["Itbis"] = Math.Round(itbis, 2); MyFila["Monto"] = Math.Round(total, 2); MyFila["EsOferta"] = esOferta; MyFila["Nivel_Precio"] = nivelPrecio; MyFila["EsExcentoItbis"] = esExcentoItbis; MyFila["PrecioConItbis"] = esPrecioConItbis; AgregarLineaDetalle(MyFila); txtBusquedaProducto.Text = ""; txtCantidad.Text = "1"; drProducto = null; txtBusquedaProducto.Focus(); } } catch (Exception ex) { lblMensajeError.Visible = true; lblMensajeError.Text = "ERROR: " + ex.Message; toolTip1.SetToolTip(lblMensajeError, lblMensajeError.Text); } finally { txtBusquedaProducto.Focus(); } }
public override int GrabarDatos() { //return base.GrabarDatos(); int resultado = 0, conteo = 0; DialogResult resp; List <DataDB_ELR_NET.Parametro> myParms = new List <DataDB_ELR_NET.Parametro>(); string valorUnico = "0"; string nombreSP = ""; bool esAplicar = false; DataRow fila0; int fechaDesde = 0, fechaHasta = 0; string SSQL = ""; int nErrores = 0; int tipoId = 0, conteo1, conteo2; try { fechaDesde = objUtil.DateToInt(dtpFechaDesde.Value); fechaHasta = objUtil.DateToInt(dtpFechaHasta.Value); temporalID = objUtil.GetTemporalID(); if (dtgOpciones.RowCount <= 0) { return(0); } resp = objUtil.MostrarMensajePregunta("Esta Seguro que Desea Generar Movimientos?"); if (resp != DialogResult.Yes) { return(0); } //Buscamos el total de asientos contables conteo1 = objDB.GetConteoAsientos(); for (int i = 0; i < dtgOpciones.RowCount; i++) { if (nErrores == 0) { valorUnico = dtgOpciones["Unico", i].Value.ToString(); esAplicar = (bool)dtgOpciones["EsAplicar", i].Value; if (esAplicar) { this.Cursor = Cursors.WaitCursor; conteo++; fila0 = DTDetalle.Select("Unico = " + valorUnico)[0]; nombreSP = objUtil.GetAsString("Nombre_SP", fila0); tipoId = objUtil.GetAsInt("Tipo_Id", fila0); myParms = new List <DataDB_ELR_NET.Parametro>(); myParms.Add(new DataDB_ELR_NET.Parametro("PFechaDesde", fechaDesde)); myParms.Add(new DataDB_ELR_NET.Parametro("PFechaHasta", fechaHasta)); myParms.Add(new DataDB_ELR_NET.Parametro("empresaId", EMPRESA_ID)); myParms.Add(new DataDB_ELR_NET.Parametro("autor", nombreUsuario)); myParms.Add(new DataDB_ELR_NET.Parametro("IdentificadorTemp", temporalID)); myParms.Add(new DataDB_ELR_NET.Parametro("TipoId", tipoId)); objDB.iniciarTransaccion(); resultado = objDB.EjecutarSP(nombreSP, myParms); if (resultado < 0) { nErrores++; MostrarErrorTemporal(); objDB.cancelarTransaccion(); break; } else { this.Cursor = Cursors.Default; objDB.confirmarTransaccion(); } } } } if ((resultado >= 0) && (conteo > 0)) { lOK = true; //Buscamos el total de asientos contables conteo2 = objDB.GetConteoAsientos(); objUtil.MostrarMensajeInformacion("SE HAN GENERADOS " + (conteo2 - conteo1).ToString("N0") + " ASIENTOS DE FORMA SATISFACTORIA"); if (DTMenu.Select("Formulario_AEjecutar = 'ELRContaGeneral.FormContaMovimientos'").Count() > 0) { ejecutaForm("ELRContaGeneral.FormContaMovimientos"); } if (cerrarAlGrabar) { Close(); } } } catch (Exception ex) { objDB.cancelarTransaccion(); objUtil.MostrarMensajeError(ex.Message); } finally { this.Cursor = Cursors.Default; } return(resultado); }
void GetCentroCosto(string codigo = "") { WinControl_ELR_NET.ELRFormBusquedaGeneral frm = new WinControl_ELR_NET.ELRFormBusquedaGeneral(); WinControl_ELR_NET.MyColumna col; DataTable DTData = null; DataRow fila0 = null; string SSQL = ""; int index = 0; string descripcionCuenta = "", descripcionAuxiliar = "", valorUnico = "0"; try { if (DTDetalle == null) { return; } if (DTDetalle.Rows.Count <= 0) { return; } if (codigo != "") { SSQL = "SELECT TOP 1 Codigo_Auxiliar, Descripcion FROM VCONTA_AUXILIARES "; SSQL += " WHERE Cast(Codigo_Auxiliar as Varchar) Like '" + codigo + "%' "; SSQL += " Order by Codigo_Auxiliar"; DTData = objDB.GetSQL(SSQL); if (DTData.Rows.Count > 0) { fila0 = DTData.Rows[0]; } } else { //Vamos a Buscar el Producto frm.titulo = @"OFICINA O CENTRO DE COSTO"; frm.TablaOVista = "VCONTA_AUXILIARES"; frm.FiltroEstatico = "Empresa_Id = " + EMPRESA_ID.ToString() + " And EsActivo = 1"; frm.columnas = new WinControl_ELR_NET.MyColumna[2]; frm.CondicionOrderBY = "Codigo_Auxiliar"; col = new WinControl_ELR_NET.MyColumna(); col.NombreCampo = "Codigo_Auxiliar"; col.HeaderText = "Codigo"; col.Ancho = 140; frm.columnas[0] = col; col = new WinControl_ELR_NET.MyColumna(); col.NombreCampo = "Descripcion"; col.HeaderText = "Descripcion"; col.Ancho = -1; frm.columnas[1] = col; frm.DefaultColumnaBusqueda = "Descripcion"; frm.ShowDialog(); if (frm.FilaSelecionada != null) { fila0 = frm.FilaSelecionada; } } if (fila0 != null) { codigoAuxiliar = objUtil.GetAsInt("Codigo_Auxiliar", fila0); descripcionAuxiliar = objUtil.GetAsString("Descripcion", fila0); index = DataGridDetalle.CurrentRow.Index; valorUnico = DataGridDetalle["ItemNumero", index].Value.ToString(); fila0 = DTDetalle.Select("ItemNumero = " + valorUnico)[0]; descripcionCuenta = objUtil.GetAsString("Descripcion_Cuenta", fila0); fila0["Codigo_Auxiliar"] = codigoAuxiliar; fila0["Descripcion"] = descripcionCuenta + ", " + descripcionAuxiliar; DataGridDetalle.Refresh(); DataGridDetalle["Cuenta_Contable", index].Selected = true; DataGridDetalle.CurrentCell = DataGridDetalle["Total", index]; DataGridDetalle.BeginEdit(false); } } catch (Exception ex) { objUtil.MostrarMensajeError(ex.Message); } finally { frm.Dispose(); } }
private void btnCargarArchivoCliente_Click(object sender, EventArgs e) { StreamReader streamDatos; string linea = null; string codigoCliente = ""; string nombreCliente = ""; string municipio = ""; string tipo = "", factura = "", sFecha, recibo, sValor, origen, concepto = ""; int anio, mes, dia; string[] AFecha; DateTime fecha; DataRow dr; OpenFileDialog ofdArchivoCliente = new OpenFileDialog(); string nombreArchivo = ""; int index = 0; int conteo = 0; int carACopiar = 0, longitudActual = 0, posActual = 0; try { string directorioActual = ""; directorioActual = System.Environment.CurrentDirectory; if (Directory.Exists(directorioActual)) { ofdArchivoCliente.InitialDirectory = directorioActual; } LimpiarDetalleTemporal(); this.Cursor = Cursors.WaitCursor; ofdArchivoCliente.Filter = "txt files (*.txt)|*.txt"; if (ofdArchivoCliente.ShowDialog() == System.Windows.Forms.DialogResult.OK) { //Verificamos si el archivo existe en el directori actual nombreArchivo = ofdArchivoCliente.SafeFileName; nombreArchivo = directorioActual + @"\" + nombreArchivo; if (nombreArchivo.ToUpper() != ofdArchivoCliente.FileName.ToUpper()) { if (File.Exists(nombreArchivo)) { File.Delete(nombreArchivo); } File.Copy(ofdArchivoCliente.FileName, nombreArchivo); } ofdArchivoCliente.FileName = nombreArchivo; streamDatos = new StreamReader(nombreArchivo); while ((linea = streamDatos.ReadLine()) != null) { conteo++; linea = linea.Trim(); tipo = ""; factura = ""; sFecha = ""; recibo = ""; sValor = "0.00"; origen = "DR"; concepto = ""; fecha = DateTime.Now.Date; if (linea == "") { continue; } if (conteo == 6) { codigoCliente = linea.Substring(0, 7); nombreCliente = linea.Substring(7, linea.Length - 7); txtCodigo.Text = codigoCliente; txtNombres.Text = nombreCliente; continue; } //Buscamos el Municipio if (conteo == 8) { municipio = linea; txtMunicipio.Text = municipio; continue; } if (conteo == 7) { municipio = linea; continue; } if (linea.Contains("-----")) { continue; } if (linea.Contains("TIPO FACTURA")) { continue; } tipo = linea.Substring(0, 2).ToUpper(); if ((tipo == "FT") || (tipo == "ND") || (tipo == "NC") || (tipo == "RC")) { factura = linea.Substring(2, 12).Trim(); recibo = linea.Substring(14, 8).Trim(); sFecha = linea.Substring(22, 11).Trim(); sValor = linea.Substring(33, 13).Trim(); longitudActual = 47; posActual = 46; if (linea.Length > longitudActual) { origen = linea.Substring(posActual, 2).Trim(); if (origen.Trim() != "") { longitudActual = 49; posActual = 48; } } if (origen.Trim() == "") { origen = "DR"; } //Buscamos el Concepto carACopiar = linea.Length - longitudActual; if (carACopiar > 0) { concepto = linea.Substring(posActual, carACopiar + 1).Trim(); } //Vamos a Buscar la Fecha if (sFecha.Trim() != "") { AFecha = sFecha.Split('/'); dia = int.Parse(AFecha[0]); mes = int.Parse(AFecha[1]); anio = int.Parse(AFecha[2]); fecha = new DateTime(anio, mes, dia); } dr = DTDetalle.NewRow(); dr["tipo"] = tipo; dr["Factura"] = factura; dr["Recibo_No"] = recibo; dr["Fecha"] = fecha; dr["valor"] = objUtil.ConvertirANumero(sValor); dr["Origen"] = origen; dr["Concepto"] = concepto; AgregarLineaDetalle(dr); } } //ELIMINAMOS EL ARCHIVO try { streamDatos.Dispose(); if (File.Exists(nombreArchivo)) { File.Delete(nombreArchivo); } } catch (Exception) { } } } catch (Exception ex) { objUtil.MostrarMensajeError(ex.Message); } finally { this.Cursor = Cursors.Default; ofdArchivoCliente.Dispose(); } }
private void AddItem() { DataRow MyFila; double precioLista, precioSinItbis, tasaItbis, itbis = 0, cantidad = 1; double subTotal = 0, total = 0; bool esPrecioConItbis = true, esExcentoItbis = false; try { cantidad = objUtil.ConvertirANumero(txtCantidad.Text); precioLista = objUtil.ConvertirANumero(txtPrecio.Text); precioSinItbis = precioLista; itbis = 0; if (drProducto != null) { tasaItbis = objUtil.GetAsDouble("Tasa_Itbis", drProducto); esExcentoItbis = objUtil.GetAsBoolean("EsExcentoItbis", drProducto); if (esExcentoItbis) { tasaItbis = 0; } if (cantidad <= 0) { objUtil.MostrarMensajeAdvertencia("LA CANTIDAD DEBE SER MAYOR A CERO(0)"); txtCantidad.Focus(); return; } //CALCULAMOS PRECIO SIN EL ITEBIS if (tasaItbis > 0) { precioSinItbis = Math.Round(precioSinItbis / (1 + tasaItbis / 100.0), 2); itbis = precioLista - precioSinItbis; } subTotal = cantidad * precioSinItbis; itbis = cantidad * itbis; total = cantidad * precioLista; MyFila = DTDetalle.NewRow(); MyFila["Producto_Id"] = drProducto["Producto_Id"]; MyFila["Descripcion"] = drProducto["Nombre_Corto"]; MyFila["Categoria_Id"] = drProducto["Categoria_Id"]; MyFila["UMedida_Id"] = drProducto["UMedida_Id"]; MyFila["Cantidad"] = cantidad; MyFila["Precio"] = Math.Round(precioLista, 2); MyFila["Sub_Total"] = Math.Round(subTotal, 2); MyFila["Descuento"] = 0; MyFila["Tasa_Itbis"] = Math.Round(tasaItbis, 2); MyFila["Itbis"] = Math.Round(itbis, 2); MyFila["Total"] = Math.Round(total, 2); MyFila["EsExcentoItbis"] = esExcentoItbis; MyFila["PrecioConItbis"] = esPrecioConItbis; AgregarLineaDetalle(MyFila, "Identificador_Id"); txtCodigoProducto.Text = ""; txtCantidad.Text = "1"; txtPrecio.Text = "0.00"; drProducto = null; btnAgregarItem.Enabled = false; lblProdDescripcion.BackColor = SystemColors.Control; lblProdDescripcion.Text = @"NOMBRE/DESCRIPCION ITEM VENTA"; txtCodigoProducto.Focus(); } } catch (Exception ex) { lblProdDescripcion.Text = "ERROR: " + ex.Message; lblProdDescripcion.BackColor = Color.Red; } }
private void AgregarProducto() { DataRow MyFila; double precioLista, precioSinItbis, tasaItbis, itbis = 0, cantidad = 1, gramos = 0; double subTotal = 0, total = 0, precioMinimo = 0; bool esPrecioConItbis = true, esExcentoItbis = false, esOferta = false, continuar = true; string nivelPrecio = "R"; try { nivelPrecio = "R"; cantidad = objUtil.ConvertirANumero(txtCantidad.Text); continuar = true; precioLista = objUtil.ConvertirANumero(txtPrecio.Text); precioSinItbis = precioLista; itbis = 0; if (cboTipoNCF.SelectedValue == null) { tipoNCF = 0; } else { tipoNCF = int.Parse(cboTipoNCF.SelectedValue.ToString()); } if (drProducto != null) { tasaItbis = objUtil.GetAsDouble("Tasa_Itbis", drProducto); precioMinimo = objUtil.GetAsDouble("PrecioM", drProducto); esExcentoItbis = objUtil.GetAsBoolean("EsExcentoItbis", drProducto); esOferta = objUtil.GetAsBoolean("EsOferta", drProducto); if (esOferta) { precioMinimo = objUtil.GetAsDouble("PrecioO", drProducto); nivelPrecio = "O"; } //VALIDAMOS EL PRECIO NO SEA MENOR O IGUAL A CERO NI MENOR AL PRECIO MINIMO if (precioLista <= 0 || precioLista < precioMinimo) { objUtil.MostrarMensajeAdvertencia("EL PRECIO NO PUEDE SER MENOR AL PRECIO MINIMO: " + precioMinimo.ToString("N2")); txtPrecio.Focus(); return; } if (cantidad <= 0) { objUtil.MostrarMensajeAdvertencia("LA CANTIDAD DEBE SER MAYOR A CERO(0)"); txtCantidad.Focus(); return; } if (tipoNCF <= 0 || esExcentoItbis) { tasaItbis = 0; } //CALCULAMOS PRECIO SIN EL ITEBIS if (tasaItbis > 0) { precioSinItbis = Math.Round(precioSinItbis / (1 + tasaItbis / 100.0), 2); itbis = precioLista - precioSinItbis; } subTotal = cantidad * precioSinItbis; itbis = cantidad * itbis; total = cantidad * precioLista; MyFila = DTDetalle.NewRow(); MyFila["Producto_Id"] = drProducto["Producto_Id"]; MyFila["Descripcion"] = drProducto["Nombre_Corto"]; MyFila["Categoria_Id"] = drProducto["Categoria_Id"]; MyFila["UMedida_Id"] = drProducto["UMedida_Id"]; MyFila["Cantidad"] = cantidad; MyFila["Precio_Sin_Itbis"] = Math.Round(precioSinItbis, 2); MyFila["Precio"] = Math.Round(precioLista, 2); MyFila["Sub_Total"] = Math.Round(subTotal, 2); MyFila["Descuento"] = 0; MyFila["Tasa_Itbis"] = Math.Round(tasaItbis, 2); MyFila["Itbis"] = Math.Round(itbis, 2); MyFila["Monto"] = Math.Round(total, 2); MyFila["EsOferta"] = esOferta; MyFila["Nivel_Precio"] = nivelPrecio; MyFila["EsExcentoItbis"] = esExcentoItbis; MyFila["PrecioConItbis"] = esPrecioConItbis; AgregarLineaDetalle(MyFila); txtCodigo.Text = ""; txtCantidad.Text = "1"; txtPrecio.Text = "0.00"; drProducto = null; btnAgregarItem.Enabled = false; lblProdDescripcion.BackColor = SystemColors.Control; lblProdDescripcion.Text = @"NOMBRE/DESCRIPCION ITEM VENTA"; txtCodigo.Focus(); } } catch (Exception ex) { lblProdDescripcion.Text = "ERROR: " + ex.Message; lblProdDescripcion.BackColor = Color.Red; } }
void CalcularMontoPrestamo() { double monto = 0, costoLeg = 0, residuo; double montoAprobado = 0; int opcionLegal = 0; try { monto = objUtil.ConvertirANumero(txtMonto.Text); montoAprobado = objUtil.ConvertirANumero(txtMonto.Text); if (cboOpcionLegal.Text.Trim() != "") { if (facturaNo <= 0) { opcionLegal = cboOpcionLegal.SelectedIndex; } } if (sysMontoLeg > 0) { costoLeg = sysMontoLeg; } else { costoLeg = (monto * sysPorcLeg) / 100.0; } //REDONDEAMOS EL COSTO DE LA LEGALIZACION if (esRedondear) { costoLeg = Math.Ceiling(costoLeg); residuo = costoLeg % 100; if (residuo < 50 && residuo != 0) { costoLeg += (50 - residuo); } else if (residuo < 100 && residuo != 0) { costoLeg += (100 - residuo); } } if (opcionLegal == 0) { monto += costoLeg; } lblCostoLegal.Text = costoLeg.ToString("N2"); lblMontoPrestamo.Text = monto.ToString("N2"); lblMontoCuota.Text = "0.00"; btnGrabar.Enabled = false; DTDetalle.Clear(); //btnGenerar.Enabled = true; SetValorEncabezado("Monto_Aprobado", montoAprobado); SetValorEncabezado("Monto_Prestamo", monto); SetValorEncabezado("Costo_Legalizacion", costoLeg); SetValorEncabezado("Opcion_Legal", opcionLegal); if (opcionLegal <= 0) { SetValorEncabezado("Descontar_Legalizacion", false); } else { SetValorEncabezado("Descontar_Legalizacion", true); } } catch (Exception) { throw; } }
void aplicarNotaCredito() { FormFacturaAplicarDevolucion frm = new FormFacturaAplicarDevolucion(); double monto = 0, itbis = 0, subtotal = 0; int codigo = 0; string concepto = ""; DataRow MyFila; try { frm.esPorEntidad = NOTA_CREDITO_POR_ENTIDAD; frm.entidadId = 0; frm.ShowDialog(); if (frm.lOK) { monto = Math.Abs(frm.monto) * -1; itbis = Math.Abs(frm.itbis) * -1; subtotal = (Math.Abs(frm.monto) - Math.Abs(frm.itbis)) * -1; codigo = frm.Id; concepto = frm.concepto.Trim(); if (concepto == "") { concepto = "DEVOLUCION DE PRODUCTOS Y/O SERVICIOS"; } concepto = "NC " + frm.concepto.Trim(); //Validamos no exista ya dicha nota de credito if (DTDetalle.Select("Producto_Id = " + codigo.ToString() + " AND Tipo = 'NC' ").Count() > 0) { objUtil.MostrarMensajeError("ESTA NOTA DE CREDITO YA FUE AGREGADA"); return; } //Agregamos al Detalle si no existe la Nota de Credito Ya Aplicada MyFila = DTDetalle.NewRow(); MyFila["Producto_Id"] = codigo; MyFila["Descripcion"] = concepto; MyFila["Categoria_Id"] = 0; MyFila["UMedida_Id"] = 0; MyFila["Cantidad"] = 1; MyFila["Precio_Sin_Itbis"] = 0; MyFila["Precio"] = monto; MyFila["Sub_Total"] = subtotal; MyFila["Descuento"] = 0; MyFila["Tasa_Itbis"] = 0; MyFila["Itbis"] = itbis; MyFila["Monto"] = monto; MyFila["EsOferta"] = 0; MyFila["Nivel_Precio"] = "R"; MyFila["EsExcentoItbis"] = false; MyFila["PrecioConItbis"] = false; MyFila["Tipo"] = "NC"; AgregarLineaDetalle(MyFila); TotalizarDetalle(); } } catch (Exception ex) { objUtil.MostrarMensajeError(ex.Message); } finally { frm.Dispose(); } }
void Generar() { double monto = 0; double montoCuota = 0; double tasaAnual = 0; int plazo = 0, diaAPagar = 0, conteo = 0; string formaPago = "M", tipoSaldo = "I", SSQL = ""; double totalCapital = 0, totalInteres = 0; DataTable DTData = null; DataRow MyFila = null; DateTime fechaIni = DateTime.Now; DateTime fechaFinal = DateTime.Now; try { btnGrabar.Enabled = false; usaCliente0 = true; if (cboTipoSaldo.SelectedValue != null) { tipoSaldo = cboTipoSaldo.SelectedValue.ToString(); } int.TryParse(txtPlazo.Text, out plazo); tasaAnual = double.Parse(txtTasa.Text); monto = double.Parse(lblMontoPrestamo.Text); diaAPagar = (int)nudDiaAPagar.Value; if (cboFrecuenciaPago.SelectedValue != null) { formaPago = cboFrecuenciaPago.SelectedValue.ToString(); } if (monto <= 0) { objUtil.MostrarMensajeAdvertencia("Debe Indicar El Monto del Prestamo"); } else if (tasaAnual <= 0) { objUtil.MostrarMensajeAdvertencia("Debe Indicar la Tasa de Interes"); } else if (plazo <= 0) { objUtil.MostrarMensajeAdvertencia("Debe Indicar el Plazo o Cantidad de Cuota"); } else if (cboFrecuenciaPago.Text.Trim() == "") { objUtil.MostrarMensajeAdvertencia("Debe Indicar La Frecuencia o Forma de Pago"); } else { SetValorEncabezado("Monto_Prestamo", monto); SetValorEncabezado("Dia_APagar", diaAPagar); //GENERAMOS LA TABLA DE AMORTIZACION SSQL = "select * from dbo.FN_TABLA_AMORTIZACION("; SSQL += monto.ToString() + ", "; SSQL += tasaAnual.ToString() + ", "; SSQL += plazo.ToString() + ", "; SSQL += "'" + formaPago.Trim() + "', "; SSQL += "NULL, "; SSQL += diaAPagar.ToString(); SSQL += ")"; DTData = objDB.GetSQL(SSQL); //LIMPIAMOS EL DETALLE TEMPORAL LimpiarDetalleTemporal(); foreach (DataRow item in DTData.Rows) { if (conteo <= 0) { montoCuota = objDB.GetAsDouble("Cuota", item); fechaIni = objDB.GetAsDate("Fecha", item); } fechaFinal = objDB.GetAsDate("Fecha", item); MyFila = null; MyFila = DTDetalle.NewRow(); MyFila["ItemNumero"] = conteo + 1; MyFila["Cuota_No"] = objDB.GetAsInt("Id", item); MyFila["Concepto"] = objDB.GetAsString("Concepto", item); MyFila["Fecha"] = objDB.GetAsDate("Fecha", item); MyFila["Saldo_Inicial"] = objDB.GetAsDouble("CapitalIni", item); MyFila["Capital"] = objDB.GetAsDouble("Capital", item); MyFila["Interes"] = objDB.GetAsDouble("Interes", item); MyFila["Monto"] = (objDB.GetAsDouble("Capital", item) + objDB.GetAsDouble("Interes", item)); MyFila["Saldo_Final"] = objDB.GetAsDouble("Saldo", item); totalCapital += objDB.GetAsDouble("Capital", item); totalInteres += objDB.GetAsDouble("Interes", item); AgregarLineaDetalle(MyFila); conteo++; } lblTotalDetalle.Text = "Capital: " + totalCapital.ToString("N2") + " "; lblTotalDetalle.Text += "Interes: " + totalInteres.ToString("N2"); lblTotalDetalle.Text += " Cuota de: " + montoCuota.ToString("N2"); lblMontoCuota.Text = montoCuota.ToString("N2"); //GUARDAMOS DATOS DEL ENCABEZADO SetValorEncabezado("Tipo_Saldo", tipoSaldo); SetValorEncabezado("Tasa_Interes", tasaAnual); SetValorEncabezado("Frecuencia_Pago", formaPago); SetValorEncabezado("Plazo", plazo); SetValorEncabezado("Monto_Cuota", montoCuota); SetValorEncabezado("Monto_Prestamo", monto); SetValorEncabezado("Fecha_Termino", fechaFinal); SetValorEncabezado("Fecha_Primer_Pago", fechaIni); PostEncabezadoTemp(); //btnGenerar.Focus(); btnGrabar.Enabled = true; } } catch (Exception ex) { objUtil.MostrarMensajeError(ex.Message); } }
private void AplicarPermisos(object sender, EventArgs e) { ToolStripMenuItem mnuItem; bool esConsulta = false; bool esInsertar = false; bool esModificar = false; bool esCambiar_Fecha = false; bool esAnular = false; bool esAprobar = false; bool esRechazar = false; bool esGenerar = false; bool esImprimir = false; string valorUnico = "0"; try { if (fila0 == null) { return; } this.Cursor = Cursors.WaitCursor; mnuItem = (ToolStripMenuItem)sender; if ((mnuItem == tsmAplicarFila) || (mnuItem == tsmAplicarTodos)) { esConsulta = true; esInsertar = true; esModificar = true; esCambiar_Fecha = true; esAnular = true; esAprobar = true; esRechazar = true; esGenerar = true; esImprimir = true; } if ((mnuItem == tsmAplicarFila) || (mnuItem == tsmQuitarFila)) { fila0["EsActivo"] = esConsulta; fila0["EsConsulta"] = esConsulta; fila0["esInsertar"] = esInsertar; fila0["esModificar"] = esModificar; fila0["esCambiar_Fecha"] = esCambiar_Fecha; fila0["esAnular"] = esAnular; fila0["esAprobar"] = esAprobar; fila0["esRechazar"] = esRechazar; fila0["esGenerar"] = esGenerar; if (DataGridDetalle.Columns.Contains("EsImprimir")) { fila0["EsImprimir"] = esImprimir; } } else { for (int i = 0; i < DataGridDetalle.RowCount; i++) { valorUnico = DataGridDetalle["Unico", i].Value.ToString(); fila0 = DTDetalle.Select("Unico = " + valorUnico)[0]; fila0["EsActivo"] = esConsulta; fila0["EsConsulta"] = esConsulta; fila0["esInsertar"] = esInsertar; fila0["esModificar"] = esModificar; fila0["esCambiar_Fecha"] = esCambiar_Fecha; fila0["esAnular"] = esAnular; fila0["esAprobar"] = esAprobar; fila0["esRechazar"] = esRechazar; fila0["esGenerar"] = esGenerar; if (DataGridDetalle.Columns.Contains("EsImprimir")) { fila0["EsImprimir"] = esImprimir; } } } } catch (Exception ex) { objUtil.MostrarMensajeError(ex.Message); } finally { this.Cursor = Cursors.Default; } }