private void pictureBox3_Click(object sender, EventArgs e)
        {
            if(textBox1.Text=="ProfuDeInfo"&&textBox2.Text=="Admin")
            {
                Adaugar_Teorie adg = new Adaugar_Teorie();
                this.Hide();
                adg.ShowDialog();
            }
            if (textBox1.Text == "EditText" && textBox2.Text == "Admin")
            {
                Edit edit = new Edit();
                this.Hide();
                edit.ShowDialog();
            }
            else
            {
                string parola_criptata;
                parola_criptata = RC4Class.RC4_Class.RC4(textBox2.Text, "38577af7-379f-421d-ad29-cd1994521704");
                SQLiteConnection sqlite_conn;
                SQLiteCommand sqlite_cmd;
                SQLiteCommand sql_command;
                SQLiteDataReader sqlite_datareader;
                SQLiteDataReader sql_datareader;
                SQLiteDataReader datareader;
                SQLiteCommand   command;
                sqlite_conn = new SQLiteConnection("Data Source=LOGIN.db;Version=3;New=False;Compress=True;");
                try
                {
                    sqlite_conn.Open();
                    sqlite_cmd = sqlite_conn.CreateCommand();
                    sqlite_cmd.CommandText = "SELECT * FROM utilizatori where username='******'and password='******' ";
                    sqlite_datareader = sqlite_cmd.ExecuteReader();
                    int count = 0;
                    while (sqlite_datareader.Read())
                    {
                        count++;
                    }
                    if (count == 1)
                    {
                        sql_command = sqlite_conn.CreateCommand();
                        sql_command.CommandText = "SELECT avatar FROM utilizatori where username='******'and password='******' ";
                        sql_datareader = sql_command.ExecuteReader();
                        while(sql_datareader.Read())
                        {
                            byte[] img = (byte[])(sql_datareader["avatar"]);
                            if (img == null)
                                picAvatar.Image = null;
                            else
                            {
                                MemoryStream ms = new MemoryStream(img);
                                picAvatar.Image = Image.FromStream(ms);
                            }
                        }
                        logged_as = textBox1.Text;
                        panel1.Visible = false;
                        if(Form1.DECIZIE == "info")
                        {
                            command = sqlite_conn.CreateCommand();
                            command.CommandText = "SELECT * FROM utilizatori where username='******'and password='******' ";
                            datareader = command.ExecuteReader();
                            while (datareader.Read())
                            {
                                String puct1 = datareader.GetString(5);
                                String puct2 = datareader.GetString(6);
                                String puct3 = datareader.GetString(7);
                                String puct4 = datareader.GetString(8);
                                String puct5 = datareader.GetString(9);
                                pct1.Text = puct1;
                                pct2.Text = puct2;
                                pct3.Text = puct3;
                                pct4.Text = puct4;
                                pct5.Text = puct5;
                            }
                        }
                        if (Form1.DECIZIE == "mate")
                        {
                            command = sqlite_conn.CreateCommand();
                            command.CommandText = "SELECT * FROM utilizatori where username='******'and password='******' ";
                            datareader = command.ExecuteReader();
                            while (datareader.Read())
                            {
                                String puct1 = datareader.GetString(10);
                                String puct2 = datareader.GetString(11);
                                String puct3 = datareader.GetString(12);
                                String puct4 = datareader.GetString(13);
                                String puct5 = datareader.GetString(14);
                                pct1.Text = puct1;
                                pct2.Text = puct2;
                                pct3.Text = puct3;
                                pct4.Text = puct4;
                                pct5.Text = puct5;
                            }
                        }
                        if (Form1.DECIZIE == "bio")
                        {
                            command = sqlite_conn.CreateCommand();
                            command.CommandText = "SELECT * FROM utilizatori where username='******'and password='******' ";
                            datareader = command.ExecuteReader();
                            while (datareader.Read())
                            {
                                String puct1 = datareader.GetString(15);
                                String puct2 = datareader.GetString(16);
                                String puct3 = datareader.GetString(17);
                                String puct4 = datareader.GetString(18);
                                String puct5 = datareader.GetString(19);
                                pct1.Text = puct1;
                                pct2.Text = puct2;
                                pct3.Text = puct3;
                                pct4.Text = puct4;
                                pct5.Text = puct5;
                            }
                        }

                        MessageBox.Show("Datele sunt corecte!");
                        groupBox1.Visible = true;
                        label2.Text = textBox1.Text + "!";
                        LogOut.Visible = true;
                        NuAmCont.Visible = false;
                        sqlite_conn.Close();
                    }
                    else
                    {
                        MessageBox.Show("Datele sunt incorecte!");
                        textBox1.Clear();
                        textBox2.Clear();
                        sqlite_conn.Close();
                    }

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Beispiel #2
0
 private void pictureBox3_Click(object sender, EventArgs e)
 {
     if (textBox1.Text == "ProfuDeInfo" && textBox2.Text == "Admin")
     {
         Adaugar_Teorie adg = new Adaugar_Teorie();
         this.Hide();
         adg.ShowDialog();
     }
     if (textBox1.Text == "EditText" && textBox2.Text == "Admin")
     {
         Edit edit = new Edit();
         this.Hide();
         edit.ShowDialog();
     }
     else
     {
        logged_as = Database.Login.Main(textBox2.Text, textBox1.Text, picAvatar, groupBox1, label2, LogOut,
                                         NuAmCont, Form1.DECIZIE, pct1, pct2, pct3, pct4, pct5, logged_as);
     }
 }