private void materialRaisedButton1_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(@"Data Source=ACHREF\MSSQLSERVER01;Initial Catalog=projet;Integrated Security=True");

            con.Open();
            String     username = usernameTextField.Text;
            String     password = passwordTextField.Text;
            SqlCommand cmd      = new SqlCommand("SELECT * FROM enseignants WHERE login=@username AND password=@password", con);
            // SqlCommand cmd2 = new SqlCommand("INSERT INTO system_log(idEtudiant, log_on_time) VALUES (@idE, @date)", con);
            String date = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszzz");

            // cmd2.Parameters.AddWithValue("@idE", username);
            // cmd2.Parameters.AddWithValue("@date", date);
            cmd.Parameters.AddWithValue("@username", username);
            cmd.Parameters.AddWithValue("@password", password);
            using (SqlDataReader dr = cmd.ExecuteReader())
            {
                if (dr.Read())
                {
                    String id = dr[0].ToString();
                    Console.WriteLine(id);
                    //MessageBox.Show("LOGIN SUCCESSFUL");
                    DashboardEns dashboard = new DashboardEns();
                    dashboard.Show();
                }
                else
                {
                    MessageBox.Show("ACCESS DENIED !");
                }
            }
            con.Close();
        }
        private void materialRaisedButton1_Click(object sender, EventArgs e)
        {
            String        note          = Note.Text;
            String        justification = Justification.Text;
            String        matiere       = Matiere.Text;
            String        coefficient   = Coefficient.Text;
            SqlConnection con           = new SqlConnection(@"Data Source=ACHREF\MSSQLSERVER01;Initial Catalog=projet;Integrated Security=True");

            con.Open();
            SqlCommand cmd2 = new SqlCommand("INSERT INTO notes(Note,Justification,Coefficient,Matiere) VALUES (@note, @justification,@coefficient,@matiere)", con);

            cmd2.Parameters.AddWithValue("@note", note);
            cmd2.Parameters.AddWithValue("@justification", justification);
            cmd2.Parameters.AddWithValue("@Coefficient", coefficient);
            cmd2.Parameters.AddWithValue("@matiere", matiere);


            int i = cmd2.ExecuteNonQuery();

            if (i != -1)

            {
                MessageBox.Show("INSERT SUCCESSFUL");
                DashboardEns dashboardEns = new DashboardEns();
                dashboardEns.Show();
            }

            con.Close();
        }
Ejemplo n.º 3
0
        private void recEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            switch (e.Result.Text)
            {
            case "show":
            {
                try
                {
                    ds = new DataSet();
                    SqlConnection con = new SqlConnection(@"Data Source=ACHREF\MSSQLSERVER01;Initial Catalog=projet;Integrated Security=True");
                    con.Open();
                    SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM Notes", con);
                    da.Fill(ds);
                    // SqlCommand cmd =new SqlCommand ("SELECT * FROM Notes", con);
                    List <Notes> l = new List <Notes>();

                    /* SqlDataReader dr =  cmd.ExecuteReader();
                     * while(dr.Read())
                     * {
                     *   Notes n = new Notes();
                     *   n.nom = dr.GetString(1);
                     *   n.justification = dr.GetString(2);
                     *   n.coefficient = dr.GetInt32(3);
                     * }*/
                    dataGridView1.DataSource = ds.Tables[0];


                    con.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Connection Error");
                }
            }
            break;

            case "dashboard":
            {
                DashboardEns d = new DashboardEns();
                d.Show();
            }
            break;
            }
        }