Oppure

Loading
17/03/16 21:50
XExplosion
Salve a tutti, ho creato con un mio amico un programma che registra le password in Windows Form (e funziona), e TEORICAMENTE dovrebbe nascondere il Form precedente, ma non lo fa. Ecco il codice:

//Form1

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Password_Register_v3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Form2 frm = new Form2();
            frm.ShowDialog();
            this.Hide();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Form3 frm = new Form3();
            frm.ShowDialog();
            this.Hide();
        }
    }
}

//Form2

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace Password_Register_v3
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            
        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {
            textBox3.PasswordChar = '*';
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            textBox2.PasswordChar = '*';
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string username = textBox1.Text;
            string accw = Environment.UserName;
            if (Directory.Exists(@"C:\Users\" + accw + "\Desktop\Passwords\" + username))
            {
                textBox1.Text = "Il nome utente scelto esiste gia'.";
            }
            else if (!Directory.Exists(@"C:\Users\" + accw + "\Desktop\Passwords\" + username))
            {
                Directory.CreateDirectory(@"C:\Users\" + accw + "\Desktop\Passwords\" + username);
                if (textBox3.Text == textBox2.Text)
                {
                    string pass = textBox2.Text;
                    Directory.CreateDirectory(@"C:\Users\" + accw + "\Desktop\Passwords\" + username + "\Accounts");
                    StreamWriter user = new StreamWriter(@"C:\Users\" + accw + "\Desktop\Passwords\" + username + "\password.txt", false);
                    user.Write(pass);
                    user.Close();
                    Form3 frm = new Form3();
                    frm.ShowDialog();
                    this.Hide();
                }
                else
                {
                    textBox2.Text = "Le password non corrispondono.";
                    textBox3.Text = "Le password non corrispondono.";
                }
            }
        }
    }
}

//Form3

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace Password_Register_v3
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            string accw = Environment.UserName;
            string username = textBox1.Text;
            if (!Directory.Exists(@"C:\Users\" + accw + "\Desktop\Passwords\" + username))
            {
                textBox1.Text = "Non esiste questo nome utente.";
            }
            else if (Directory.Exists(@"C:\Users\" + accw + "\Desktop\Passwords\" + username))
            {
                string userpass = File.ReadAllText(@"C:\Users\" + accw + "\Desktop\Passwords\" + username + "\password.txt");
                if (textBox2.Text == userpass)
                {
                    Form4 frm = new Form4();
                    frm.ShowDialog();
                    this.Hide();
                }
            }
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            textBox2.PasswordChar = '*';
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }
    }
}

//Form4

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Password_Register_v3
{
    public partial class Form4 : Form
    {
        public Form4()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string scelta;
            scelta = textBox1.Text;
            switch (scelta)
            {
                case "1":
                    Form5 frm = new Form5();
                    frm.ShowDialog();
                    this.Hide();
                    break;
                case "2":
                    Form6 frm2 = new Form6();
                    frm2.ShowDialog();
                    this.Hide();
                    break;
                case "3":
                    Form7 frm3 = new Form7();
                    frm3.ShowDialog();
                    this.Hide();
                    break;
                default:
                    textBox1.Text = "Scelta non valida, riprovare.";
                    break;
            }
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            
        }
    }
}

//Form5

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace Password_Register_v3
{
    public partial class Form5 : Form
    {
        public Form5()
        {
            InitializeComponent();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            textBox1.PasswordChar = '*';
        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {
            textBox3.PasswordChar = '*';
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            textBox2.PasswordChar = '*';
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string accw = Environment.UserName;
            string username = textBox4.Text;
            if (Directory.Exists(@"C:\Users\" + accw + "\Desktop\Passwords\" + username))
            {
                string pass = File.ReadAllText(@"C:\Users\" + accw + "\Desktop\Passwords\" + username + "\password.txt");
                if (textBox1.Text == pass)
                {
                    if (textBox3.Text == textBox2.Text)
                    {
                        StreamWriter password = new StreamWriter(@"C:\Users\" + accw + "\Desktop\Passwords\" + username + "\password.txt", false);
                        password.Write(textBox2.Text);
                        password.Close();
                        Form4 frm = new Form4();
                        frm.ShowDialog();
                        this.Hide();
                    }
                    else
                    {
                        textBox2.Text = "Password non uguali.";
                        textBox3.Text = "Password non uguali.";
                    }
                }
                else
                {
                    textBox1.Text = "Password non valida.";
                }
            }
            else if (!Directory.Exists(@"C:\Users\" + accw + "\Desktop\Passwords\" + username))
            {
                textBox4.Text = "Il nome utente non esiste.";
            }
        }

        private void label2_Click(object sender, EventArgs e)
        {

        }
    }
}

//Form6

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace Password_Register_v3
{
    public partial class Form6 : Form
    {
        public Form6()
        {
            InitializeComponent();
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            textBox2.PasswordChar = '*';
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string sito = textBox1.Text;
            string username = textBox3.Text;
            string pass = textBox2.Text;
            string accw = Environment.UserName;
            if (!Directory.Exists(@"C:\Users\" + accw + "\Desktop\Passwords\" + username))
            {
                textBox3.Text = "Nome utente non esistente.";
            }
            else if (Directory.Exists(@"C:\Users\" + accw + "\Desktop\Passwords\" + username))
            {
                StreamWriter dati = new StreamWriter(@"C:\Users\" + accw + "\Desktop\Passwords\" + username + "\Accounts\" + sito + ".txt", false);
                dati.Write(pass);
                dati.Close();
                Form4 frm = new Form4();
                frm.ShowDialog();
                this.Hide();
            }
        }
    }
}

//Form7

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace Password_Register_v3
{
    public partial class Form7 : Form
    {
        public Form7()
        {
            InitializeComponent();
        }

        private void label4_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            string sito = textBox2.Text;
            string username = textBox1.Text;
            string accw = Environment.UserName;
            if (!Directory.Exists(@"C:\Users\" + accw + "\Desktop\Passwords\" + username))
            {
                textBox1.Text = "Nome utente non esistente.";
            }
            else if (Directory.Exists(@"C:\Users\" + accw + "\Desktop\Passwords\" + username))
            {
                if (File.Exists(@"C:\Users\" + accw + "\Desktop\Passwords\" + username + "\Accounts\" + sito + ".txt"))
                {
                    string passletta = File.ReadAllText(@"C:\Users\" + accw + "\Desktop\Passwords\" + username + "\Accounts\" + sito + ".txt");
                    label4.Text = "Password: " + passletta;
                }
                else if (!File.Exists(@"C:\Users\" + accw + "\Desktop\Passwords\" + username + "\Accounts\" + sito + ".txt"))
                {
                    textBox2.Text = "Sito/account mai registrato.";
                }
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Form4 frm = new Form4();
            frm.ShowDialog();
            this.Hide();
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }
    }
}



Vi ringrazio per l'aiuto. Ah, non usate termini troppo specifici, ancora non li ho capiti molto bene ahah! Anzi, se qualcuno me li spiega se li usa ahah :rotfl: ! :rofl: :k:
aaa
18/03/16 6:26
nessuno
Devi invertire l'ordine

this.Hide();
frm.ShowDialog();
Ricorda che nessuno è obbligato a risponderti e che nessuno è perfetto ...
---
Il grande studioso italiano Bruno de Finetti ( uno dei padri fondatori del moderno Calcolo delle probabilità ) chiamava il gioco del Lotto Tassa sulla stupidità.
18/03/16 13:32
XExplosion
Postato originariamente da nessuno:

Devi invertire l'ordine

this.Hide();
frm.ShowDialog();


Grazie mille! Ho risolto! :k: :asd:
aaa