private void btnDebitar_Click(object sender, EventArgs e)
        {
            if (!CONTROLADORA.funciones_compartidas.CHEQUEAR_EMAIL())
            {
                MessageBox.Show("No se ha configurado una cuenta de correo para el envio de recibos.");
                return;
            }
            //CREA TODOS LOS RECIBOS Y LOS ENVIA UNO POR UNO POR CORREO
            bool enviaron           = false; //para saber si mostrar mensaje de recibos enviados
            ListaDeudasAPagar lista = new ListaDeudasAPagar();

            dgvAFILIADOS.DataSource = cAFILIADOS.Obtener_Afiliados("", true, false); //obtiene todos los afiliados con Debito Automático
            int numero_afiliados = dgvAFILIADOS.Rows.Count;                          //numero de afiliados

            for (int j = 0; j <= numero_afiliados - 1; j++)                          //crea recibo uno por uno
            {
                lista.Clear();
                oAfiliado = cAFILIADOS.Obtener_Afiliados(Convert.ToInt32(dgvAFILIADOS[0, j].Value)); //obtiene afiliado
                MODELO.DEUDA oDeuda = oAfiliado.DEUDAS.FirstOrDefault(x => x.Pagada == false);       //obtiene deuda sin pagar
                //Crea un recibo nuevo
                oRecibo = new MODELO.RECIBO();
                //Crea el Detalle_Recibo con el Recibo y la Deuda
                cFACTURACION.AgregarDetalle(oRecibo, oDeuda);
                if (oDeuda != null) //si la deuda existe
                {
                    enviaron           = true;
                    lblDebitar.Visible = true;
                    lblDebitar.Text    = lblDebitar.Text = "Se estan enviando los recibos. Por favor, espere que termine el proceso." + " Quedan " + numero_afiliados + " por enviar.";
                    lista.Tables[0].Rows.Add //se carga la deuda en el dataset
                        (new object[] {
                        oDeuda.Id,
                        oDeuda.Mes,
                        oDeuda.Año,
                        oDeuda.Monto,
                        oDeuda.Pagada,
                        oDeuda.AFILIADO.Nombre,
                        oDeuda.Monto
                    });

                    //----ESTO ES PARA CREAR EL RECIBO PDF---//
                    ReportDocument oRep = new ReportDocument();
                    oRep.Load(rutaProyecto + "VISTA/Recibo.rpt");
                    oRep.SetDataSource(lista);
                    crystalReportViewer1.ReportSource = oRep; //carga el documento en el CrystalReport

                    //----ESTO ES PARA ENVIAR EL RECIBO PDF POR MAIL---//
                    oRep.ExportToDisk(ExportFormatType.PortableDocFormat, rutaProyecto + "report" + j + ".pdf"); //exporta recibo en pdf
                    string filename = rutaProyecto + "report" + j + ".pdf";
                    CONTROLADORA.funciones_compartidas.EnviarEmail(oAfiliado.Email, "Recibo", "Recibo", filename);
                    lblDebitar.Text = lblDebitar.Text = "Se estan enviando los recibos. Por favor, espere que termine el proceso." + " Quedan " + (numero_afiliados - (j + 1)) + " por enviar.";
                    oAfiliado.DEUDAS.First(x => x.Pagada == false).Pagada = true; //Cambia el estado de la deuda a pagado
                    cAFILIADOS.Modificar_Afiliado(oAfiliado);                     //guarda la deuda

                    //Completa los datos del Recibo y lo guarda en el catalogo
                    oRecibo.AFILIADO   = oAfiliado;
                    oRecibo.Fecha      = DateTime.Today;
                    oRecibo.Importe    = oDeuda.Monto;
                    oRecibo.Nro_Recibo = oRecibo.Id_Recibo + 100;
                    cFACTURACION.AgregarRecibo(oRecibo);
                }
            }

            if (enviaron) //si se enviaron recibos, se muestra el mensaje
            {
                MessageBox.Show("Se han enviado todos los recibos por correo.");
                lblDebitar.Visible = false;
                //Deshabilita el boton Debitar porque ya se realizo esa tarea
                btnDebitar.Enabled = false;
                ARMA_GRILLA();
            }
            else
            {
                MessageBox.Show("Ya se han cobrado las cuantas de Debito Automático.");
                ARMA_GRILLA();
            }
        }
示例#2
0
        private void btnGuardar_AFILIADO_Click(object sender, EventArgs e)
        {
            int      telefono, dni, contrato;
            Int64    numero_tarjeta = 0;
            DateTime fecha_nacimiento;

            if (!int.TryParse(TxtContrato_Afiliado.Text, out contrato))
            {
                MessageBox.Show("El número de contrato ingresado es incorrecto");
                return;
            }

            if (string.IsNullOrEmpty(txtNombre_Afiliado.Text))
            {
                MessageBox.Show("El nombre ingresado es incorrecto");
                return;
            }

            if (!int.TryParse(mtxtDNI_Afiliado.Text, out dni))
            {
                MessageBox.Show("El DNI ingresado es incorrecto");
                return;
            }

            if (!DateTime.TryParse(MtbFecha_Nacimiento.Text, out fecha_nacimiento))
            {
                MessageBox.Show("La fecha de nacimiento ingresada es incorrecta");
                return;
            }

            if (string.IsNullOrEmpty(Txtsexo_Afiliado.Text))
            {
                MessageBox.Show("El sexo ingresado es incorrecto");
                return;
            }

            if (string.IsNullOrEmpty(txtDirecion_Afiliado.Text))
            {
                MessageBox.Show("La dirección ingresada es incorrecta");
                return;
            }

            if (!int.TryParse(mtxtTel_Afiliado.Text, out telefono))
            {
                MessageBox.Show("El telefono ingresado es incorrecto");
                return;
            }

            if (string.IsNullOrEmpty(txtEmail_Afiliado.Text))
            {
                MessageBox.Show("El email ingresado es incorrecto");
                return;
            }

            if (CBPlanes.SelectedItem == null)
            {
                MessageBox.Show("Debe seleccionar un plan");
                return;
            }

            if (RbDebitoAutomatico.Checked)
            {
                if (!Int64.TryParse(txtNumeroTarjeta.Text, out numero_tarjeta))
                {
                    MessageBox.Show("Debe ingresar el número de la tarjeta");
                    return;
                }

                if (string.IsNullOrEmpty(mtbVencimientoTarjeta.Text))
                {
                    MessageBox.Show("Debe ingresar la fecha de vencimiento de la tarjeta");
                    return;
                }
            }

            oAFILIADO.Nombre           = txtNombre_Afiliado.Text;
            oAFILIADO.DNI              = dni;
            oAFILIADO.Fecha_Nacimiento = fecha_nacimiento;
            oAFILIADO.Sexo             = Txtsexo_Afiliado.Text;
            oAFILIADO.Direccion        = txtDirecion_Afiliado.Text;
            oAFILIADO.Telefono         = telefono;
            oAFILIADO.Email            = txtEmail_Afiliado.Text;
            oAFILIADO.Numero_Contrato  = contrato;
            oAFILIADO.PLAN             = (MODELO.PLAN)CBPlanes.SelectedItem;

            if (ChkEstado.Checked == true)
            {
                oAFILIADO.Estado = true;
            }
            else
            {
                oAFILIADO.Estado = false;
            }

            if (RbEfectivo.Checked)
            {
                oAFILIADO.Forma_Pago = "Efectivo";
            }
            else
            {
                if (accion == "A" || oAFILIADO.TARJETAS == null)
                {
                    oTarjeta = new MODELO.TARJETA();
                }

                oTarjeta.AFILIADO    = oAFILIADO;
                oTarjeta.Vencimiento = mtbVencimientoTarjeta.Text;
                oTarjeta.Numero      = numero_tarjeta;
                oTarjeta.Titular     = txtNombre_Afiliado.Text;
                oAFILIADO.Forma_Pago = "Debito Automático";

                if (accion == "A" || oAFILIADO.TARJETAS == null)
                {
                    cAFILIADOS.Agregar_Tarjeta(oTarjeta);
                }
                else
                {
                    cAFILIADOS.Modificar_Tarjeta(oTarjeta);
                }

                oAFILIADO.TARJETAS = oTarjeta;
            }

            MODELO.DEUDA oDeuda = new MODELO.DEUDA();
            oDeuda.AFILIADO = oAFILIADO;
            oDeuda.Mes      = DateTime.Now.Month.ToString();
            oDeuda.Año      = DateTime.Now.Year;
            oDeuda.Monto    = oAFILIADO.PLAN.Costo;
            oDeuda.Pagada   = false;

            List <MODELO.DEUDA> Deudas = cAFILIADOS.Obtener_Deudas();

            if (Deudas.Find(x => x.Año == oDeuda.Año && x.Mes == oDeuda.Mes && x.AFILIADO == oDeuda.AFILIADO) == null)
            {
                oAFILIADO.DEUDAS.Add(oDeuda);
            }

            if (accion == "A")
            {
                cAFILIADOS.Agregar_Afiliado(oAFILIADO);
            }
            else
            {
                cAFILIADOS.Modificar_Afiliado(oAFILIADO);
            }

            this.DialogResult = DialogResult.OK;
        }
