public void Navigate() { while (userInput != e) { // NAVIGATION PANEL Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("____________________________TYPE TO NAVIGATE________________________________"); Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("============================================================================"); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"| {"(1) STUDENTS",-12} | {"(2) TRAINERS",-12} | {"(3) ASSIGNMENTS",-12} | {"(4) COURSES",-11} | {"(E) RETURN",-9} |"); Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("============================================================================"); Console.ForegroundColor = ConsoleColor.White; userInput = Console.ReadLine(); // Simple SELECT QUERYS if (userInput == one) { sqlStudent MyS1 = new sqlStudent(); MyS1.StudentSelectOutput(); } else if (userInput == two) { sqlTrainer MyT1 = new sqlTrainer(); MyT1.TrainerSelectOutput(); } else if (userInput == three) { sqlAssignment MyA1 = new sqlAssignment(); MyA1.AssignmentSelectOutput(); } else if (userInput == four) { sqlCourse MyC1 = new sqlCourse(); MyC1.CourseSelectOutput(); } // Exit and Wrong Input Cases else if (userInput == e) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("EXIT"); Console.ForegroundColor = ConsoleColor.White; } else { Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("Unindentified Input, Please Choose Again"); Console.ForegroundColor = ConsoleColor.White; } } }
public void InsertIntoStudentPerCourse() { // Bring the Table STUDENT to see/choose a specific STUDENT KEY Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("#==========================================================================#"); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"| EXISTING STUDENTS |"); Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("#==========================================================================#"); Console.ForegroundColor = ConsoleColor.White; sqlStudent MyS2 = new sqlStudent(); MyS2.StudentSelectOutput(); // Input Data Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"< TIP: Insert KEY of choosen STUDENT from the Table above >"); Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("----------------------------------------------------------------------------"); Console.ForegroundColor = ConsoleColor.White; Console.Write("Input Student ID: "); Student_ID = Console.ReadLine(); // Bring the Table COURSES to see/choose a specific COURSE KEY Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("#==========================================================================#"); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"| EXISTING COURSES |"); Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("#==========================================================================#"); Console.ForegroundColor = ConsoleColor.White; sqlCourse MyC2 = new sqlCourse(); MyC2.CourseSelectOutput(); // Input Data Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"< TIP: Insert KEY of choosen COURSE from the Table above >"); Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("----------------------------------------------------------------------------"); Console.ForegroundColor = ConsoleColor.White; Console.Write("Input Course Title: "); CourseTitle = Console.ReadLine(); string splInsertStudentCourse = "INSERT INTO CourseStudent(CourseTitle, Student_ID ) " + "VALUES (@coursetitle, @studentid)"; try { using (SqlConnection conn = new SqlConnection(ConnectionString.connection)) { conn.Open(); using (SqlCommand cmInsert = new SqlCommand(splInsertStudentCourse, conn)) { cmInsert.Parameters.Add(new SqlParameter("CourseTitle", CourseTitle)); cmInsert.Parameters.Add(new SqlParameter("studentid", Student_ID)); int rowsAffected = cmInsert.ExecuteNonQuery(); // Display A message for the Inserted STUDENT Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("#==========================================================================#"); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"| Successful Insertion: {rowsAffected,-30} |"); Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("#==========================================================================#"); Console.ForegroundColor = ConsoleColor.White; // Bring the Table STUDENT/COURSE sqlStudentsPerCourse MySperC2 = new sqlStudentsPerCourse(); MySperC2.StudentCoursetOutput(); // Display A message for the Inserted STUDENT again Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("#==========================================================================#"); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"| Successful Insertion: {rowsAffected,-30} |"); Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("#==========================================================================#"); Console.ForegroundColor = ConsoleColor.White; } } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public void InsertIntoStudent() { // Display STUDENTS Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("#==========================================================================#"); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"| EXISTING STUDENTS |"); Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("#==========================================================================#"); Console.ForegroundColor = ConsoleColor.White; sqlStudent MyS2 = new sqlStudent(); MyS2.StudentSelectOutput(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"< TIP: Insert a 5 Character KEY (example: ST088) >"); Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("----------------------------------------------------------------------------"); Console.ForegroundColor = ConsoleColor.White; Console.Write("Input Student ID: "); Student_ID = Console.ReadLine(); Console.Write("Input First name: "); FirstName = Console.ReadLine(); Console.Write("Input Last Name: "); LastName = Console.ReadLine(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"< TIP: Insert Format YYYY/MM/DD (example: 1988/08/08) >"); Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("----------------------------------------------------------------------------"); Console.ForegroundColor = ConsoleColor.White; Console.Write("Input Date of Birth: "); BirthDate = Console.ReadLine(); Console.Write("Input Tuition Fees Amount: "); TuitionFees = Console.ReadLine(); string sqlInsertStudents = "INSERT INTO Student(Student_ID, FirstName, LastName, BirthDate, TuitionFees) " + "VALUES (@studentid, @firstname, @lastname, @birthdate, @tuitionfees)"; try { using (SqlConnection conn = new SqlConnection(ConnectionString.connection)) { conn.Open(); using (SqlCommand cmInsert = new SqlCommand(sqlInsertStudents, conn)) { cmInsert.Parameters.Add(new SqlParameter("studentid", Student_ID)); cmInsert.Parameters.Add(new SqlParameter("firstname", FirstName)); cmInsert.Parameters.Add(new SqlParameter("lastname", LastName)); cmInsert.Parameters.Add(new SqlParameter("birthdate", BirthDate)); cmInsert.Parameters.Add(new SqlParameter("tuitionfees", TuitionFees)); int rowsAffected = cmInsert.ExecuteNonQuery(); // Display A message for the Inserted STUDENT Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("#==========================================================================#"); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"| Students Inserted Succesfully: {rowsAffected, -26} |"); Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("#==========================================================================#"); Console.ForegroundColor = ConsoleColor.White; // Bring the Table STUDENT to see our newly Input STUDENT sqlStudent MyIS1 = new sqlStudent(); MyIS1.StudentSelectOutput(); // Again, Show that the Student was Inserted at the end of the Table STUDENTS Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("#==========================================================================#"); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"| Students Inserted Succesfully: {rowsAffected,-26} |"); Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("#==========================================================================#"); Console.ForegroundColor = ConsoleColor.White; } } } catch (Exception ex) { Console.WriteLine(ex.Message); } }