Example #1
0
 // when imprimir button is clicked.
 private void btnImprimir_Click(object sender, EventArgs e)
 {
     try
     {
         if (rbDivorcioAccidente.Checked == true)
         {
             if (dgvFacturas.SelectedRows.Count == 1)
             {
                 frmFacturaDivorciosAccidente pFactura = new frmFacturaDivorciosAccidente();
                 pFactura.getID = Convert.ToInt32(dgvFacturas.CurrentRow.Cells[0].Value);
                 pFactura.ShowDialog();
             }
             else
             {
                 MessageBox.Show("Seleccione una factura de la tabla", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
         else if (rbVentas.Checked == true)
         {
             if (dgvFacturas.SelectedRows.Count == 1)
             {
                 frmFacturaVenta pFac = new frmFacturaVenta();
                 pFac.getID = Convert.ToInt32(dgvFacturas.CurrentRow.Cells[0].Value);
                 pFac.ShowDialog();
             }
             else
             {
                 MessageBox.Show("Seleccione una factura de la tabla", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
         else if (rbAlquiler.Checked == true)
         {
             if (dgvFacturas.SelectedRows.Count == 1)
             {
                 frmFacturaAlquiler pFactura = new frmFacturaAlquiler();
                 pFactura.getID = Convert.ToInt32(dgvFacturas.CurrentRow.Cells[0].Value);
                 pFactura.ShowDialog();
             }
             else
             {
                 MessageBox.Show("Seleccione una factura de la tabla", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #2
0
        // when cobrar button is clicked.
        private void btnCobrar_Click(object sender, EventArgs e)
        {
            try {
                if (pBaseObjfactura == null)
                {
                    MessageBox.Show("no se ha tomado una factura de la lista", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    btnSeleccionar.Focus();
                }
                else if (txtCantDevolver.Text == string.Empty)
                {
                    MessageBox.Show("Tienen que calcular la cantidad a devolver", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    btnCalcular.Focus();
                }
                else {
                    double pagorealizado, totalpagar, pagomensual, pagocontrato, parestante;
                    if (rbAlquiler.Checked == true)
                    {
                        // alquiler
                        if (txtCantPagar.Text == string.Empty)
                        {
                            MessageBox.Show("No se ha digitado una cantidad a pagar", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            txtCantPagar.Focus();
                        }
                        else if (txtMoneda.Text == string.Empty)
                        {
                            MessageBox.Show("No se ha digitado la moneda con la que se pagara", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            txtMoneda.Focus();
                        }
                        else
                        {
                            totalpagar = Convert.ToDouble(txtTotalaPagar.Text);
                            pagorealizado = Convert.ToDouble(txtCantPagar.Text);
                            pagocontrato = Convert.ToDouble(pBaseObjfactura.ContratoTotal);
                            DateTime today = DateTime.Now.Date;
                            DateTime nextPayment;
                            if(pBaseObjfactura.fechaProximoPago == string.Empty || pBaseObjfactura.fechaProximoPago == null)
                            {
                                nextPayment = today;
                            }
                            else
                            {
                                nextPayment = Convert.ToDateTime(pBaseObjfactura.fechaProximoPago);
                                nextPayment = nextPayment.AddMonths(1);
                            }

                            if (totalpagar >= pagorealizado)
                            {
                                try
                                {
                                    // verify wich payments the user is going to make.
                                    if (dbContrato.Checked == true && dbMensualidad.Checked == true)
                                    {
                                        // calculate mensualidad total in order to verify payment and calulate if monthly payment was completed.
                                        pagomensual = Convert.ToDouble(pBaseObjfactura.TotalPago_Mensualidad) + Convert.ToDouble(txtITEBIS.Text) + Convert.ToDouble(txtImpSobreRenta.Text);
                                        parestante = pagorealizado - pagomensual;
                                        // make the math to remove the remaing payment amount from the contract.
                                        parestante = pagocontrato - parestante;
                                        // validate if monthly payment was achieved.
                                        if (parestante > 0)
                                        {
                                            if (factura.registerFacturaRent(pBaseObjfactura.Cliente_ID, pBaseObjfactura.Service_ID, pBaseObjfactura.Case_ID, txtCantPagar.Text, parestante.ToString("f2"), txtTotalaPagar.Text, nextPayment.ToString("yyyy-MM-dd"), parestante.ToString("f2"), "Pago mensualidad y Abono al contrato de alquiler", DateTime.Today.Date.ToString("yyyy-MM-dd")) > 0)
                                            {
                                                // update the payment status
                                                facturacion.updateRentStatus(pBaseObjfactura.ID, "0", DateTime.Today.Date.ToString("yyyy-MM-dd"), parestante.ToString("f2"), nextPayment.ToString("yyyy-MM-dd"));
                                                MessageBox.Show("Factura registrada Exitosamente. \nProximo Pago: " + nextPayment.ToLongDateString(), "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                                if(MessageBox.Show("Desea Imprimir la factura?", "Mensaje", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                                                {
                                                    frmFacturaAlquiler pfactura = new frmFacturaAlquiler();
                                                    pfactura.getID = Convert.ToInt32(factura.getFacturaIDRent(pBaseObjfactura.Case_ID, "Pago mensualidad y Abono al contrato de alquiler", pBaseObjfactura.Cliente_ID, DateTime.Today.Date.ToString("yyyy-MM-dd")));
                                                    pfactura.ShowDialog();
                                                }
                                                cleanInputs();
                                            }
                                        }
                                        else if (parestante == 0)
                                        {
                                            if (factura.registerFacturaRent(pBaseObjfactura.Cliente_ID, pBaseObjfactura.Service_ID, pBaseObjfactura.Case_ID, txtCantPagar.Text, parestante.ToString("f2"), txtTotalaPagar.Text, nextPayment.ToString("yyyy-MM-dd"), parestante.ToString("f2"), "Pago mensualidad y Pago contrato de alquiler", DateTime.Today.Date.ToString("yyyy-MM-dd")) > 0)
                                            {
                                                facturacion.updateRentStatus(pBaseObjfactura.ID, "0", DateTime.Today.Date.ToString("yyyy-MM-dd"), parestante.ToString("f2"), nextPayment.ToString("yyyy-MM-dd"));
                                                MessageBox.Show("Factura registrada Exitosamente. \nProximo Pago: " + nextPayment.ToLongDateString(), "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                                if (MessageBox.Show("Desea Imprimir la factura?", "Mensaje", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                                                {
                                                    frmFacturaAlquiler pfactura = new frmFacturaAlquiler();
                                                    pfactura.getID = Convert.ToInt32(factura.getFacturaIDRent(pBaseObjfactura.Case_ID, "Pago mensualidad y Pago contrato de alquiler", pBaseObjfactura.Cliente_ID, DateTime.Today.Date.ToString("yyyy-MM-dd")));
                                                    pfactura.ShowDialog();
                                                }
                                                cleanInputs();
                                            }
                                        }
                                        else
                                        {
                                            MessageBox.Show("El pago realizado excede la cantidad Total a pagar", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                        }
                                    }
                                    else if (dbContrato.Checked == true)
                                    {
                                        parestante = totalpagar - pagorealizado;
                                        if (parestante > 0)
                                        {
                                            if (factura.registerFacturaRent(pBaseObjfactura.Cliente_ID, pBaseObjfactura.Service_ID, pBaseObjfactura.Case_ID, txtCantPagar.Text, parestante.ToString("f2"), txtTotalaPagar.Text, pBaseObjfactura.fechaProximoPago, parestante.ToString("f2"), "Abono al contrato de alquiler", DateTime.Today.Date.ToString("yyyy-MM-dd")) > 0)
                                            {
                                                facturacion.updateRentStatus(pBaseObjfactura.ID, "0", DateTime.Today.Date.ToString("yyyy-MM-dd"), parestante.ToString("f2"), pBaseObjfactura.fechaProximoPago);
                                                MessageBox.Show("Factura registrada Exitosamente. \nProximo Pago: " + nextPayment.ToLongDateString(), "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                                if (MessageBox.Show("Desea Imprimir la factura?", "Mensaje", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                                                {
                                                    frmFacturaAlquiler pfactura = new frmFacturaAlquiler();
                                                    pfactura.getID = Convert.ToInt32(factura.getFacturaIDRent(pBaseObjfactura.Case_ID, "Abono al contrato de alquiler", pBaseObjfactura.Cliente_ID, DateTime.Today.Date.ToString("yyyy-MM-dd")));
                                                    pfactura.ShowDialog();
                                                }
                                                cleanInputs();

                                            }
                                        }
                                        else if (parestante == 0)
                                        {
                                            if (factura.registerFacturaRent(pBaseObjfactura.Cliente_ID, pBaseObjfactura.Service_ID, pBaseObjfactura.Case_ID, txtCantPagar.Text, parestante.ToString("f2"), txtTotalaPagar.Text, pBaseObjfactura.fechaProximoPago, parestante.ToString("f2"), "Pago total del contrato de alquiler", DateTime.Today.Date.ToString("yyyy-MM-dd")) > 0)
                                            {
                                                facturacion.updateRentStatus(pBaseObjfactura.ID, "0", DateTime.Today.Date.ToString("yyyy-MM-dd"), parestante.ToString("f2"), pBaseObjfactura.fechaProximoPago);
                                                MessageBox.Show("Factura registrada Exitosamente. \nProximo Pago: " + nextPayment.ToLongDateString(), "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                                if (MessageBox.Show("Desea Imprimir la factura?", "Mensaje", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                                                {
                                                    frmFacturaAlquiler pfactura = new frmFacturaAlquiler();
                                                    pfactura.getID = Convert.ToInt32(factura.getFacturaIDRent(pBaseObjfactura.Case_ID, "Pago total del contrato de alquiler", pBaseObjfactura.Cliente_ID, DateTime.Today.Date.ToString("yyyy-MM-dd")));
                                                    pfactura.ShowDialog();
                                                }
                                                cleanInputs();
                                            }
                                        }
                                    }
                                    else if (dbMensualidad.Checked == true)
                                    {
                                        parestante = totalpagar - pagorealizado;
                                        if (parestante > 0)
                                        {
                                            MessageBox.Show("Debe completar el pago mensual para poder general la factura", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                        }
                                        else if (parestante == 0)
                                        {
                                            if (factura.registerFacturaRent(pBaseObjfactura.Cliente_ID, pBaseObjfactura.Service_ID, pBaseObjfactura.Case_ID, txtCantPagar.Text, parestante.ToString("f2"), txtTotalaPagar.Text, nextPayment.ToString("yyyy-MM-dd"), parestante.ToString("f2"), "Pago total de la mensualidad", DateTime.Today.Date.ToString("yyyy-MM-dd")) > 0)
                                            {
                                                facturacion.updateRentStatus(pBaseObjfactura.ID, "0", DateTime.Today.Date.ToString("yyyy-MM-dd"), pBaseObjfactura.ContratoTotal, nextPayment.ToString("yyyy-MM-dd"));
                                                MessageBox.Show("Factura registrada Exitosamente. \nProximo Pago: " + nextPayment.ToLongDateString(), "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                                if (MessageBox.Show("Desea Imprimir la factura?", "Mensaje", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                                                {
                                                    frmFacturaAlquiler pfactura = new frmFacturaAlquiler();
                                                    pfactura.getID = Convert.ToInt32(factura.getFacturaIDRent(pBaseObjfactura.Case_ID, "Pago total de la mensualidad", pBaseObjfactura.Cliente_ID, DateTime.Today.Date.ToString("yyyy-MM-dd")));
                                                    pfactura.ShowDialog();
                                                }
                                                cleanInputs();
                                            }
                                        }
                                        else
                                        {
                                            MessageBox.Show("El pago realizado excede la cantidad Total a pagar", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                            else
                            {
                                MessageBox.Show("La cantidad a pagar excede el Total a Pagar", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                txtCantPagar.Clear();
                                txtCantPagar.Focus();
                            }
                        }
                    }
                    else if (rbVentas.Checked == true)
                    {
                        // ventas
                        totalpagar = Convert.ToDouble(txtTotalaPagar.Text);
                        pagorealizado = Convert.ToDouble(txtCantPagar.Text);
                        parestante = totalpagar - pagorealizado;
                        if (parestante > 0)
                        {
                            if (factura.registerFacturaVenta(pBaseObjfactura.Cliente_ID, pBaseObjfactura.Service_ID, pBaseObjfactura.Case_ID, totalpagar.ToString("f2"), pagorealizado.ToString("f2"), parestante.ToString("f2"), DateTime.Today.Date.ToString("yyyy-MM-dd"), "Abono contrato de venta") > 0)
                            {
                                MessageBox.Show("Factura registrada exitosamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                facturacion.updateVentaStatus(pBaseObjfactura.ID, parestante.ToString("f2"), pagorealizado.ToString("f2"), DateTime.Today.ToString("yyyy-MM-dd"));
                                if(MessageBox.Show("Desea Imprimir la factura?", "Mensaje", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                                {
                                    frmFacturaVenta pFactura = new frmFacturaVenta();
                                    pFactura.getID = Convert.ToInt32(factura.getFacturaIDVenta(DateTime.Today.Date.ToString("yyyy-MM-dd"), pBaseObjfactura.Case_ID, "Abono contrato de venta", pBaseObjfactura.Cliente_ID));
                                    pFactura.ShowDialog();
                                }
                                cleanInputs();
                            }
                        }
                        else if (parestante == 0)
                        {
                            if (factura.registerFacturaVenta(pBaseObjfactura.Cliente_ID, pBaseObjfactura.Service_ID, pBaseObjfactura.Case_ID, totalpagar.ToString("f2"), pagorealizado.ToString("f2"), parestante.ToString("f2"), DateTime.Today.Date.ToString("yyyy-MM-dd"), "Pago total del contrato de venta") > 0)
                            {
                                MessageBox.Show("Factura registrada exitosamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                facturacion.updateVentaStatus(pBaseObjfactura.ID, parestante.ToString("f2"), pagorealizado.ToString("f2"), DateTime.Today.ToString("yyyy-MM-dd"));
                                if (MessageBox.Show("Desea Imprimir la factura?", "Mensaje", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                                {
                                    frmFacturaVenta pFactura = new frmFacturaVenta();
                                    pFactura.getID = Convert.ToInt32(factura.getFacturaIDVenta(DateTime.Today.Date.ToString("yyyy-MM-dd"), pBaseObjfactura.Case_ID, "Pago total del contrato de venta", pBaseObjfactura.Cliente_ID));
                                    pFactura.ShowDialog();
                                }
                                cleanInputs();
                            }
                        }
                        else
                        {
                            MessageBox.Show("El pago realizado excede la cantidad que se tienen que pagar", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                    else if (rbDivorcioAccidente.Checked == true)
                    {
                        // divorcio accidente
                        totalpagar = Convert.ToDouble(txtTotalaPagar.Text);
                        pagorealizado = Convert.ToDouble(txtCantPagar.Text);
                        parestante = totalpagar - pagorealizado;
                        if (parestante > 0)
                        {
                            if (factura.registerFacturaDivorciosAccidente(pBaseObjfactura.Cliente_ID, pBaseObjfactura.Service_ID, pBaseObjfactura.Case_ID, totalpagar.ToString("f2"), pagorealizado.ToString("f2"), parestante.ToString("f2"), DateTime.Today.Date.ToString("yyyy-MM-dd"), "Abono a cuenta") > 0)
                            {
                                MessageBox.Show("Factura registrada exitosamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                facturacion.updateDivorciosAccidenteStatus(pBaseObjfactura.ID, parestante.ToString("f2"), pagorealizado.ToString("f2"), DateTime.Today.Date.ToString("yyyy-MM-dd"));
                                if(MessageBox.Show("Desea Imprimir la factura?", "Mensaje", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                                {
                                    frmFacturaDivorciosAccidente pFactura = new frmFacturaDivorciosAccidente();
                                    pFactura.getID = Convert.ToInt32(factura.getFacturaIDDivorciosAccidente(DateTime.Today.Date.ToString("yyyy-MM-dd"), pBaseObjfactura.Case_ID, "Abono a cuenta", pBaseObjfactura.Cliente_ID));
                                    pFactura.ShowDialog();
                                }
                                cleanInputs();
                            }
                        }
                        else if (parestante == 0)
                        {
                            if (factura.registerFacturaDivorciosAccidente(pBaseObjfactura.Cliente_ID, pBaseObjfactura.Service_ID, pBaseObjfactura.Case_ID, totalpagar.ToString("f2"), pagorealizado.ToString("f2"), parestante.ToString("f2"), DateTime.Today.Date.ToString("yyyy-MM-dd"), "Pago total") > 0)
                            {
                                MessageBox.Show("Factura registrada exitosamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                facturacion.updateDivorciosAccidenteStatus(pBaseObjfactura.ID, parestante.ToString("f2"), pagorealizado.ToString("f2"), DateTime.Today.ToString("yyyy-MM-dd"));
                                if (MessageBox.Show("Desea Imprimir la factura?", "Mensaje", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                                {
                                    frmFacturaDivorciosAccidente pFactura = new frmFacturaDivorciosAccidente();
                                    pFactura.getID = Convert.ToInt32(factura.getFacturaIDDivorciosAccidente(DateTime.Today.Date.ToString("yyyy-MM-dd"), pBaseObjfactura.Case_ID, "Pago total", pBaseObjfactura.Cliente_ID));
                                    pFactura.ShowDialog();
                                }
                                cleanInputs();
                            }
                        }
                        else
                        {
                            MessageBox.Show("El pago realizado excede el total a pagar", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                }
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #3
0
 // when imprimir button is clicked.
 private void btnImprimir_Click(object sender, EventArgs e)
 {
     try
     {
         if (rbDivorcioAccidente.Checked == true)
         {
             if (dgvFacturas.SelectedRows.Count == 1)
             {
                 frmFacturaDivorciosAccidente pFactura = new frmFacturaDivorciosAccidente();
                 pFactura.getID = Convert.ToInt32(dgvFacturas.CurrentRow.Cells[0].Value);
                 pFactura.ShowDialog();
             }
             else
             {
                 MessageBox.Show("Seleccione una factura de la tabla", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
         else if (rbVentas.Checked == true)
         {
             if (dgvFacturas.SelectedRows.Count == 1)
             {
                 frmFacturaVenta pFac = new frmFacturaVenta();
                 pFac.getID = Convert.ToInt32(dgvFacturas.CurrentRow.Cells[0].Value);
                 pFac.ShowDialog();
             }
             else
             {
                 MessageBox.Show("Seleccione una factura de la tabla", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
         else if (rbAlquiler.Checked == true)
         {
             if (dgvFacturas.SelectedRows.Count == 1)
             {
                 frmFacturaAlquiler pFactura = new frmFacturaAlquiler();
                 pFactura.getID = Convert.ToInt32(dgvFacturas.CurrentRow.Cells[0].Value);
                 pFactura.ShowDialog();
             }
             else
             {
                 MessageBox.Show("Seleccione una factura de la tabla", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }