示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            label3.Text = "";
            if (String.IsNullOrEmpty(textBox1.Text)) { errorProvider1.SetError(textBox1, "Nombre de Usuario no puede estar vacio"); } else { errorProvider1.SetError(textBox1, ""); }
            if (String.IsNullOrEmpty(textBox2.Text)) { errorProvider1.SetError(textBox2, "Contraseña no puede estar vacio"); } else { errorProvider1.SetError(textBox2, ""); }

            if (!String.IsNullOrEmpty(textBox1.Text) && !String.IsNullOrEmpty(textBox2.Text))
            {
                Rules logica = new Rules();;

                Usuario user = new Usuario();

                user = logica.validateUser(textBox1.Text, textBox2.Text);

                if (user.Logged)
                {
                    switch (user.RolUser)
                    {
                        case "Administrador":
                            Administracion admin = new Administracion(user);
                            admin.WindowState = FormWindowState.Maximized;
                            this.Hide();
                            admin.ShowDialog();
                            this.Close();
                            break;
                        default:
                            MessageBox.Show("Usted no esta autorizado");
                            break;
                    }
                }
                else
                {
                    label3.Text = "Nombre de Usuario/Contraseña Incorrectos";
                }
            }
        }
示例#2
0
        void core_onImage(object source, GriauleFingerprintLibrary.Events.ImageEventArgs ie)
        {
            try
            {
                huella = ie.RawImage;
                core.Extract(huella, ref template);
                label4.Text = "";//"Espere, identificando...";
                bool haveHorarios = false;
                string consulta;
                byte[] dataTemp;
                GriauleFingerprintLibrary.DataTypes.FingerprintTemplate templateTemp;
                int precision, calidad;

                // selecciono
                consulta = "select id, rol, concat_ws(' ', nombre, apellidoPaterno, apellidoMaterno) as nombreCompleto, template, calidad_template, foto from usuarios where template is not null and 1 = 1";

                MySqlDataReader reader = this.EjecutarQuery(consulta);

                core.IdentifyPrepare(template);
                bool match = false;

                while (reader.Read())
                {
                    Log.WriteLog("Recorriendo usuarios.");
                    dataTemp = (byte[])reader["template"];
                    calidad = (int)reader["calidad_template"];
                    templateTemp = new GriauleFingerprintLibrary.DataTypes.FingerprintTemplate();
                    templateTemp.Buffer = dataTemp;
                    templateTemp.Size = dataTemp.Length;
                    templateTemp.Quality = calidad;

                    int result = core.Identify(templateTemp, out precision);

                    if (result == 1)
                    {

                        Usuario = reader["id"].ToString();
                        string nombreCompleto = reader["nombreCompleto"].ToString();
                        string rol = reader["rol"].ToString();
                        string foto = reader["foto"].ToString();
                        Rol = rol;

                        Log.WriteLog("Encontre al Usuario - " + reader["nombreCompleto"].ToString());
                        string inout = new Rules().isInOut(Usuario);
                        if (inout == "In")
                        {
                            Log.WriteLog(inout);
                            if (Rol == "Cliente")
                            {
                                List<Horario> horarios = this.getHorarios(Usuario);

                                if (horarios.Count > 0)
                                {
                                    haveHorarios = true;
                                }
                                else
                                {
                                    Log.WriteLog("No hay horarios disponibles.");
                                    MessageBox.Show("Lo sentimos no contamos con horarios disponibles");
                                    //clean();
                                }

                                if (haveHorarios)
                                {
                                    label4.Text = "";
                                    dataGridView1.DataSource = horarios;
                                    label2.Text = "Bienvenido " + nombreCompleto;
                                    mensualidad.Text = new Rules().ProximoPago(Usuario);
                                    Log.WriteLog("Encontre horarios para - " + nombreCompleto);
                                    if (!String.IsNullOrEmpty(foto))
                                    {
                                        fotoGrafia.ImageLocation = @"c:\wamp\www\gym\fotos\" + foto;
                                    }
                                    this.WindowState = FormWindowState.Normal;
                                }
                            }
                            else if (Rol == "Instructor")
                            {
                                label4.Text = "";
                                dataGridView1.DataSource = null;
                                label2.Text = "Bienvenido " + nombreCompleto;

                                if (!String.IsNullOrEmpty(foto))
                                {
                                    fotoGrafia.ImageLocation = @"c:\wamp\www\gym\fotos\" + foto;
                                }
                                this.WindowState = FormWindowState.Normal;
                                Log.WriteLog("Bienvenido Instructor - " + nombreCompleto);
                            }

                        }
                        else
                        {
                            if (new Rules().registrarSalida(Usuario))
                            {
                                Log.WriteLog("Se registro la salida - " + nombreCompleto);
                                label2.Text = "Hasta pronto " + nombreCompleto;

                                if (!String.IsNullOrEmpty(foto))
                                {
                                    fotoGrafia.ImageLocation = @"c:\wamp\www\gym\fotos\" + foto;
                                }
                                this.WindowState = FormWindowState.Normal;
                                this.button2.Visible = true;

                            }

                        }
                        match = true;

                        break;
                    }

                }

                if(!match)
                {
                    label4.Text = "Usuario no registrado, te invitamos a darte de alta";
                    Log.WriteLog("No se encontro ni un usuario");
                    //clean();
                    this.WindowState = FormWindowState.Normal;
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                Log.WriteLog(ex.Message);
            }
        }
示例#3
0
        void core_onImage(object source, GriauleFingerprintLibrary.Events.ImageEventArgs ie)
        {
            try
            {
                WriteLog("Obteniendo Huella.");
                huella = ie.RawImage;
                core.Extract(huella, ref template);
                string consulta;
                byte[] dataTemp;
                GriauleFingerprintLibrary.DataTypes.FingerprintTemplate templateTemp;
                int precision, calidad;

                // selecciono
                consulta = "select id, id as no_empleado, telefono, rfc, rol, concat_ws(' ', nombre, apellidoPaterno, apellidoMaterno) as nombreCompleto, template, calidad_template, foto from usuarios where template is not null and 1 = 1";

                MySqlDataReader reader = this.EjecutarQuery(consulta);
                core.IdentifyPrepare(template);

                while (reader.Read())
                {
                    dataTemp = (byte[])reader["template"];
                    calidad = (int)reader["calidad_template"];
                    templateTemp = new GriauleFingerprintLibrary.DataTypes.FingerprintTemplate();
                    templateTemp.Buffer = dataTemp;
                    templateTemp.Size = dataTemp.Length;
                    templateTemp.Quality = calidad;

                    int result = core.Identify(templateTemp, out precision);
                    WriteLog("Resultado: "+result.ToString() + " Precision: " +  precision.ToString());

                    if (result == 1)
                    {

                        //
                        Usuario = reader["id"].ToString();
                        string no_Empleado = reader["no_empleado"].ToString();
                        string nombreCompleto = reader["nombreCompleto"].ToString();
                        string rfc = reader["rfc"].ToString();
                        string telefono = reader["telefono"].ToString();
                        string rol = reader["rol"].ToString();
                        string foto = reader["foto"].ToString();
                        Rol = rol;

                        WriteLog("Huella encontrada.");
                        WriteLog("Empleado: " + no_Empleado);

                        string inout = new Rules().isInOut(Usuario);
                        if (inout == "In")
                        {
                            if (new Rules().registrarEntrada(Usuario))
                            {
                                this.no_personal.Text = no_Empleado;
                                this.nombre_completo.Text = nombreCompleto;
                                this.rfc.Text = rfc;
                                this.telefono.Text = telefono;
                                label1.Text = "Entrada";

                                if (!String.IsNullOrEmpty(foto))
                                {
                                    fotoGrafia.ImageLocation = @RutaFotos + foto;
                                }

                                this.WindowState = FormWindowState.Normal;
                                WriteLog("Entrada Registrada. " + no_Empleado);
                            }
                            else
                            {
                                MessageBox.Show("No hemos podido registrar su entrada");
                                WriteLog("No hemos podido registrar su entrada" + no_Empleado);
                            }
                        }
                        else
                        {
                            if (new Rules().registrarSalida(Usuario))
                            {
                                this.no_personal.Text = no_Empleado;
                                this.nombre_completo.Text = nombreCompleto;
                                this.rfc.Text = rfc;
                                this.telefono.Text = telefono;

                                if (!String.IsNullOrEmpty(foto))
                                {
                                    fotoGrafia.ImageLocation = @RutaFotos + foto;
                                }

                                this.no_personal.Text = no_Empleado;
                                this.nombre_completo.Text = nombreCompleto;
                                this.rfc.Text = rfc;
                                this.telefono.Text = telefono;
                                label1.Text = "Salida";

                                if (!String.IsNullOrEmpty(foto))
                                {
                                    fotoGrafia.ImageLocation = @RutaFotos + foto;
                                }

                                this.WindowState = FormWindowState.Normal;
                                WriteLog("Salida Registrada. " + no_Empleado);
                            }

                        }

                        break;
                    }
                    else
                    {
                        WriteLog("No concuerda");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }