예제 #1
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");
        }
예제 #2
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;
            }
        }