예제 #1
0
        public int mtdRegistrarPago(clPagoE objPagoE)
        {
            consulta = "insert into Pago(ValorPago,Fecha,IdFactura)values(" + objPagoE.ValorPago + ",'" + DateTime.Now.ToShortDateString() + "'," + objPagoE.IdFactura + ")";
            int registros = objBDSql.mtdIDU(consulta);

            return(registros);
        }
예제 #2
0
        private void btnGuardarCr_Click(object sender, EventArgs e)
        {
            if (txtAbono.Text == "" || txtEfectivo.Text == "")
            {
                MessageBox.Show("Por favor complete todos los campos");
            }
            else
            {
                if (Double.Parse(txtEfectivo.Text) < Double.Parse(txtAbono.Text))
                {
                    MessageBox.Show("El valor en efectivo no puede ser menor que el abono");
                }
                else
                {
                    double abono = Double.Parse(txtAbono.Text);
                    if (abono > saldo)
                    {
                        MessageBox.Show("El Abono no puede ser mayor al saldo pendiente, por favor verifique el valor ingresado");
                    }
                    else
                    {
                        clPagoE objPagoE = new clPagoE();
                        objPagoE.Fecha     = DateTime.Now;
                        objPagoE.IdFactura = IdFactura;
                        objPagoE.ValorPago = Math.Truncate(Double.Parse(txtAbono.Text));
                        if (objPagoE.ValorPago > Double.Parse(lblSaldo.Text))
                        {
                            objPagoE.ValorPago = Double.Parse(lblSaldo.Text);
                        }
                        int registro = objPagoL.mtdRegistrarPago(objPagoE);

                        if (registro == 1)
                        {
                            double cambio = Double.Parse(txtEfectivo.Text) - Double.Parse(txtAbono.Text);
                            MessageBox.Show("Pago registrado con éxito \n Cambio:$" + cambio);
                            double Total = Double.Parse(lblTotalAPagar.Text);
                            TotalPagado = Double.Parse(objPagoL.mtdObtenerSaldoPorPagar(IdFactura));
                            if (TotalPagado >= Total)
                            {
                                objFacturaL.mtdActualizarEstado(objPagoE.IdFactura);
                            }
                            this.Hide();
                            frmListarFacturas objListarFacturas = new frmListarFacturas();
                            objListarFacturas.Show();
                        }
                        else
                        {
                            MessageBox.Show("Error al registrar ");
                        }
                    }
                }
            }
        }
예제 #3
0
 public int mtdRegistrarPago(clPagoE objPagoE)
 {
     return(objPagoD.mtdRegistrarPago(objPagoE));
 }