示例#3
0
        private void btnGuardar_AFILIADO_Click(object sender, EventArgs e)
        {
            int telefono, dni, contrato;
            DateTime fecha_nacimiento;

            if(!int.TryParse(TxtContrato_Afiliado.Text, out contrato))
            {
                MessageBox.Show("El número de contrato ingresado es incorrecto");
                return;
            }

            if (string.IsNullOrEmpty(txtNombre_Afiliado.Text))
            {
                MessageBox.Show("El nombre ingresado es incorrecto");
                return;
            }

            if (!int.TryParse(mtxtDNI_Afiliado.Text, out dni))
            {
                MessageBox.Show("El DNI ingresado es incorrecto");
                return;
            }

            if (!DateTime.TryParse(MtbFecha_Nacimiento.Text, out fecha_nacimiento))
            {
                MessageBox.Show("La fecha de nacimiento ingresada es incorrecta");
                return;
            }

            if (string.IsNullOrEmpty(Txtsexo_Afiliado.Text))
            {
                MessageBox.Show("El sexo ingresado es incorrecto");
                return;
            }

            if (string.IsNullOrEmpty(txtDirecion_Afiliado.Text))
            {
                MessageBox.Show("La dirección ingresada es incorrecta");
                return;
            }

            if (!int.TryParse(mtxtTel_Afiliado.Text, out telefono))
            {
                MessageBox.Show("El telefono ingresado es incorrecto");
                return;
            }

            if (string.IsNullOrEmpty(txtEmail_Afiliado.Text))
            {
                MessageBox.Show("El email ingresado es incorrecto");
                return;
            }



            oAFILIADO.Nombre = txtNombre_Afiliado.Text;
            oAFILIADO.DNI = dni;
            oAFILIADO.Fecha_Nacimiento = fecha_nacimiento;
            oAFILIADO.Sexo = Txtsexo_Afiliado.Text;
            oAFILIADO.Direccion = txtDirecion_Afiliado.Text;
            oAFILIADO.Telefono = telefono;
            oAFILIADO.Email = txtEmail_Afiliado.Text;
            oAFILIADO.Numero_Contrato = contrato;


            if(chkTitular.Checked == true)
            {
                oAFILIADO.Titular = true;
            }
            else
            {
                oAFILIADO.Adherente = true;
            }

            if(ChkEstado.Checked == true)
            {
                oAFILIADO.Estado = true;
            }
            else
            {
                oAFILIADO.Estado = false;
            }

            if (accion == "A")
            {
                cAFILIADOS.Agregar_Afiliado(oAFILIADO);
            }
            else
            {
                cAFILIADOS.Modificar_Afiliado(oAFILIADO);
            }

            this.DialogResult = DialogResult.OK;


            //FALTA EL TEMA DE LOS PLANES Y EL DEBITO AUTOMATICO
        }