コード例 #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            if ((File.Exists(@"D:\Projekat\Admini\" + textBox1.Text + ".txt") == false) && (Program.privremena.Contains(textBox1.Text) == false))
            {
                if ((textBox5.Text == textBox2.Text) && (String.IsNullOrWhiteSpace(textBox5.Text) == false) && (String.IsNullOrWhiteSpace(textBox2.Text) == false))
                {
                    if ((String.IsNullOrWhiteSpace(textBox1.Text) == false) && (String.IsNullOrWhiteSpace(textBox3.Text) == false) && (String.IsNullOrWhiteSpace(textBox4.Text) == false))
                    {
                        Administrator Fejk  = HeadAdministrator.KreirajAdmina(textBox1.Text, textBox2.Text, textBox3.Text, textBox4.Text);
                        List <string> lista = new List <string>();
                        lista.Add(textBox1.Text);
                        lista.Add(textBox2.Text);
                        lista.Add(textBox3.Text);
                        lista.Add(textBox4.Text);
                        HeadAdministrator.Podaci.USERADMIN.Add(textBox1.Text);
                        HeadAdministrator.Podaci.ADMIN.Add(Fejk);
                        File.WriteAllLines(@"D:\Projekat\Admini\" + textBox1.Text + ".txt", lista);

                        MessageBox.Show("Admin kreiran");
                    }
                    else
                    {
                        MessageBox.Show("Molimo ispunite sva polja");
                    }
                }
                else
                {
                    MessageBox.Show("Unete lozinke nisu jednake");
                }
            }
            else
            {
                MessageBox.Show($"Korisnik {textBox1.Text} vec postoji");
            }
        }
コード例 #2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (Directory.Exists(@"D:\Projekat") == false)
            {
                System.IO.Directory.CreateDirectory(@"D:\Projekat");
                System.IO.Directory.CreateDirectory(@"D:\Projekat\Studenti");
                System.IO.Directory.CreateDirectory(@"D:\Projekat\Profesori");
                System.IO.Directory.CreateDirectory(@"D:\Projekat\Admini");
            }

            if (File.Exists(@"D:\Projekat\Studenti\liste.txt"))
            {
                try
                {
                    HeadAdministrator.Podaci.USERSTUD = File.ReadAllLines(@"D:\Projekat\Studenti\liste.txt").ToList();
                    if (String.IsNullOrWhiteSpace(HeadAdministrator.Podaci.USERSTUD[0]) == false)
                    {
                        foreach (string user in HeadAdministrator.Podaci.USERSTUD)
                        {
                            privremena = File.ReadAllLines(@"D:\Projekat\Studenti\" + user + ".txt").ToList();
                            Student stud = new Student(privremena[0], privremena[1], privremena[2], privremena[3], privremena[4], privremena[5]);
                            Indeks  indx = new Indeks(Convert.ToInt32(privremena[6]), privremena[7], Convert.ToInt32(privremena[8]), Convert.ToInt32(privremena[9]), privremena[10], stud);
                            stud.INDEKS = indx;
                            HeadAdministrator.Podaci.STUDENT.Add(stud);
                            HeadAdministrator.Podaci.INDEKS.Add(indx);
                            privremena.Clear();
                        }
                    }
                }
                catch
                {
                    string[] Jovan = { "Jovan", "Jovan", "Jovan", "jova123", "*****@*****.**", "0601010", "000", "Test Smer", "2019", "1", "Netflix&Chill" };

                    File.WriteAllText(@"D:\Projekat\Studenti\liste.txt", "Jovan");
                    File.WriteAllLines(@"D:\Projekat\Studenti\Janko.txt", Jovan);
                }
            }
            if (File.Exists(@"D:\Projekat\Profesori\liste.txt"))
            {
                try
                {
                    HeadAdministrator.Podaci.USERPROF = File.ReadAllLines(@"D:\Projekat\Profesori\liste.txt").ToList();
                    if (String.IsNullOrWhiteSpace(HeadAdministrator.Podaci.USERPROF[0]) == false)
                    {
                        foreach (string user in HeadAdministrator.Podaci.USERPROF)
                        {
                            privremena = File.ReadAllLines(@"D:\Projekat\Profesori\" + user + ".txt").ToList();
                            HeadAdministrator.Podaci.PROFESOR.Add(new Nastavnik(privremena[0], privremena[1], privremena[2], privremena[3], privremena[4], privremena[5]));
                            privremena.Clear();
                        }
                    }
                }
                catch
                {
                    string[] Marko = { "Marko", "Marko", "Marko", "marko123", "*****@*****.**", "Asistent" };
                    File.WriteAllText(@"D:\Projekat\Profesori\liste.txt", "Marko");
                    File.WriteAllLines(@"D:\Projekat\Profesori\Marko.txt", Marko);
                }
            }
            if (File.Exists(@"D:\Projekat\Admini\liste.txt"))
            {
                try
                {
                    HeadAdministrator.Podaci.USERADMIN = File.ReadAllLines(@"D:\Projekat\Admini\liste.txt").ToList();
                    if (String.IsNullOrWhiteSpace(HeadAdministrator.Podaci.USERADMIN[0]) == false)
                    {
                        foreach (string user in HeadAdministrator.Podaci.USERADMIN)
                        {
                            privremena = File.ReadAllLines(@"D:\Projekat\Admini\" + user + ".txt").ToList();
                            HeadAdministrator.Podaci.ADMIN.Add(HeadAdministrator.KreirajAdmina(privremena[0], privremena[1], privremena[2], privremena[3]));
                            privremena.Clear();
                        }
                    }
                }
                catch
                {
                    string[] Janko = { "Jancic", "janko123", "Janko", "Jancic" };
                    File.WriteAllText(@"D:\Projekat\Admini\liste.txt", "Janko");
                    File.WriteAllLines(@"D:\Projekat\Admini\Janko.txt", Janko);
                }
            }
            Program.privremena.Clear();
            Program.privremena.AddRange(HeadAdministrator.Podaci.USERADMIN);
            Program.privremena.AddRange(HeadAdministrator.Podaci.USERPROF);
            Program.privremena.AddRange(HeadAdministrator.Podaci.USERSTUD);
            Application.Run(new Form1());
        }