예제 #4
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (rbCita.Checked == true && txtNombres.Text == "")
            {
                MessageBox.Show("Para Guardar Una Factura De Cita Es Necesario Un Paciente");
            }
            else
            {
                if ((rbAccesorios.Checked == true && productos == 0) || (rbCita.Checked == true && citas == 0) || cmbFormaDePago.SelectedItem == null || (rbCita.Checked == false && rbAccesorios.Checked == false) || (cmbFormaDePago.SelectedItem.ToString() == "Contado" && txtEfectivo.Text == ""))
                {
                    MessageBox.Show("Complete Todos Los Campos, Por Favor.");
                }
                else
                {
                    clFacturaE objFacturaE = new clFacturaE();
                    objFacturaE.NoFactura = NoFactura;



                    objFacturaE.Fecha    = txtFecha.Text;
                    objFacturaE.SubTotal = Math.Truncate(double.Parse(txtSubTotal.Text));
                    objFacturaE.IVA      = Math.Truncate(double.Parse(txtIVA.Text));
                    objFacturaE.Total    = Math.Truncate(double.Parse(txtTotal.Text));
                    Totall = txtTotal.Text;
                    objFacturaE.Descuento = Math.Truncate(double.Parse(txtDescuento.Text));
                    objFacturaE.TipoPago  = cmbFormaDePago.SelectedItem.ToString();
                    if (objFacturaE.TipoPago == "Contado")
                    {
                        objFacturaE.Estado = "Paga";
                    }
                    else
                    {
                        objFacturaE.Estado = "Pendiente";
                    }

                    objFacturaE.IdUsuario  = frmIniciarSesion.IdUsuario;
                    objFacturaE.IdPaciente = idPaciente;

                    int registros       = objFacturaL.mtdRegistrarFactura(objFacturaE);
                    int registroDetalle = 0;
                    int totalRegistros  = 0;
                    if (registros == 1)
                    {
                        clDetallesL objDetallesL = new clDetallesL();
                        objFacturaE = objDetallesL.mtdObtenerIdFactura(objFacturaE);
                        IdF         = objFacturaE.IdFactura;
                        if (cmbFormaDePago.Text == "Contado")
                        {
                            clPagoL objPagoL = new clPagoL();
                            clPagoE objPagoE = new clPagoE();
                            objPagoE.ValorPago = Math.Truncate(Double.Parse(txtTotal.Text));
                            objPagoE.Fecha     = Convert.ToDateTime(txtFecha.Text);
                            objPagoE.IdFactura = objFacturaE.IdFactura;

                            int registro = objPagoL.mtdRegistrarPago(objPagoE);
                        }

                        if (rbCita.Checked == true)
                        {
                            clDetallesE objDetallesE = new clDetallesE();
                            objDetallesE.IdFactura = objFacturaE.IdFactura;
                            objDetallesE.IdCita    = idCita;
                            objDetallesE.Valor     = Math.Truncate(double.Parse(dgvCitas.Rows[0].Cells[3].Value.ToString()));
                            registroDetalle        = objDetallesL.mtdRegistrarDetalles(objDetallesE, 1);
                            if (registroDetalle == 1)
                            {
                                totalRegistros++;
                            }
                            else if (registroDetalle == 5)
                            {
                                MessageBox.Show("La cita que desea cancelar ya está paga");
                                objFacturaL.mtdEliminarFactura(objFacturaE);
                            }

                            if (totalRegistros != dgvCitas.Rows.Count)
                            {
                                MessageBox.Show("Error Al Guardar");
                                objFacturaL.mtdEliminarFactura(objFacturaE);
                            }
                            else
                            {
                                efectivo = double.Parse(txtEfectivo.Text);
                                total    = double.Parse(txtTotal.Text);

                                cambio    = efectivo - total;
                                btGuardar = 0;
                                MessageBox.Show("Factura Guardada con éxito \n Cambio: " + cambio);

                                btGuardar++;
                                if (cmbFormaDePago.Text == "Contado")
                                {
                                    mtdTicket();
                                    frmVistaTicket objTicket = new frmVistaTicket();
                                    //objTicket.MdiParent = this.MdiParent;
                                    objTicket.Show();
                                    this.Hide();
                                    this.MdiParent.Hide();
                                }
                                else
                                {
                                    mtdTicket();
                                    frmListarFacturas objListarFacturas = new frmListarFacturas();
                                    objListarFacturas.MdiParent = this.MdiParent;
                                    objListarFacturas.Show();

                                    this.Hide();
                                }
                            }
                        }
                        else
                        {
                            for (int i = 0; i < productos; i++)
                            {
                                clDetallesE objDetallesE = new clDetallesE();
                                objDetallesE.IdProducto = int.Parse(dgvProductos.Rows[i].Cells[0].Value.ToString());
                                objDetallesE.IdFactura  = objFacturaE.IdFactura;
                                objDetallesE.Cantidad   = int.Parse(dgvProductos.Rows[i].Cells[3].Value.ToString());
                                objDetallesE.Valor      = Math.Truncate(double.Parse(dgvProductos.Rows[i].Cells[5].Value.ToString()));
                                registroDetalle         = objDetallesL.mtdRegistrarDetalles(objDetallesE, 2);
                                if (registroDetalle == 1)
                                {
                                    totalRegistros++;
                                }
                            }
                            if (totalRegistros != productos)
                            {
                                MessageBox.Show("Error Al Guardar");
                                objFacturaL.mtdEliminarFactura(objFacturaE);
                            }
                            else
                            {
                                for (int i = 0; i < productos; i++)
                                {
                                    clProductoL objProductoL = new clProductoL();
                                    int         cantidad     = int.Parse(dgvProductos.Rows[i].Cells[3].Value.ToString());
                                    int         IdProducto   = int.Parse(dgvProductos.Rows[i].Cells[0].Value.ToString());
                                    objProductoL.mtdActualizar(cantidad: cantidad, IdProducto: IdProducto);
                                }
                                btGuardar++;
                                if (cmbFormaDePago.Text == "Contado")
                                {
                                    efectivo = double.Parse(txtEfectivo.Text);
                                    total    = double.Parse(txtTotal.Text);

                                    cambio = efectivo - total;
                                    MessageBox.Show("La Factura se ha Guardado con éxito \n Cambio: " + cambio);
                                    mtdTicket();
                                    frmVistaTicket objTicket = new frmVistaTicket();
                                    //objTicket.MdiParent = this.MdiParent;

                                    this.Hide();
                                    this.MdiParent.Hide();
                                    objTicket.Show();
                                }
                                else
                                {
                                    MessageBox.Show("La Factura se ha Guardado con éxito");


                                    mtdTicket();
                                    frmListarFacturas objListarFacturas = new frmListarFacturas();
                                    objListarFacturas.MdiParent = this.MdiParent;
                                    objListarFacturas.Show();

                                    this.Hide();
                                }
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("Error Al Guardar");
                    }
                }
            }
        }