private void homeworkMenuBtn_Click(object sender, EventArgs e) { Hide(); studentHomework sh = new studentHomework(_username); sh.Show(); }
private void btnEndPractice_Click(object sender, EventArgs e) { using (SqlConnection conn = new SqlConnection(@"Data Source=DESKTOP-I1C7SOR;Initial Catalog=mathClassroomDB;Integrated Security=True")) { string query = @"UPDATE Homework SET Score = @Score, Completed = @Completed, DateSubmitted = @DateSubmitted, Time = @Time WHERE Id = @Id"; conn.Open(); SqlCommand command = new SqlCommand(query, conn); command.Parameters.AddWithValue("@Score", score); command.Parameters.AddWithValue("@Completed", true); command.Parameters.AddWithValue("@DateSubmitted", DateTime.Now.ToShortDateString()); command.Parameters.AddWithValue("@Time", lblTimer.Text); command.Parameters.AddWithValue("@Id", _id); command.ExecuteNonQuery(); conn.Close(); } MessageBox.Show("Your score has been saved.", "Thank You", MessageBoxButtons.OK, MessageBoxIcon.Information); Hide(); studentHomework sh = new studentHomework(_username); sh.Show(); }