Ejemplo n.º 1
0
        public void GuardarBD()
        {
            try
            {
                byte[]         streamHuella   = Template.Bytes;
                ConexionHuella conexionHuella = new ConexionHuella();
                conexionHuella.Abrir();
                String     Comando = "INSERT INTO HUELLASCLIENTES(ID,HUELLA) VALUES(@ID,@HUELLA)";
                SqlCommand cmd     = new SqlCommand(Comando, conexionHuella.Conectarbd);
                cmd.Parameters.AddWithValue("@ID", pId);
                cmd.Parameters.AddWithValue("@HUELLA", streamHuella);
                int ok = cmd.ExecuteNonQuery();

                if (ok == 1)
                {
                    MessageBox.Show("Huella guardada con Exito...", "OK", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Error al guardar la huella...", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                conexionHuella.Cerrar();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Conexion Conectar = new Conexion();
                Conectar.Abrir();
                string comando = "SELECT * FROM CLIENTES WHERE ID_CLIENTE=@DOC";


                SqlCommand cmd = new SqlCommand(comando, Conectar.Conectarbd);
                cmd.Parameters.AddWithValue("@DOC", Convert.ToInt64(NroDocumento.Text));
                SqlDataReader read = cmd.ExecuteReader();
                while (read.Read())
                {
                    string Nombre    = read["NOMBRE"].ToString();
                    string Apellido  = read["APELLIDO"].ToString();
                    string Telefono  = read["TELEFONO"].ToString();
                    string Direccion = read["DIRECCION"].ToString();
                    string Genero    = read["GENERO"].ToString();
                    string TipoDoc   = read["DOC_CLIENTE"].ToString();
                    string Estatura  = read["ESTATURA_IN"].ToString();
                    textNombre.Text    = Nombre;
                    textApellido.Text  = Apellido;
                    textDireccion.Text = Direccion;
                    textTelefono.Text  = Telefono;
                    textGenero.Text    = Genero;
                    textTipoDoc.Text   = TipoDoc;
                    textEstatura.Text  = Estatura;
                }
                Conectar.Cerrar();
                string   FechaHoy = DateTime.Now.ToString("yyyy-MM-dd");
                DateTime FechaH   = Convert.ToDateTime(FechaHoy);
                string   comando2 = "SELECT * FROM INGRESOS WHERE FECHA_INGRE = (SELECT MAX(FECHA_INGRE) FROM INGRESOS WHERE DOC_CLIENTE = @DOC) AND DOC_CLIENTE = @DOC";
                Conectar.Abrir();
                SqlCommand cmd2 = new SqlCommand(comando2, Conectar.Conectarbd);
                cmd2.Parameters.AddWithValue("@DOC", Convert.ToInt64(NroDocumento.Text));
                SqlDataReader LFecha = cmd2.ExecuteReader();
                while (LFecha.Read())
                {
                    string FechaUlt   = LFecha["FECHA_INICIO"].ToString();
                    string FechaUlti2 = LFecha["FECHA_INGRE"].ToString();
                    string TipoPago   = LFecha["TIPO_INGRE"].ToString();
                    //textUlyimoPago.Text = LFecha["FECHA_INGRE"].ToString();
                    DateTime fecha = Convert.ToDateTime(FechaUlt);
                    textTipoPago.Text   = TipoPago;
                    textUlyimoPago.Text = FechaUlti2;
                    DateTime FechaVen;
                    Console.WriteLine(TipoPago);
                    if (TipoPago == "Mensual                  ")
                    {
                        FechaVen = fecha.AddMonths(1);
                        TOTAL    = 1;
                    }
                    else
                    {
                        if (TipoPago == "Quincenal                ")
                        {
                            FechaVen = fecha.AddDays(15);
                            TOTAL    = 2;
                        }
                        else
                        {
                            if (TipoPago == "Semanal                  ")
                            {
                                FechaVen = fecha.AddDays(7);
                                TOTAL    = 3;
                            }
                            else
                            {
                                if (TipoPago == "Diario                   ")
                                {
                                    FechaVen = fecha.AddDays(1);
                                    TOTAL    = 4;
                                }
                                else
                                {
                                    if (TipoPago == "2 Meses                  ")
                                    {
                                        FechaVen = fecha.AddMonths(2);
                                        TOTAL    = 5;
                                    }
                                    else
                                    {
                                        if (TipoPago == "3 Meses                  ")
                                        {
                                            FechaVen = fecha.AddMonths(3);
                                            TOTAL    = 6;
                                        }
                                        else
                                        {
                                            if (TipoPago == "6 Meses                  ")
                                            {
                                                FechaVen = fecha.AddMonths(3);
                                                TOTAL    = 7;
                                            }
                                            else
                                            {
                                                if (TipoPago == "Anual                    ")
                                                {
                                                    FechaVen = fecha.AddYears(1);
                                                    TOTAL    = 8;
                                                }
                                                else
                                                {
                                                    FechaVen = fecha;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    pTPago = FechaVen.ToString("yyyy-MM-dd");

                    if (FechaVen > FechaH)
                    {
                        textEstado.Text = "ACTIVO";
                    }
                    else
                    {
                        textEstado.Text = "VENCIDO";
                    }
                    Console.WriteLine(FechaVen);
                    Console.WriteLine(FechaH);
                }
                Conectar.Cerrar();
            }
            catch (Exception exe)
            {
                MessageBox.Show(exe.ToString());
            }

            try
            {
                ConexionHuella conexionHuella = new ConexionHuella();
                conexionHuella.Abrir();
                string     comando = "SELECT * FROM HUELLASCLIENTES WHERE ID=@ID";
                SqlCommand cmd     = new SqlCommand(comando, conexionHuella.Conectarbd);
                cmd.Parameters.AddWithValue("@ID", Convert.ToInt64(NroDocumento.Text));
                SqlDataReader reader = cmd.ExecuteReader();
                int           ok     = 0;
                while (reader.Read())
                {
                    ok = ok + 1;
                }
                if (ok == 1)
                {
                    button6.Visibility      = Visibility.Visible;
                    button6_Copy.Visibility = Visibility.Collapsed;
                }
                else
                {
                    button6_Copy.Visibility = Visibility.Visible;
                    button6.Visibility      = Visibility.Collapsed;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 3
0
        void Menu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            DialogResult result;

            result = MessageBox.Show("¿Desea realizar el pago?", "Pagar", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
            if (result == DialogResult.OK)
            {
                if (dtgLista.SelectedRows.Count == 1)
                {
                    Nombre   = dtgLista.CurrentRow.Cells[1].Value.ToString();
                    Apellido = dtgLista.CurrentRow.Cells[2].Value.ToString();
                    TPago    = dtgLista.CurrentRow.Cells[3].Value.ToString();
                    DateTime FeVe = Convert.ToDateTime(TPago);
                    DateTime Fhoy = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
                    if (FeVe >= Fhoy)
                    {
                        MessageBox.Show("El pago Comenzara con la fecha de vencimiento...", "INFO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        TPago = FeVe.ToString("yyyy-MM-dd");
                        Pagos pagos = new Pagos(CedulaPago, UsserID, Nombre, Apellido, TPago, 0);
                        pagos.Show();
                    }
                    else
                    {
                        try
                        {
                            ConexionHuella conexionHuella = new ConexionHuella();
                            conexionHuella.Abrir();
                            string     com = "SELECT ID,FECHA FROM REGISTROS WHERE (FECHA>@FECHAVEN AND FECHA<@FECHAHOY) AND ID=@CEDULA";
                            SqlCommand cmd = new SqlCommand(com, conexionHuella.Conectarbd);
                            cmd.Parameters.AddWithValue("@FECHAVEN", Convert.ToDateTime(FeVe.Date.ToString("yyyy-MM-dd")));
                            cmd.Parameters.AddWithValue("@FECHAHOY", Convert.ToDateTime(Fhoy.Date.ToString("yyyy-MM-dd")));
                            cmd.Parameters.AddWithValue("@CEDULA", CedulaPago);
                            Console.WriteLine(CedulaPago);
                            Console.WriteLine(FeVe.Date.ToString("yyyy-MM-dd"));
                            Console.WriteLine(Fhoy);
                            int ok = 0;
                            int i  = 0;
                            Console.WriteLine(ok);
                            SqlDataReader reader = cmd.ExecuteReader();
                            DateTime[]    fechas = new DateTime[100];
                            while (reader.Read())
                            {
                                Int64    cd = Convert.ToInt64(reader["ID"].ToString());
                                DateTime f  = Convert.ToDateTime(reader["FECHA"].ToString());
                                fechas[i] = f;
                                i++;
                                ok++;
                                Console.WriteLine(cd);
                                Console.WriteLine(ok);
                            }
                            conexionHuella.Cerrar();
                            //int cont = 0;
                            int total = 0;
                            for (int j = 0; j < i; j++)
                            {
                                int cont = 0;
                                //Console.WriteLine(cont);
                                for (int k = 0; k < i; k++)
                                {
                                    //DateTime fr = fechas[k];
                                    if (fechas[j] == fechas[k])
                                    {
                                        cont++;
                                    }
                                    Console.WriteLine(cont);
                                    if (cont >= 2)
                                    {
                                        total++;
                                        Console.WriteLine("total");
                                        Console.WriteLine(total);
                                        cont = 1;
                                    }
                                    //cont = 0;
                                }

                                // cont = 0;
                            }
                            int ok2 = ok;

                            if (total >= 1)
                            {
                                ok = ok - (total / 2);
                                Console.WriteLine(ok);
                            }


                            if (ok2 == 0)
                            {
                                MessageBox.Show("El pago se registrara desde el dia de HOY", "INFO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                TPago = Fhoy.ToString();
                                Pagos pagos = new Pagos(CedulaPago, UsserID, Nombre, Apellido, TPago, 0);
                                pagos.Show();
                            }
                            else
                            {
                                string mensaje = string.Format("EL pago se realizara \nDias descontados: {0} \nPor mora...", ok);
                                MessageBox.Show(mensaje, "INFO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                DateTime date = Fhoy.AddDays(-(ok));
                                TPago = date.ToString("yyyy-MM-dd");
                                Pagos pagos = new Pagos(CedulaPago, UsserID, Nombre, Apellido, TPago, 0);
                                pagos.Show();
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private static List <ListaR> LisRegist(Int64 IdUsser)
        {
            try
            {
                DateTime       Hoy            = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
                DateTime       Manana         = Hoy.AddDays(1);
                List <ListaR>  listas         = new List <ListaR>();
                ConexionHuella conexionHuella = new ConexionHuella();
                conexionHuella.Abrir();
                string     comando = "SELECT ID,FECHAYHORA FROM REGISTROS WHERE (FECHAYHORA>=@FECHAHOY AND FECHAYHORA<@FECHAMANANA) AND(IDUSUARIO=@USSERACTIVO)";
                SqlCommand cmd     = new SqlCommand(comando, conexionHuella.Conectarbd);
                cmd.Parameters.AddWithValue("@FECHAHOY", Hoy);
                cmd.Parameters.AddWithValue("@FECHAMANANA", Manana);
                cmd.Parameters.AddWithValue("@USSERACTIVO", IdUsser);

                SqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    ListaR listaR = new ListaR();
                    listaR.Documento = reader["ID"].ToString();
                    Int64    Pdoc      = Convert.ToInt64(listaR.Documento);
                    DateTime FechaHora = Convert.ToDateTime(reader["FECHAYHORA"]);
                    listaR.Fecha_y_Hora = FechaHora.ToString("HH:mm tt");
                    Conexion conexion = new Conexion();
                    conexion.Abrir();
                    string     com  = "SELECT NOMBRE,APELLIDO,NINGRESOS.FECHA_INICIO,INGRESOS.TIPO_INGRE FROM CLIENTES INNER JOIN  (select max(FECHA_INICIO)AS FECHA_INICIO,DOC_CLIENTE from INGRESOS group by DOC_CLIENTE) AS NINGRESOS  ON NINGRESOS.DOC_CLIENTE = CLIENTES.ID_CLIENTE INNER JOIN INGRESOS ON NINGRESOS.DOC_CLIENTE = INGRESOS.DOC_CLIENTE AND NINGRESOS.FECHA_INICIO=INGRESOS.FECHA_INICIO WHERE CLIENTES.ID_CLIENTE=@IDCLIENTE ";
                    SqlCommand cmd2 = new SqlCommand(com, conexion.Conectarbd);
                    cmd2.Parameters.AddWithValue("@IDCLIENTE", Pdoc);

                    SqlDataReader reader2 = cmd2.ExecuteReader();
                    while (reader2.Read())
                    {
                        listaR.Nombre   = reader2["NOMBRE"].ToString();
                        listaR.Apellido = reader2["APELLIDO"].ToString();
                        string TipoPago = reader2["TIPO_INGRE"].ToString();
                        listaR.Tipo_Pago = reader2["TIPO_INGRE"].ToString();
                        DateTime FechaIni = Convert.ToDateTime(reader2["FECHA_INICIO"].ToString());
                        DateTime FechaVen;
                        switch (TipoPago)
                        {
                        case "Mensual                  ":
                            FechaVen = FechaIni.AddMonths(1);
                            break;

                        case "Semanal                  ":
                            FechaVen = FechaIni.AddDays(7);
                            break;

                        case "Quincenal                ":
                            FechaVen = FechaIni.AddDays(15);
                            break;

                        case "2 Meses                  ":
                            FechaVen = FechaIni.AddMonths(2);
                            break;

                        case "3 Meses                  ":
                            FechaVen = FechaIni.AddMonths(3);
                            break;

                        case "6 Meses                  ":
                            FechaVen = FechaIni.AddMonths(6);
                            break;

                        case "Anual                    ":
                            FechaVen = FechaIni.AddYears(1);
                            break;

                        default:
                            FechaVen = FechaIni;
                            break;
                        }
                        listaR.Fecha_Vencimiento = FechaVen.ToString("dddd,dd MMMM yyyy");
                    }
                    conexion.Cerrar();
                    listas.Add(listaR);
                }
                conexionHuella.Cerrar();
                return(listas);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return(null);
            }
        }
Ejemplo n.º 5
0
        private void Regis(Int64 ID)
        {
            int ok1;

            try
            {
                DateTime       Hoy             = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
                DateTime       Manana          = Hoy.AddDays(1);
                ConexionHuella conexionHuella1 = new ConexionHuella();
                conexionHuella1.Abrir();
                string     com  = "SELECT ID FROM REGISTROS WHERE (FECHAYHORA>@FECHAHOY AND FECHAYHORA<@FECHAMANANA) AND IDUSUARIO=@USSERACTIVO AND ID=@IDCLIENTE";
                SqlCommand cmd1 = new SqlCommand(com, conexionHuella1.Conectarbd);
                cmd1.Parameters.AddWithValue("@FECHAHOY", Hoy);
                cmd1.Parameters.AddWithValue("@FECHAMANANA", Manana);
                cmd1.Parameters.AddWithValue("@USSERACTIVO", UsserID);
                cmd1.Parameters.AddWithValue("@IDCLIENTE", ID);
                SqlDataReader reader = cmd1.ExecuteReader();
                ok1 = 0;
                while (reader.Read())
                {
                    ok1 = ok1 + 1;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ToString());
                ok1 = 2;
            }
            if (ok1 == 0)
            {
                try
                {
                    DateTime dateTime = DateTime.Now;

                    ConexionHuella conexionHuella = new ConexionHuella();
                    conexionHuella.Abrir();
                    string     comando = "INSERT INTO REGISTROS (ID,FECHAYHORA,IDUSUARIO,FECHA) VALUES(@ID,@FECHAYHORA,@IDUSUARIO,@FECHA)";
                    SqlCommand cmd     = new SqlCommand(comando, conexionHuella.Conectarbd);
                    cmd.Parameters.AddWithValue("@ID", ID);
                    cmd.Parameters.AddWithValue("@FECHAYHORA", dateTime.ToString("yyyy-MM-dd HH:mm:ss"));
                    cmd.Parameters.AddWithValue("@IDUSUARIO", UsserID);
                    cmd.Parameters.AddWithValue("@FECHA", dateTime.Date.ToString("yyyy-MM-dd"));

                    int ok = cmd.ExecuteNonQuery();
                    if (ok == 1)
                    {
                    }
                    else
                    {
                        MessageBox.Show("Error al registrar ingreso", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    conexionHuella.Cerrar();

                    try
                    {
                        Conexion conexion = new Conexion();
                        conexion.Abrir();
                        string     com  = "SELECT NINGRESOS.FECHA_INICIO,INGRESOS.TIPO_INGRE FROM CLIENTES INNER JOIN (select max(FECHA_INICIO)AS FECHA_INICIO,DOC_CLIENTE from INGRESOS group by DOC_CLIENTE) AS NINGRESOS  ON NINGRESOS.DOC_CLIENTE = CLIENTES.ID_CLIENTE INNER JOIN INGRESOS ON NINGRESOS.DOC_CLIENTE = INGRESOS.DOC_CLIENTE AND NINGRESOS.FECHA_INICIO=INGRESOS.FECHA_INICIO WHERE CLIENTES.ID_CLIENTE=@ID ";
                        SqlCommand cmd3 = new SqlCommand(com, conexion.Conectarbd);
                        cmd3.Parameters.AddWithValue("@ID", ID);

                        SqlDataReader reader2 = cmd3.ExecuteReader();
                        int           ven     = 0;
                        while (reader2.Read())
                        {
                            string TipoPago = reader2["TIPO_INGRE"].ToString();
                            //listaR.Tipo_Pago = reader2["TIPO_INGRE"].ToString();
                            DateTime FechaIni = Convert.ToDateTime(reader2["FECHA_INICIO"].ToString());
                            DateTime FechaVen;
                            switch (TipoPago)
                            {
                            case "Mensual                  ":
                                FechaVen = FechaIni.AddMonths(1);
                                break;

                            case "Semanal                  ":
                                FechaVen = FechaIni.AddDays(7);
                                break;

                            case "Quincenal                ":
                                FechaVen = FechaIni.AddDays(15);
                                break;

                            case "2 Meses                  ":
                                FechaVen = FechaIni.AddMonths(2);
                                break;

                            case "3 Meses                  ":
                                FechaVen = FechaIni.AddMonths(3);
                                break;

                            case "6 Meses                  ":
                                FechaVen = FechaIni.AddMonths(6);
                                break;

                            case "Anual                    ":
                                FechaVen = FechaIni.AddYears(1);
                                break;

                            default:
                                FechaVen = FechaIni;
                                break;
                            }
                            if (FechaVen > DateTime.Now)
                            {
                                Señal(true);
                            }
                            else
                            {
                                Señal(false);
                            }
                        }
                        conexion.Cerrar();

                        if (ven == 1)
                        {
                            Veri = true;
                        }
                        else
                        {
                            Veri = false;
                        }
                        //Stop();
                        //Init2();
                        //Start();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }

                    //Listar();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
            else
            {
                if (ok1 == 1)
                {
                    //MessageBox.Show("El Usuario ya se registro en este turno...", "Error de registro", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                }
                else
                {
                    MessageBox.Show("Error de captura", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }