private void txtClave_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
               

                if (!ExpresionesRegulares.RegEX.isNumber(txtClave.Text.ToString()))
                {
                    MessageBox.Show("La clave es numerica, debes introducir solo numeros");
                    return;
                }

                int clave = int.Parse(txtClave.Text.ToString());

                oRegistro = new clsRegistro(clave);
                if (oRegistro.buscaDatos())
                {
                    //cargar datos
                    txtNombre.Text = oRegistro.datos.NombreSocio;
                    txtPaterno.Text = oRegistro.datos.Paterno;
                    txtMaterno.Text = oRegistro.datos.Materno;
                    lblVencimiento.Text = oRegistro.datos.Vencimiento.ToLongDateString();
                    //cargar foto
                    if (oRegistro.datos.foto != null)
                    {
                        MemoryStream stream = new MemoryStream(oRegistro.datos.foto);
                        Bitmap image = new Bitmap(stream);
                        pbFoto.Image = image;
                    }

                    txtClave.Text = "";
                    if (DateTime.Compare(oRegistro.datos.Vencimiento, DateTime.Now) < 0)
                    {
                        lblVencimiento.ForeColor = Color.Red;
                        MessageBox.Show("Se a términado tu membresia");

                    }
                    //si no se a venciudo la registramos REGISTRO
                    else
                    {
                        //si le quedanm pocos dias se le avisa de que ya mero se le acaba su membresia
                        Configuracion.clsConfiguracion.getDatos();
                        if(Configuracion.clsConfiguracion.datos.mensajeVencimiento!=null&&Configuracion.clsConfiguracion.datos.mensajeVencimiento>0)//si tiene abilitado el mensaje
                        if (DateTime.Compare(oRegistro.datos.Vencimiento, DateTime.Now.AddDays(Configuracion.clsConfiguracion.datos.mensajeVencimiento)) < 0)//si ya mero se termina
                        {
                            DateTime newDate = oRegistro.datos.Vencimiento;
                            DateTime oldDate = DateTime.Now;
                            TimeSpan ts = newDate - oldDate;
                            int diasFaltantes=ts.Days;

                            MessageBox.Show("Quedan "+(diasFaltantes)+" dias de tu membresia");
                        }

                        lblVencimiento.ForeColor = Color.Black;
                       
                        if (!oRegistro.addVisita())
                        {
                            MessageBox.Show(oRegistro.error);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("No existe un socio con esa clave");
                }
            }
        }
Exemple #2
0
        // Metodo con evento de caja te texto para cuando la tecla se halla hundido para ingresar la cave
        private void txtClave_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (!ExpresionesRegulares.RegEX.isNumber(txtClave.Text.ToString()))
                {
                    MessageBox.Show("La clave es numerica, debes introducir solo numeros");
                    return;
                }

                int clave = int.Parse(txtClave.Text.ToString());

                oRegistro = new clsRegistro(clave);
                if (oRegistro.buscaDatos())
                {
                    //Cargar datos
                    txtNombre.Text      = oRegistro.datos.NombreSocio;
                    txtPaterno.Text     = oRegistro.datos.Paterno;
                    txtMaterno.Text     = oRegistro.datos.Materno;
                    lblVencimiento.Text = oRegistro.datos.Vencimiento.ToLongDateString();
                    //Cargar foto
                    if (oRegistro.datos.foto != null)
                    {
                        MemoryStream stream = new MemoryStream(oRegistro.datos.foto);
                        Bitmap       image  = new Bitmap(stream);
                        pbFoto.Image = image;
                    }

                    txtClave.Text = "";
                    if (DateTime.Compare(oRegistro.datos.Vencimiento, DateTime.Now) < 0)
                    {
                        lblVencimiento.ForeColor = Color.Red;
                        MessageBox.Show("Se a términado tu membresia");
                    }
                    //Si no se a vencido la registramos registro
                    else
                    {
                        //Si le quedan pocos dias se le avisa de que ya casi se le acaba su membresia
                        Configuracion.clsConfiguracion.getDatos();
                        if (Configuracion.clsConfiguracion.datos.mensajeVencimiento != null && Configuracion.clsConfiguracion.datos.mensajeVencimiento > 0)       //Si tiene habilitado el mensaje
                        {
                            if (DateTime.Compare(oRegistro.datos.Vencimiento, DateTime.Now.AddDays(Configuracion.clsConfiguracion.datos.mensajeVencimiento)) < 0) //Si ya casi se termina
                            {
                                DateTime newDate       = oRegistro.datos.Vencimiento;
                                DateTime oldDate       = DateTime.Now;
                                TimeSpan ts            = newDate - oldDate;
                                int      diasFaltantes = ts.Days;

                                MessageBox.Show("Quedan " + (diasFaltantes) + " dias de tu membresia");
                            }
                        }

                        lblVencimiento.ForeColor = Color.Black;

                        if (!oRegistro.addVisita())
                        {
                            MessageBox.Show(oRegistro.error);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("No existe un socio con esa clave");
                }
            }
        }
Exemple #3
0
        private void txtClave_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                this.initForm(false);

                if (string.IsNullOrEmpty(txtClave.Text))
                {
                    return;
                }

                int clave = int.Parse(txtClave.Text.ToString());

                oRegistro = new clsRegistro(clave);
                if (oRegistro.buscaDatos())
                {
                    clsSocio socio = new clsSocio();

                    //cargar datos
                    String name = string.Format("{0} {1} {2}", oRegistro.datos.NombreSocio, oRegistro.datos.Paterno, oRegistro.datos.Materno);
                    lblName.Text = name;

                    //cargar foto
                    if (oRegistro.datos.foto != null)
                    {
                        MemoryStream stream = new MemoryStream(oRegistro.datos.foto);
                        Bitmap       image  = new Bitmap(stream);
                        pbFoto.Image = image;
                    }

                    txtClave.Text = "";
                    if (!oRegistro.datos.idSocio.Equals(1000))
                    {
                        String vencimiento = string.Format("Del {0} al {1}", oRegistro.datos.fechaInicioMembresia.ToLongDateString(), oRegistro.datos.Vencimiento.ToLongDateString());
                        lblPeriodo.Text = vencimiento;

                        clsSocio socioData = new clsSocio();
                        if (!socioData.socioActivo(oRegistro.datos.idSocio))
                        {
                            this.BackColor           = Color.Salmon;
                            lblVencimiento.ForeColor = Color.Red;
                            MessageBox.Show(this, "Usuario inactivo", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            tmHideData.Start();
                            return;
                        }
                        else if (DateTime.Compare(oRegistro.datos.Vencimiento, DateTime.Now) < 0)
                        {
                            this.BackColor           = Color.Salmon;
                            lblVencimiento.ForeColor = Color.Red;
                            MessageBox.Show(this, "Su membresía ha terminado, favor de renovarla", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            tmHideData.Start();
                            return;
                        }
                        else
                        {
                            //si le quedanm pocos dias se le avisa de que ya mero se le acaba su membresia
                            Configuracion.clsConfiguracion.getDatos();
                            if (Configuracion.clsConfiguracion.datos.mensajeVencimiento > 0)                                                                          //si tiene abilitado el mensaje
                            {
                                if (DateTime.Compare(oRegistro.datos.Vencimiento, DateTime.Now.AddDays(Configuracion.clsConfiguracion.datos.mensajeVencimiento)) < 0) //si ya mero se termina
                                {
                                    DateTime newDate       = oRegistro.datos.Vencimiento;
                                    DateTime oldDate       = DateTime.Now;
                                    TimeSpan ts            = newDate - oldDate;
                                    int      diasFaltantes = ts.Days;

                                    string msgDiasFaltantes = string.Format("Quedan {0} dias de vigencia a tu membresia", diasFaltantes);
                                    lblRestanteMembresia.Text = msgDiasFaltantes;
                                    pnlRestanteMembresia.Show();
                                }
                            }

                            lblVencimiento.ForeColor = Color.Black;
                        }
                    }
                    else
                    {
                        lblPeriodo.Hide();
                    }

                    if (!oRegistro.addVisita())
                    {
                        MessageBox.Show(this, oRegistro.error, "Atención", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

                    tmHideData.Start();
                }
                else
                {
                    this.BackColor = Color.Red;
                    pnlNotFound.Show();
                    tmNoMember.Start();
                }
            }
        }