private void cargar() { dataListado.DataSource = NTransporte.Mostrar(); if (dataListado.Rows.Count > 0) { ocultarColumnas(); mostrarTotales(); } }
private void btnGuardar_Click(object sender, EventArgs e) { decimal viaticos = 00.00m, peaje = 00.00m, combustible = 00.00m, mantenimiento = 00.00m, otrosGastos = 00.00m, adelanto = 00.00m, saldo = 00.00m, total = 00.00m; if (txtViatico.Text.Trim().Length == 0) { viaticos = 00.00m; } else { viaticos = Convert.ToDecimal(txtViatico.Text.Trim()); } if (txtPeaje.Text.Trim().Length == 0) { peaje = 00.00m; } else { peaje = Convert.ToDecimal(txtPeaje.Text.Trim()); } if (txtCombustible.Text.Trim().Length == 0) { combustible = 00.00m; } else { combustible = Convert.ToDecimal(txtCombustible.Text.Trim()); } if (txtMantenimiento.Text.Trim().Length == 0) { mantenimiento = 00.00m; } else { mantenimiento = Convert.ToDecimal(txtMantenimiento.Text.Trim()); } if (txtOtrosGastos.Text.Trim().Length == 0) { otrosGastos = 00.00m; } else { otrosGastos = Convert.ToDecimal(txtOtrosGastos.Text.Trim()); } if (txtAdelanto.Text.Trim().Length == 0) { adelanto = 00.00m; } else { adelanto = Convert.ToDecimal(txtAdelanto.Text.Trim()); } if (txtSaldo.Text.Trim().Length == 0) { saldo = 00.00m; } else { saldo = Convert.ToDecimal(txtSaldo.Text.Trim()); } total = viaticos + peaje + combustible + mantenimiento + otrosGastos; string rpta = "", estado = ""; int? idPersona = null; if (cbProducto.SelectedIndex == -1) { idPersona = null; } else { idPersona = Convert.ToInt32(cbProducto.SelectedValue.ToString()); } if (cbFormaPago.SelectedIndex == -1) { MessageBox.Show("Seleccione una forma de Pago"); } else { string tipoMonto = ""; if (cbFormaPago.SelectedIndex == 0) { estado = "CANCELADO"; tipoMonto = "EFECTIVO"; } else { estado = "CREDITO-PENDIENTE"; tipoMonto = "EFECTIVO"; } rpta = NTransporte.Insertar(idPersona, dtFechaSalida.Value, dtFechaLlegada.Value, viaticos, peaje, mantenimiento, combustible, otrosGastos, cbFormaPago.Text, adelanto, saldo, estado, 00.00m); if (rpta == "OK") { if (adelanto > 0 && cbFormaPago.SelectedIndex == 1) { rpta = NCaja.Insertar(Convert.ToInt32(frmPrincipal.f1.lblIdUsuario.Text), "2", "EGRESO", adelanto, "PAGO TRANSPORTE", tipoMonto); } else if (adelanto <= 0 && cbFormaPago.SelectedIndex == 0) { rpta = NCaja.Insertar(Convert.ToInt32(frmPrincipal.f1.lblIdUsuario.Text), "2", "EGRESO", total, "PAGO TRANSPORTE", tipoMonto); } if (rpta == "OK") { MessageBox.Show("Se registró correctamente"); this.Close(); } } } }