Beispiel #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
            Autentificare f = new Autentificare();

            f.Show();
        }
        private void button2_Click(object sender, EventArgs e)
        {
            string location = System.Reflection.Assembly.GetEntryAssembly().Location; //Scoatem locatia proiectului (inclusiv /bin/debug)

            string[] paths = location.Split('\\');                                    /* Impartim calea in mai multe siruri de caractere in functie de caracterul '\'.De exemplu, location = "C:\My Documents\Proiect\..."
                                                                                       * Atunci, paths[0] = "C:";
                                                                                       * paths[1] = "My Documents";
                                                                                       * paths[2] = "Proiect" etc.
                                                                                       */

            string path = "";                                                         // Initializam sirul de caractere in care vom memora calea catre baza de date

            for (int index = 0; index < paths.Length - 3; index++)                    // Parcurgem fiecare sir de caractere in afara de "bin" si "Debug"
            {
                path += paths[index] + '\\';                                          // Completam calea catre baza de date
            }

            path += "Bac.mdf"; // La calea catre fiserul unde se afla baza de date adaugam si denumirea acesteia
            using (SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=" + path + ";Integrated Security=True;User Instance=True"))
            {
                con.Open();
                SqlCommand cmd = new SqlCommand(@"select * from conturi where utilizator = @utilizator ", con);

                cmd.Parameters.AddWithValue("@utilizator", textBox1.Text);


                SqlDataReader reader = cmd.ExecuteReader();
                if (reader.Read())
                {
                    cmd.Parameters.Clear();
                    reader.Dispose();
                    cmd.CommandText = "update  conturi set Parola=@Parola where Utilizator=@Utilizator";
                    cmd.Parameters.AddWithValue("@Utilizator", textBox1.Text);
                    cmd.Parameters.AddWithValue("@Parola", textBox3.Text);


                    cmd.ExecuteNonQuery();
                    MessageBox.Show("Parola schimbata cu succes");
                    Meniu meniu = new Meniu();
                    meniu.Close();


                    this.Close();

                    Autentificare x = new Autentificare();
                    x.Show();
                }

                else
                {
                    MessageBox.Show("Utilizatorul nu exista");
                }
            }
        }
Beispiel #3
0
        private void pictureBox11_Click(object sender, EventArgs e)
        {
            string location = System.Reflection.Assembly.GetEntryAssembly().Location; //Scoatem locatia proiectului (inclusiv /bin/debug)

            string[] paths = location.Split('\\');                                    /* Impartim calea in mai multe siruri de caractere in functie de caracterul '\'.De exemplu, location = "C:\My Documents\Proiect\..."
                                                                                       * Atunci, paths[0] = "C:";
                                                                                       * paths[1] = "My Documents";
                                                                                       * paths[2] = "Proiect" etc.
                                                                                       */

            string path = "";                                                         // Initializam sirul de caractere in care vom memora calea catre baza de date

            for (int index = 0; index < paths.Length - 3; index++)                    // Parcurgem fiecare sir de caractere in afara de "bin" si "Debug"
            {
                path += paths[index] + '\\';                                          // Completam calea catre baza de date
            }

            path += "Bac.mdf"; // La calea catre fiserul unde se afla baza de date adaugam si denumirea acesteia
            using (SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=" + path + ";Integrated Security=True;User Instance=True"))
            {
                con.Open();
                SqlCommand cmd = new SqlCommand(@"update Conturi set Conectat = @con, TimpTotalStudiu = @timpSt WHERE Conectat = 1", con);

                DateTime now = DateTime.Now;

                string timpTrecut = (Autentificare.conectare - now).ToString();

                string secunde = "";
                for (int i = 7; i < 12; i++)
                {
                    secunde += timpTrecut[i];
                }

                double timp_total_studiu = double.Parse(secunde) + double.Parse(Autentificare.timp_studiu);

                cmd.Parameters.AddWithValue("@con", 0);
                cmd.Parameters.AddWithValue("@timpSt", timp_total_studiu / 100);

                cmd.ExecuteNonQuery();
            }


            soundplayer.Stop();
            this.Hide();
            Autentificare x = new Autentificare();

            x.Show();
        }