コード例 #1
0
        private List <Detalle> obtenerCreditos()
        {
            List <Detalle> lista = null;

            try
            {
                //Obteniendo todos las
                lista = DetalleController.listar(-1).Where(x => x.TipoTransaccion == 2 && x.Activo).ToList();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error durante la obtencion de la informacion", ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(lista);
        }
コード例 #2
0
        private void verDetallesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //Obteniendo el indice seleccionado
            int id_detalle = (int)dgvCreditos.SelectedRows[0].Cells[1].Value;
            var detalle    = DetalleController.leer(id_detalle);

            if (detalle != null)
            {
                var form = new Lista_Abonos(detalle);
                form.ShowDialog();
            }
            else
            {
                MessageBox.Show("No se ha localizado dicha factura!", "Error durante la busqueada", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #3
0
 private void imprimirFacturaToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         int     codigo   = (int)dgvEgresos.SelectedRows[0].Cells[0].Value;
         var     transacc = TransaccionController.leer(codigo);
         var     det      = DetalleController.listar(codigo);
         string  cajero   = UsuariosController.leer(transacc.Id_usuario).ToString();
         decimal ingreso  = det.Where(x => x.TipoTransaccion == 1).Sum(y => y.Cantidad);
         decimal egreso   = det.Where(x => x.TipoTransaccion == 0).Sum(y => y.Cantidad);
         decimal total    = ingreso - egreso;
         Form    ticket   = new Reportes.ImprimirFactura(codigo, cajero, transacc.Vehiculo.Placa, dtFechaFiltro.Value);
         ticket.ShowDialog();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
コード例 #4
0
 public Detalle()
 {
     InitializeComponent();
     DetalleController vista = new DetalleController(this);
 }
コード例 #5
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (CombosValidos())
            {
                var confirmacion = MessageBox.Show("Guardar Factura?", "Los Cambios no se pueden deshacer!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (confirmacion.Equals(DialogResult.Yes))
                {
                    try
                    {
                        //Obtiendo el encabezado de la transaccion
                        int      id_cajero   = MainContainer.sesion.Personas.Id_persona;
                        int      id_vehiculo = ((Vehiculo)cboVehiculo.SelectedItem).Id_Vehiculo;
                        DateTime Fecha       = dtFecha.Value.Date;
                        //Insertando la transaccion
                        int i = TransaccionController.agregar(id_cajero, id_vehiculo, Fecha, true);
                        //Si la transaccion tuvo exito
                        if (i > 0)
                        {
                            int t = 0;
                            //Obtiendo el utimo id de la transaccion
                            int     idTransaccion = TransaccionController.getUltima().IdTransaccion;
                            decimal ing           = 0;
                            decimal eg            = 0;
                            for (int j = 0; j < dgvEgresos.Rows.Count; j++)
                            {
                                int    TipoDetalle   = (int)dgvEgresos.Rows[j].Cells[0].Value;
                                string Descripcion   = (string)dgvEgresos.Rows[j].Cells[2].Value;
                                string tipo          = dgvEgresos.Rows[j].Cells[3].Value.ToString();
                                int    tpTransaccion = 0; //Egreso
                                if (tipo.Equals("INGRESO"))
                                {
                                    tpTransaccion = 1;
                                }
                                else if (tipo.Equals("CREDITO"))
                                {
                                    tpTransaccion = 2;
                                }

                                decimal monto = (decimal)dgvEgresos.Rows[j].Cells[4].Value;

                                t = DetalleController.agregar(idTransaccion, TipoDetalle, Descripcion, monto, tpTransaccion, true);
                                float dec = Convert.ToSingle(monto);

                                if (tipo == "INGRESO")
                                {
                                    ing += monto;
                                }

                                else if (tipo.Equals("EGRESO"))
                                {
                                    eg += monto;
                                }
                                totalFactura = 0;
                            }
                            if (t == 0) //Si no se registraron transacciones
                            {
                                throw new Exception("No se registraron las transacciones de Entrada/Salida!");
                            }
                            else
                            {
                                decimal total = ing - eg;
                                MessageBox.Show("Se ha insertado la transacion", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                ImprimirTicket(idTransaccion, MainContainer.sesion.ToString(), ((Vehiculo)cboVehiculo.SelectedItem).Placa, total, ing, eg);
                                LimpiarControles();
                            }
                        }
                        else
                        {
                            throw new Exception("No se pudo insertar la transaccion");
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Error!!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            else
            {
                MessageBox.Show("Todos los campos son requeridos!", "Faltan campos por completar", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #6
0
        private void dgDatos_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            var abonos = new Lista_Abonos(DetalleController.leer((int)dgDatos.SelectedRows[0].Cells[1].Value));

            abonos.ShowDialog();
        }
コード例 #7
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            //Validar Selecciones
            bool txts, cbos;

            txts = TextosValidos();
            cbos = CombosValidos();
            //fechas = FechasValidas();
            if (txts && cbos)
            {
                try
                {
                    //Obtencion de la informacion para registrar una carrera
                    int      id_cajero    = MainContainer.sesion.Personas.Id_persona;
                    int      id_conductor = ((Conductor)cboConductor.SelectedItem).Id_conductor;
                    int      id_vehiculo  = ((Vehiculo)cboVehiculo.SelectedItem).Id_Vehiculo;
                    DateTime Fecha        = dtFecha.Value.Date;
                    TimeSpan salida       = dtSalida.Value.TimeOfDay;
                    TimeSpan llegada      = dtLlegada.Value.TimeOfDay;
                    bool     vuelta       = cbVueltaCompleta.Checked;
                    //Agregando Transaccion
                    int t = TransaccionController.agregar(id_cajero, id_vehiculo, Fecha, true);
                    //Comprobamos que se haya insertado la transaccion
                    if (t > 0)
                    {
                        //Obtenemos el id de la ultima transaccion
                        int idTransaccion = TransaccionController.getUltima().IdTransaccion;
                        t = CarreraController.Agregar(idTransaccion, id_vehiculo, id_conductor, salida, llegada, Fecha, vuelta);
                        //Si se inserto correctamente la carrera, procedemos a ingresar los gastos
                        if (t > 0)
                        {
                            t = 0;
                            decimal ingreso = Decimal.Parse(QuitarEspacios(txtIngreso.Text));
                            //Registrando Ingreso
                            t = DetalleController.agregar(idTransaccion, TipoDetalleController.leer("CICLO").IdTipoDetalle, "CICLO", ingreso, 0, true);
                            //Verificando y registrando los egresos
                            decimal totalEgreso = 0;
                            if (dgvEgresos.Rows.Count > 0) // Si hay egresos
                            {
                                for (int j = 0; j < dgvEgresos.RowCount; j++)
                                {
                                    int     id_egreso   = (int)dgvEgresos.Rows[j].Cells[0].Value;
                                    string  descripcion = dgvEgresos.Rows[j].Cells[2].Value.ToString();
                                    decimal monto       = (decimal)dgvEgresos.Rows[j].Cells[3].Value;
                                    totalEgreso += monto;
                                    t           += DetalleController.agregar(idTransaccion, id_egreso, descripcion, monto, 1, true);
                                }
                            }
                            if (t == 0) //Si no se registraron transacciones
                            {
                                throw new Exception("No se registraron las transacciones de Entrada/Salida!");
                            }
                            //Se imprime la factura
                            else
                            {
                                var result = MessageBox.Show("Imprimir factura?", "Confirme Impresion", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                                if (result.Equals(DialogResult.Yes))
                                {
                                    var ultima = CarreraController.getUltima();
                                    //var cond = ConductorController.leer(ultima.Id_conductor);
                                    //Creando instancia de reporte
                                    TicketFisicoForm ticket = new TicketFisicoForm(
                                        CapaControlador.TransaccionController.getUltima().IdTransaccion,
                                        ultima.FechaCarrera.ToShortDateString(),
                                        MainContainer.sesion.ToString(),
                                        ultima.Vehiculo.Placa,
                                        ultima.Vehiculo.Socio.ToString(),
                                        cboConductor.SelectedItem.ToString(),
                                        ingreso,
                                        totalEgreso,
                                        (ingreso - totalEgreso)
                                        );
                                    ticket.ShowDialog();
                                }
                                limpiarControles();
                                actualizarNoFactura();
                            }
                        }
                        else
                        {
                            throw new Exception("No se Completo el registro de la carrera");
                        }
                    }
                    else
                    {
                        throw new Exception("No se Ingreso la carrera");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error!!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Todos los campos son requeridos!", "Faltan campos por completar", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }