Beispiel #1
0
        private void Hora()
        {
            Byte[] encry = Encoding.Unicode.GetBytes(DateTime.Now.ToString("dd/MM/yyyy"));
            string fecha = Convert.ToBase64String(encry);

            File.WriteAllText("Key2", fecha);
            ComprobarFecha c = new ComprobarFecha();

            c.Encriptar("Key2");
            Application.Exit();
        }
Beispiel #2
0
        private void ModoAdmin()
        {
            string limite = "Administrador Modo";

            Byte[] ecrypt = Encoding.Unicode.GetBytes(limite);
            File.WriteAllText("Key", Convert.ToBase64String(ecrypt), Encoding.Unicode);
            ComprobarFecha c = new ComprobarFecha();

            c.Encriptar("Key");

            frmHora h = new frmHora();

            if (h.error == true)
            {
                h.error = false;
                Application.Exit();
            }
        }
Beispiel #3
0
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            ComprobarFecha f = new ComprobarFecha();

            f.Desencriptar(Application.StartupPath + @"\Config\IO.dat");
            Form1 fo = new Form1();

            if (File.ReadAllText(Application.StartupPath + @"\Config\IO.dat") == txtcontra.Text)
            {
                frmEmpleados em = new frmEmpleados();
                em.Visible = true;
                Close();
            }
            else
            {
                MessageBox.Show("La contraseña ha sido incorrecta");
            }
            f.Encriptar(Application.StartupPath + @"\Config\IO.dat");
        }
Beispiel #4
0
        private void ModoPrueba()
        {
            DateTime tiempo = DateTime.Now;

            string limite = tiempo.AddDays(60).ToString("dd/MM/yyyy");

            Byte[] ecrypt = Encoding.Unicode.GetBytes(limite);
            File.WriteAllText("Key", Convert.ToBase64String(ecrypt), Encoding.Unicode);
            ComprobarFecha c = new ComprobarFecha();

            c.Encriptar("Key");
            File.WriteAllText("Tiempo de Licencia.txt", 2.ToString() + " Meses");

            frmHora h = new frmHora();

            if (h.error == true)
            {
                h.error = false;
                Application.Exit();
            }
        }
Beispiel #5
0
        private void Licencia()
        {
            if (txtMes.Text == "" && txtAño.Text == "" && txtDias.Text == "")
            {
                MessageBox.Show("Limite no establecido", "Error");
                this.Close();
            }
            else
            {
                if (txtDias.Text == "")
                {
                    txtDias.Text = "0";
                }

                if (txtMes.Text == "")
                {
                    txtMes.Text = "0";
                }

                if (txtAño.Text == "")
                {
                    txtAño.Text = "0";
                }

                string limite = "";

                double dia = 0;
                int    mes = 0, año = 0;

                dia = double.Parse(txtDias.Text);
                mes = int.Parse(txtMes.Text);
                año = int.Parse(txtAño.Text);

                if (mes > 0)
                {
                    dia = (30 * mes) + dia;
                }
                if (año > 0)
                {
                    dia = (360 * año) + dia;
                }

                DateTime tiempo = DateTime.Now;

                limite = tiempo.AddDays(dia).ToString("dd/MM/yyyy");

                Byte[] ecrypt = Encoding.Unicode.GetBytes(limite);
                File.WriteAllText("Key", Convert.ToBase64String(ecrypt), Encoding.Unicode);

                ComprobarFecha c = new ComprobarFecha();
                c.Encriptar("Key");

                File.WriteAllText("Tiempo de Licencia.txt", dia.ToString() + " Dias");

                frmHora h = new frmHora();
                if (h.error == true)
                {
                    h.error = false;
                    Application.Exit();
                }
            }
        }
Beispiel #6
0
        private void Aceptar()
        {
            if (txtNue.TextLength >= 6 && txtNue.TextLength <= 16)
            {
                lblNueva.ForeColor = Color.Black;

                if (File.Exists(Application.StartupPath + @"\Config\IO.dat"))
                {
                    ComprobarFecha c = new ComprobarFecha();
                    c.Desencriptar(Application.StartupPath + @"\Config\IO.dat");
                    string contra = File.ReadAllText(Application.StartupPath + @"\Config\IO.dat");
                    if (txtAnti.Text == contra)
                    {
                        if (txtConfirm.Text == txtNue.Text)
                        {
                            File.WriteAllText(Application.StartupPath + @"\Config\IO.dat", txtNue.Text);
                            lblInfoNue.ForeColor  = Color.Green;
                            lblInfoConf.ForeColor = Color.Green;
                            lblInfo.ForeColor     = Color.Green;
                            lblInfo.Text          = "Se ha modificado la contraseña";
                            lblInfoNue.Text       = "Coinciden";
                            lblInfoConf.Text      = "Coiciden";
                            btnAcept.Text         = "Cerrar";
                        }
                        else
                        {
                            lblInfoNue.ForeColor  = Color.Red;
                            lblInfoConf.ForeColor = Color.Red;
                            lblInfoNue.Text       = "No coinciden";
                            lblInfoConf.Text      = "No coinciden";
                        }
                    }
                    else
                    {
                        lblInfoAnti.ForeColor = Color.Red;
                        lblInfoAnti.Text      = "La contraseña no coincide";
                        if (txtNue.Text != txtConfirm.Text)
                        {
                            lblInfoNue.ForeColor  = Color.Red;
                            lblInfoConf.ForeColor = Color.Red;
                            lblInfoNue.Text       = "No coinciden";
                            lblInfoConf.Text      = "No coinciden";
                        }
                    }
                    c.Encriptar(Application.StartupPath + @"\Config\IO.dat");
                }
                else
                {
                    if (txtConfirm.Text == txtNue.Text)
                    {
                        ComprobarFecha c = new ComprobarFecha();
                        File.WriteAllText(Application.StartupPath + @"\Config\IO.dat", txtNue.Text);
                        c.Encriptar(Application.StartupPath + @"\Config\IO.dat");
                        lblInfoNue.ForeColor  = Color.Green;
                        lblInfoConf.ForeColor = Color.Green;
                        lblInfo.ForeColor     = Color.Green;
                        lblInfo.Text          = "Se ha creado la contraseña";
                        lblInfoNue.Text       = "Coinciden";
                        lblInfoConf.Text      = "Coiciden";
                        btnAcept.Text         = "Cerrar";
                    }
                    else
                    {
                        lblInfoNue.ForeColor  = Color.Red;
                        lblInfoConf.ForeColor = Color.Red;
                        lblInfoNue.Text       = "No coinciden";
                        lblInfoConf.Text      = "No coinciden";
                    }
                }
            }
            else
            {
                lblNueva.ForeColor = Color.Red;
            }
        }