コード例 #1
0
        private void Rezervovat_Click(object sender, EventArgs e)
        {
            Regex  rg            = new Regex(@"(?<=Jméno:)\S+");
            Regex  rx            = new Regex(@"(?<=Příjmení:)\S+");
            string jmeno         = "";
            string prijmeni      = "";
            string cestaUzivatel = Environment.CurrentDirectory + @"\Users\";

            using (StreamReader sr = new StreamReader(cestaUzivatel + user + ".txt"))
            {
                string radek;
                while ((radek = sr.ReadLine()) != null)
                {
                    if (rg.IsMatch(radek))
                    {
                        jmeno = Convert.ToString(rg.Match(radek));
                    }
                    if (rx.IsMatch(radek))
                    {
                        prijmeni = Convert.ToString(rx.Match(radek));
                    }
                }
            }

            string cesta     = Environment.CurrentDirectory + @"\Rezervace\";
            string cestaAuta = Environment.CurrentDirectory + @"\Cars\";

            using (StreamReader sr = new StreamReader(cestaAuta + textBox_ID.Text + ".txt"))
            {
                string radek;
                while ((radek = sr.ReadLine()) != null)
                {
                    if (radek == "Zarezervováno")
                    {
                        label6.Visible = true;
                    }
                }
            }
            if (label6.Visible == false)
            {
                using (StreamWriter sw = new StreamWriter(Path.Combine(cesta, user + ".txt"), true))
                {
                    sw.WriteLine("Jméno:" + jmeno);
                    sw.WriteLine("Přijmení:" + prijmeni);
                    sw.WriteLine("ID rezervovaného auta:" + textBox_ID.Text);
                }
                using (StreamWriter sw = new StreamWriter(Path.Combine(cestaAuta, textBox_ID.Text + ".txt"), true))
                {
                    sw.WriteLine("Zarezervováno");
                }
                this.Hide();
                u.Show();
            }
        }
コード例 #2
0
        private void Potvrdit_Click(object sender, EventArgs e)
        {
            string cesta = Environment.CurrentDirectory + @"\Users\" + user + ".txt";

            string h      = "";
            SHA256 sha256 = SHA256.Create();

            byte[] StareHesloHash;
            byte[] NoveHesloHash;
            StareHesloHash = sha256.ComputeHash(Encoding.UTF8.GetBytes(stareHeslo.Text));
            NoveHesloHash  = sha256.ComputeHash(Encoding.UTF8.GetBytes(noveHeslo.Text));
            bool b = true;

            using (StreamReader sr = new StreamReader(cesta))
            {
                Regex  rg = new Regex(@"(?<=Heslo:)\S+");
                string radek;
                while ((radek = sr.ReadLine()) != null)
                {
                    if (rg.IsMatch(radek))
                    {
                        h = Convert.ToString(rg.Match(radek));
                    }
                    if (radek == "zmenaHesla")
                    {
                        b = false;
                    }
                }
            }
            if (b == false)
            {
                File.WriteAllText(cesta, File.ReadAllText(cesta).Replace("zmenaHesla", ""));
            }
            if (BitConverter.ToString(StareHesloHash).Replace("-", "").ToLower() == h)
            {
                this.Hide();
                u.Show();
                string he = BitConverter.ToString(NoveHesloHash).Replace("-", "").ToLower();
                File.WriteAllText(cesta, Regex.Replace(File.ReadAllText(cesta), @"(?<=Heslo:)\S+", he));
            }
            else
            {
                label6.Visible = true;
            }
        }
コード例 #3
0
 private void Zpet_Click(object sender, EventArgs e)
 {
     this.Hide();
     u.Show();
 }
コード例 #4
0
ファイル: Login.cs プロジェクト: Standik24/Vozovy_Park_V2.1
        private void Prihlasit_Click(object sender, EventArgs e)
        {
            byte[] ujmeno = Encoding.GetEncoding("UTF-8").GetBytes(user.Text);
            SHA256 sha256 = SHA256.Create();

            byte[] ujmenoHash      = sha256.ComputeHash(ujmeno);
            string un              = Convert.ToString(ByteArrayToString(ujmenoHash));
            bool   prvniPrihlaseni = true;

            string cesta = Environment.CurrentDirectory + @"\Users\" + un + ".txt";

            if (File.Exists(cesta) == false)
            {
                label3.Visible = true;
            }
            else
            {
                string h = "";
                byte[] adminHash;
                byte[] HesloHash;
                adminHash = sha256.ComputeHash(Encoding.UTF8.GetBytes("admin"));
                HesloHash = sha256.ComputeHash(Encoding.UTF8.GetBytes(heslo.Text));

                StreamReader sr = new StreamReader(cesta);
                Regex        rg = new Regex(@"(?<=Heslo:)\S+");
                Regex        rh = new Regex(@"(?<=Poslední přihlášení:)\S+");
                string       radek;
                bool         zmena = false;
                while ((radek = sr.ReadLine()) != null)
                {
                    if (rg.IsMatch(radek))
                    {
                        h = Convert.ToString(rg.Match(radek));
                    }
                    if (radek == "zmenaHesla")
                    {
                        zmena = true;
                    }
                    if (rh.IsMatch(radek))
                    {
                        prvniPrihlaseni = false;
                    }
                }
                sr.Close();


                if (BitConverter.ToString(adminHash).Replace("-", "").ToLower() != un && BitConverter.ToString(HesloHash).Replace("-", "").ToLower() == h)
                {
                    UvodniUz uz = new UvodniUz(un);
                    if (zmena == true)
                    {
                        this.Hide();
                        ZmenaHesla zm = new ZmenaHesla(uz, un);
                        zm.Show();
                    }
                    else
                    {
                        this.Hide();
                        uz.Show();
                    }
                }
                if (BitConverter.ToString(adminHash).Replace("-", "").ToLower() == un && BitConverter.ToString(HesloHash).Replace("-", "").ToLower() == h)
                {
                    this.Hide();
                    UvodniAd u = new UvodniAd(un, this);
                    u.Show();
                    if (prvniPrihlaseni == true)
                    {
                        using (StreamWriter sw = File.AppendText(cesta))
                        {
                            sw.WriteLine("Poslední přihlášení:" + DateTime.Now);
                            prvniPrihlaseni = false;
                        }
                    }
                    else
                    {
                        File.WriteAllText(cesta, Regex.Replace(File.ReadAllText(cesta), @"(?<=Poslední přihlášení:)\S+", DateTime.Now.ToString()));
                    }
                }
                else
                {
                    label6.Visible = true;
                }
            }
        }
コード例 #5
0
        private void Potvrdit_Click(object sender, EventArgs e)
        {
            string cesta = Environment.CurrentDirectory + @"\Users\" + user + ".txt";

            string h      = "";
            SHA256 sha256 = SHA256.Create();

            byte[] StareHesloHash;
            byte[] NoveHesloHash;
            StareHesloHash = sha256.ComputeHash(Encoding.UTF8.GetBytes(stareHeslo.Text));
            NoveHesloHash  = sha256.ComputeHash(Encoding.UTF8.GetBytes(noveHeslo.Text));

            using (StreamReader sr = new StreamReader(cesta))
            {
                Regex  rg = new Regex(@"(?<=Heslo:)\S+");
                string radek;
                while ((radek = sr.ReadLine()) != null)
                {
                    if (rg.IsMatch(radek))
                    {
                        h = Convert.ToString(rg.Match(radek));
                    }
                }
            }
            if (BitConverter.ToString(StareHesloHash).Replace("-", "").ToLower() == h)
            {
                this.Hide();
                u.Show();
                string j  = "";
                string p  = "";
                string uj = "";
                string he = BitConverter.ToString(NoveHesloHash).Replace("-", "").ToLower();
                using (StreamReader sr = new StreamReader(cesta))
                {
                    Regex  rg = new Regex(@"(?<=Jméno:)\S+");
                    Regex  rx = new Regex(@"(?<=Příjmení:)\S+");
                    Regex  ry = new Regex(@"(?<=Uživatelské jméno:)\S+");
                    Regex  rz = new Regex(@"(?<=Heslo:)\S+");
                    string radek;

                    while ((radek = sr.ReadLine()) != null)
                    {
                        if (rg.IsMatch(radek))
                        {
                            j = Convert.ToString(rg.Match(radek));
                        }
                        if (rx.IsMatch(radek))
                        {
                            p = Convert.ToString(rx.Match(radek));
                        }
                        if (ry.IsMatch(radek))
                        {
                            uj = Convert.ToString(ry.Match(radek));
                        }
                    }
                }

                using (StreamWriter sw = new StreamWriter(cesta, false))
                {
                    sw.WriteLine("Jméno:" + j);
                    sw.WriteLine("Příjmení:" + p);
                    sw.WriteLine("Uživatelské jméno:" + uj);
                    sw.WriteLine("Heslo:" + he);
                }
            }
        }
コード例 #6
0
        private void Prihlasit_Click(object sender, EventArgs e)
        {
            byte[] ujmeno = Encoding.GetEncoding("UTF-8").GetBytes(user.Text);
            SHA256 sha256 = SHA256.Create();

            byte[] ujmenoHash = sha256.ComputeHash(ujmeno);
            string un         = Convert.ToString(ByteArrayToString(ujmenoHash));

            string cesta = Environment.CurrentDirectory + @"\Users\" + un + ".txt";

            if (File.Exists(cesta) == false)
            {
                label3.Visible = true;
            }
            else
            {
                string h = "";
                byte[] adminHash;
                byte[] HesloHash;
                adminHash = sha256.ComputeHash(Encoding.UTF8.GetBytes("admin"));
                HesloHash = sha256.ComputeHash(Encoding.UTF8.GetBytes(heslo.Text));

                using (StreamReader sr = new StreamReader(cesta))
                {
                    Regex  rg = new Regex(@"(?<=Heslo:)\S+");
                    string radek;
                    while ((radek = sr.ReadLine()) != null)
                    {
                        if (rg.IsMatch(radek))
                        {
                            h = Convert.ToString(rg.Match(radek));
                        }
                    }
                }
                if (BitConverter.ToString(adminHash).Replace("-", "").ToLower() != un && BitConverter.ToString(HesloHash).Replace("-", "").ToLower() == h)
                {
                    this.Hide();
                    UvodniUz u = new UvodniUz(un);
                    u.Show();

                    using (StreamWriter sw = File.AppendText(cesta))
                    {
                        sw.WriteLine(DateTime.Now);
                    }
                }
                if (BitConverter.ToString(adminHash).Replace("-", "").ToLower() == un && BitConverter.ToString(HesloHash).Replace("-", "").ToLower() == h)
                {
                    this.Hide();
                    UvodniAd u = new UvodniAd(un);
                    u.Show();

                    using (StreamWriter sw = File.AppendText(cesta))
                    {
                        sw.WriteLine(DateTime.Now);
                    }
                }
                else
                {
                    label6.Visible = true;
                }
            }
        }