Esempio n. 1
0
        public FrmAFILIADO(MODELO.AFILIADO miAFILIADO, string miaccion)
        {
            InitializeComponent();

            cAFILIADOS = CONTROLADORA.cAFILIADOS.Obtener_Instancia();
            oAFILIADO  = miAFILIADO;
            accion     = miaccion;

            CBPlanes.DataSource    = cAFILIADOS.Obtener_Planes();
            CBPlanes.DisplayMember = "Nombre";

            if (accion != "A")
            {
                txtNombre_Afiliado.Text   = oAFILIADO.Nombre;
                txtDirecion_Afiliado.Text = oAFILIADO.Direccion;
                txtEmail_Afiliado.Text    = oAFILIADO.Email;
                MtbFecha_Nacimiento.Text  = oAFILIADO.Fecha_Nacimiento.ToString();
                Txtsexo_Afiliado.Text     = oAFILIADO.Sexo;
                TxtContrato_Afiliado.Text = oAFILIADO.Numero_Contrato.ToString();
                mtxtDNI_Afiliado.Text     = oAFILIADO.DNI.ToString();
                mtxtTel_Afiliado.Text     = oAFILIADO.Telefono.ToString();
                CBPlanes.Text             = oAFILIADO.PLAN.ToString();
                if (oAFILIADO.Estado == true)
                {
                    ChkEstado.Checked = true;
                }
                else
                {
                    ChkEstado.Checked = false;
                }

                if (oAFILIADO.Titular == true)
                {
                    chkTitular.Checked = true;
                }
                else
                {
                    ChkAdherente.Checked = true;
                }
            }
            if (accion == "C")
            {
                ChkEstado.Enabled            = false;
                ChkAdherente.Enabled         = false;
                MtbFecha_Nacimiento.Enabled  = false;
                btnGuardar_AFILIADO.Visible  = false;
                btnCancelar.Text             = "CERRAR";
                txtNombre_Afiliado.Enabled   = false;
                txtDirecion_Afiliado.Enabled = false;
                Txtsexo_Afiliado.Enabled     = false;
                mtxtDNI_Afiliado.Enabled     = false;
                mtxtTel_Afiliado.Enabled     = false;
                chkTitular.Enabled           = false;
                ChkDebito.Enabled            = false;
                TxtContrato_Afiliado.Enabled = false;
                txtEmail_Afiliado.Enabled    = false;
                CBPlanes.Enabled             = false;
            }
        }
 private void dgvAFILIADOS_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dgvAFILIADOS.CurrentRow == null)
     {
         MessageBox.Show("Debe seleccionar un Afiliafo");
         return;
     }
     else
     {
         oAFILIADO         = (MODELO.AFILIADO)dgvAFILIADOS.CurrentRow.DataBoundItem;
         this.DialogResult = System.Windows.Forms.DialogResult.OK;
     }
 }
Esempio n. 3
0
        public FrmCOBRAR(MODELO.AFILIADO miAFILIADO)
        {
            InitializeComponent();
            oAfiliado = miAFILIADO;
            //Obtiene las controladoras
            cAFILIADOS   = CONTROLADORA.cAFILIADOS.Obtener_Instancia();
            cFACTURACION = CONTROLADORA.cFACTURACION.Obtener_Instancia();
            //Crea una lista de deudas para guardar las deudas seleccionadas
            listaDeudas = new List <MODELO.DEUDA>();
            //Autocompleta los datos del afiliado
            txtNombre_Afiliado.Text = oAfiliado.Nombre;
            mtxtDNI_Afiliado.Text   = oAfiliado.DNI.ToString();
            //Ruta de la carpeta del proyecto: [...]/SISTEMA/
            rutaProyecto = Directory.GetCurrentDirectory().Substring(0, Directory.GetCurrentDirectory().Length - 15);

            ARMA_GRILLA();
        }
Esempio n. 4
0
        private void txtDNI_Afiliado_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                int dni;
                if (!int.TryParse(txtDNI_Afiliado.Text, out dni))
                {
                    MessageBox.Show("El DNI es incorrecto");
                    txtDNI_Afiliado.Focus();
                    return;
                }
                oAFILIADO = oCATALOGO.AFILIADOS.FirstOrDefault(x => x.DNI == dni);

                if (oAFILIADO == null)
                {
                    MessageBox.Show("No se ha encontrado el Afiliado");
                    return;
                }
                else
                {
                    txtDNI_Afiliado.Text    = oAFILIADO.DNI.ToString();
                    txtNombre_Afiliado.Text = oAFILIADO.Nombre;
                }
            }

            if (e.KeyCode == Keys.F5)
            {
                FrmBUSCARAFILIADO formBUSCARAFILIADO = new FrmBUSCARAFILIADO();
                DialogResult      dr = formBUSCARAFILIADO.ShowDialog();
                if (dr == DialogResult.OK)
                {
                    oAFILIADO               = formBUSCARAFILIADO.AFILIADO;
                    txtDNI_Afiliado.Text    = oAFILIADO.DNI.ToString();
                    txtNombre_Afiliado.Text = oAFILIADO.Nombre;
                }
            }
        }
Esempio n. 5
0
        public FrmAFILIADO(MODELO.AFILIADO miAFILIADO, string miaccion)
        {
            InitializeComponent();

            cAFILIADOS = CONTROLADORA.cAFILIADOS.Obtener_Instancia();
            oAFILIADO  = miAFILIADO;
            accion     = miaccion;

            CBPlanes.DataSource    = cAFILIADOS.Obtener_Planes();
            CBPlanes.DisplayMember = "Nombre";

            if (accion != "A")
            {
                txtNombre_Afiliado.Text   = oAFILIADO.Nombre;
                txtDirecion_Afiliado.Text = oAFILIADO.Direccion;
                txtEmail_Afiliado.Text    = oAFILIADO.Email;
                MtbFecha_Nacimiento.Text  = oAFILIADO.Fecha_Nacimiento.ToString();
                Txtsexo_Afiliado.Text     = oAFILIADO.Sexo;
                TxtContrato_Afiliado.Text = oAFILIADO.Numero_Contrato.ToString();
                mtxtDNI_Afiliado.Text     = oAFILIADO.DNI.ToString();
                mtxtTel_Afiliado.Text     = oAFILIADO.Telefono.ToString();
                CBPlanes.Text             = oAFILIADO.PLAN.ToString();
                if (oAFILIADO.Forma_Pago == "Debito Automático")
                {
                    oTarjeta = oAFILIADO.TARJETAS;
                    txtNumeroTarjeta.Text      = oAFILIADO.TARJETAS.Numero.ToString();
                    mtbVencimientoTarjeta.Text = oAFILIADO.TARJETAS.Vencimiento;
                }
                if (oAFILIADO.Forma_Pago.ToString() == "Efectivo")
                {
                    RbEfectivo.Checked = true;
                }
                else
                {
                    RbDebitoAutomatico.Checked = true;
                }
                if (oAFILIADO.Estado == true)
                {
                    ChkEstado.Checked = true;
                }
                else
                {
                    ChkEstado.Checked = false;
                }
            }
            if (accion == "C")
            {
                ChkEstado.Enabled            = false;
                MtbFecha_Nacimiento.Enabled  = false;
                btnGuardar_AFILIADO.Visible  = false;
                btnCancelar.Text             = "CERRAR";
                txtNombre_Afiliado.Enabled   = false;
                txtDirecion_Afiliado.Enabled = false;
                Txtsexo_Afiliado.Enabled     = false;
                mtxtDNI_Afiliado.Enabled     = false;
                mtxtTel_Afiliado.Enabled     = false;
                GB_FormasPago.Enabled        = false;
                gbTarjeta.Enabled            = false;
                TxtContrato_Afiliado.Enabled = false;
                txtEmail_Afiliado.Enabled    = false;
                CBPlanes.Enabled             = false;
            }
        }
Esempio n. 6
0
 public void Modificar_Afiliado(MODELO.AFILIADO oAfiliado)
 {
     oCATALOGO.Entry(oAfiliado).State = System.Data.Entity.EntityState.Modified;
     oCATALOGO.SaveChanges();
 }
Esempio n. 7
0
 public void Agregar_Afiliado(MODELO.AFILIADO oAfiliado)
 {
     oCATALOGO.AFILIADOS.Add(oAfiliado);
     oCATALOGO.SaveChanges();
 }
        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();
            }
        }