예제 #1
0
        // Μεταφορά Assignment στην Βάση δεδομένων
        public static void AssignmentTransfer(string description, string title, object subDate, object oral, object total)
        {
            SqlConnection con = new SqlConnection(ConString);
            string        qr  = "Insert into Assignment ( Title ,Description, SubDateTime , Oralmark, TotalMark) VALUES (@Title, @Description , @SubDateTime , @Oralmark, @TotalMark)";

            SqlCommand cmd = new SqlCommand(qr, con);


            cmd.Parameters.AddWithValue("@Title", title);
            cmd.Parameters.AddWithValue("@Description", description);
            cmd.Parameters.AddWithValue("@SubDateTime", subDate);
            cmd.Parameters.AddWithValue("@Oralmark", oral ?? (object)DBNull.Value);
            cmd.Parameters.AddWithValue("@TotalMark", total ?? (object)DBNull.Value);

            try
            {
                con.Open();
                cmd.ExecuteNonQuery();
                Standard_Messages.SuccessfullInsert();
                Interaction.ContinueAddingAsOrNot();
            }
            catch (SqlException e)
            {
                Standard_Messages.Error();
                Console.WriteLine(e.ToString());
            }
            finally
            {
                con.Close();
                Console.ReadKey();
            }
        }
예제 #2
0
        // Δημιουργία μιας νέας τριπλής σχέσης μεταξύ Μαθητή , Μαθήματος και Assignment  .Μεταφορά σχέσης στην Βάση δεδομένων
        public static void AssignmentPerCoursePerStudentTransfer(int course_id, int assignment_id, int studentId)
        {
            SqlConnection con = new SqlConnection(ConString);
            string        qr  = @"Insert into AssignmentPerCourse (Course_ID , Assignment_ID ) VALUES (@Course_ID , @Assignment_ID) 
                         Insert into StudentPerCourse (Course_ID , Student_ID) VALUES (@Course_ID , @Student_ID)";

            SqlCommand cmd = new SqlCommand(qr, con);

            cmd.Parameters.AddWithValue("@Course_ID", course_id);
            cmd.Parameters.AddWithValue("@Assignment_ID", assignment_id);
            cmd.Parameters.AddWithValue("@Student_ID", studentId);

            try
            {
                con.Open();
                cmd.ExecuteNonQuery();
                Standard_Messages.SuccessfullInsert();
                Interaction.ContinueAddingAssignmentPerCourseOrNot();
            }
            catch (SqlException e) when(e.Number == 2627 || e.Number == 547)
            {
                Standard_Messages.Error();
                Standard_Messages.AlreadyExists();
                Interaction.ContinueAddingAssignmentPerCourseOrNot();
            }
            finally
            {
                con.Close();
                Console.ReadKey();
            }
        }
예제 #3
0
        // Μεταφορά Μαθητή στην Βάση δεδομένων
        public static void StudentTransfer(string firstName, string lastName, DateTime dateOfBirth, object tuitionFees)
        {
            SqlConnection con = new SqlConnection(ConString);
            string        qr  = "Insert into Student (FirstName, LastName , DateOfBirth , TuitionFees) VALUES (@FirstName, @LastName , @DateOfBirth , @TuitionFees)";

            SqlCommand cmd = new SqlCommand(qr, con);

            cmd.Parameters.AddWithValue("@FirstName", firstName);
            cmd.Parameters.AddWithValue("@LastName", lastName);
            cmd.Parameters.AddWithValue("@DateOfBirth", dateOfBirth);
            cmd.Parameters.AddWithValue("@TuitionFees", tuitionFees ?? (object)DBNull.Value);
            try
            {
                con.Open();
                cmd.ExecuteNonQuery();
                Standard_Messages.SuccessfullInsert();
                Interaction.ContinueAddingStudOrNot();
            }
            catch (SqlException e)
            {
                Standard_Messages.Error();
                Console.WriteLine(e.ToString());
            }
            finally
            {
                con.Close();
                Console.ReadKey();
            }
        }
예제 #4
0
        // Μεταφορά Μαθήματος στην Βάση
        public static void CourseTransfer(string title, string stream, string type, DateTime startDate, DateTime endDate)
        {
            SqlConnection con = new SqlConnection(ConString);
            string        qr  = "Insert into Course (Title, Stream , Type , StartDate , EndDate) VALUES (@Title, @Stream , @Type ,@StartDate , @EndDate)";

            SqlCommand cmd = new SqlCommand(qr, con);

            cmd.Parameters.AddWithValue("@Title", title);
            cmd.Parameters.AddWithValue("@Stream", stream);
            cmd.Parameters.AddWithValue("@Type", type);
            cmd.Parameters.AddWithValue("@StartDate", startDate);
            cmd.Parameters.AddWithValue("@EndDate", endDate);

            try
            {
                con.Open();
                cmd.ExecuteNonQuery();
                Standard_Messages.SuccessfullInsert();
                Interaction.ContinueAddingCourseOrNot();
            }
            catch (SqlException e)
            {
                Standard_Messages.Error();
                e.ToString();
            }
            finally
            {
                con.Close();
                Console.ReadKey();
            }
        }
예제 #5
0
        // Δημιουργία μιας νέας σχέσης Καθηγητή και Μαθήματος .Μεταφορά σχέσης στην Βάση δεδομένων
        public static void TrainerPerCourseTransfer(int course_id, int trainer_id)
        {
            SqlConnection con = new SqlConnection(ConString);
            string        qr  = "Insert into TrainerPerCourse (Course_ID , Trainer_ID) VALUES (@Course_ID , @Trainer_ID)";

            SqlCommand cmd = new SqlCommand(qr, con);

            cmd.Parameters.AddWithValue("@Course_ID", course_id);
            cmd.Parameters.AddWithValue("@Trainer_ID", trainer_id);

            try
            {
                con.Open();
                cmd.ExecuteNonQuery();
                Standard_Messages.SuccessfullInsert();
                Interaction.ContinueAddingTrainerPerCourseOrNot();
            }
            catch (SqlException e) when(e.Number == 2627 || e.Number == 547)
            {
                Standard_Messages.Error();
                Standard_Messages.AlreadyExists();
                Interaction.ContinueAddingTrainerPerCourseOrNot();
            }
            finally
            {
                con.Close();
                Console.ReadKey();
            }
        }
예제 #6
0
        // Μεταφορά Καθηγητή στην Βάση δεδομένων
        public static void TrainerTransfer(string firstname, string lastname, string subject)
        {
            SqlConnection con = new SqlConnection(ConString);
            string        qr  = "Insert into Trainer (FirstName , LastName , Subject) VALUES (@FirstName , @LastName , @Subject)";

            SqlCommand cmd = new SqlCommand(qr, con);

            cmd.Parameters.AddWithValue("@FirstName", firstname);
            cmd.Parameters.AddWithValue("@LastName", lastname);
            cmd.Parameters.AddWithValue("@Subject", subject);

            try
            {
                con.Open();
                cmd.ExecuteNonQuery();
                Standard_Messages.SuccessfullInsert();
                Interaction.ContinueAddingTrainerOrNot();
            }
            catch (SqlException e)
            {
                Standard_Messages.Error();
                Console.WriteLine(e.ToString());
            }
            finally
            {
                con.Close();
                Console.ReadKey();
            }
        }
예제 #7
0
 public static void LogOut()
 {
     Console.Clear();
     Standard_Messages.Welcome();
     Console.WriteLine("\tYou selected LogOut");
     Thread.Sleep(2000);
     Console.Clear();
 }
        // Ακολουθούν μέθοδοι που ζητούν απο τον χρήστη να αποφασίσει αν θα συνεχίσει να δημιουργεί νέες προσθήκες
        // ή αν θέλει να επιστρεψει στο αρχικο κατα κύριο λόγο μενου

        public static string CheckContinueOrNot()
        {
            string answer = string.Empty;

            Standard_Messages.ShowContinueOrBack();
            answer = StringAnswer();
            while (!(answer.ToUpper() == "B" || answer.ToUpper() == "C"))
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("\tChoose Between C Or B");
                Console.ForegroundColor = ConsoleColor.White;
                Console.Write("\t                           : ");
                answer = StringAnswer();
            }
            return(answer);
        }
        public static void ContinueAddingStudOrNot()
        {
            string answer = CheckContinueOrNot();

            while (answer.ToUpper() == "C")
            {
                Console.Clear();
                Standard_Messages.Welcome();
                Insert.InsertStudent();
                Standard_Messages.ShowContinueOrBack();
                answer = StringAnswer();
            }
            if (answer.ToUpper() == "B")
            {
                MoveTools.BackOptionToInsertMenu();
            }
        }
예제 #10
0
        // Αρχικό Μενού. Επιλογή ανάμεσα σε Συνθετικές πληροφορίες ή Εισαγωγή.

        public static void IntroInitialOrSynthetic()
        {
            string choice = string.Empty;

            Console.WriteLine("\t1.You can Insert Data.\n");
            Console.WriteLine("\t2.You can use Synthetic Data.\n");
            Console.Write("\t0. ");
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("LogOut\n");
            Console.ForegroundColor = ConsoleColor.White;
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.Write("\n\tChoose ");
            Console.ForegroundColor = ConsoleColor.White;
            Console.Write("1,2 or 0 : ");
            choice = Interaction.StringAnswer();
            while (!(choice == "1" || choice == "2" || choice == "0"))
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("\t!Choose Between (1,2,0)");
                Console.Beep();
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.Write("\n\tChoose ");
                Console.ForegroundColor = ConsoleColor.White;
                Console.Write("1,2 or 0 : ");
                choice = Interaction.StringAnswer();
                Console.ForegroundColor = ConsoleColor.White;
            }

            if (choice == "1")    // Περίπτωση εισαγωγής
            {
                Console.Clear();
                Standard_Messages.Welcome();
                InsertMenu();
            }
            else if (choice == "2")
            {
                Console.Clear();
                Standard_Messages.Welcome();
                SyntheticMenu();  // Μπορούμε να δούμε όλα τα δεδομένα της βάσης
            }
            else if (choice == "0")
            {
                MoveTools.LogOut(); // Αποσύνδεση χρήστη , απο το σύστημα
            }
        }
        public static void ContinueAddingCourseOrNot()
        {
            string answer = CheckContinueOrNot();

            while (answer.ToUpper() == "C")
            {
                Console.Clear();
                Standard_Messages.Welcome();
                Insert.InsertCourse();
                Standard_Messages.ShowContinueOrBack();
                answer = StringAnswer();
            }
            if (answer.ToUpper() == "B")
            {
                Console.Clear();
                Standard_Messages.Welcome();
                Menu.InsertMenu();
            }
        }
예제 #12
0
        // Συνθετικό Μενού
        public static void SyntheticMenu()
        {
            string answer = string.Empty;

            Standard_Messages.ShowSyntheticOption();
            answer = Interaction.StringAnswer();
            while (!(answer == "1" || answer == "2" || answer == "0"))
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("\tChoose Between (1,2,0)");
                Console.Beep();
                Console.ForegroundColor = ConsoleColor.White;
                Console.Write("\tChoice : ");
                answer = Interaction.StringAnswer();
            }
            switch (answer)
            {
            case "1":
                Console.Clear();
                Standard_Messages.Welcome();
                TablePrinting.PrintAllTables();      // Εκτύπωση όλων των στοιχείων
                MoveTools.GoBack();
                break;

            case "2":
                Console.Clear();
                Standard_Messages.Welcome();
                MoveTools.GobackStartmenu();      // Μεταφορά πίσω στο αρχικό μενου
                break;

            case "0":
                Console.Clear();
                Standard_Messages.Welcome();
                MoveTools.LogOut();     // Αποσύνδεση
                break;
            }
        }
예제 #13
0
 public static void BackOptionToInsertMenu()
 {
     Console.Clear();
     Standard_Messages.Welcome();
     Menu.InsertMenu();
 }
예제 #14
0
 public static void GobackStartmenu()
 {
     Console.Clear();
     Standard_Messages.Welcome();
     Menu.IntroInitialOrSynthetic();
 }
예제 #15
0
 // Η Κύρια μέθοδος του προγράμματος.
 public static void Run()
 {
     Standard_Messages.Welcome();
     Menu.IntroInitialOrSynthetic();
 }
예제 #16
0
        // Μενού με 7 επιλογές εισαγωγής και δύο επιλογές για την μεταφορά μας μέσα στο σύστημα
        public static void InsertMenu()
        {
            string answer = string.Empty;

            Standard_Messages.ShowInsertOptions();
            answer = Interaction.StringAnswer();
            while (!(answer == "1" || answer == "2" || answer == "3" || answer == "4" ||
                     answer == "5" || answer == "6" || answer == "7" || answer == "8" || answer == "0"))
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("\tChoose Between (1,2,3,4,5,0)");
                Console.Beep();
                Console.ForegroundColor = ConsoleColor.White;
                Console.Write("\tChoice : ");
                answer = Interaction.StringAnswer();
            }
            switch (answer)
            {
            case "1":
                Console.Clear();
                Standard_Messages.Welcome();
                Insert.InsertCourse();
                break;

            case "2":
                Console.Clear();
                Standard_Messages.Welcome();
                Insert.InsertTrainer();
                break;

            case "3":
                Console.Clear();
                Standard_Messages.Welcome();
                Insert.InsertAssignment();
                break;

            case "4":
                Console.Clear();
                Standard_Messages.Welcome();
                Insert.InsertStudent();
                break;

            case "5":
                Console.Clear();
                Standard_Messages.Welcome();
                Insert.InsertStudentsPerCourse();
                break;

            case "6":
                Console.Clear();
                Standard_Messages.Welcome();
                Insert.InsertTrainerPerCourse();
                break;

            case "7":
                Console.Clear();
                Standard_Messages.Welcome();
                Insert.InsertStudentPerCoursePerAss();
                break;

            case "8":
                MoveTools.GobackStartmenu();
                break;

            case "0":
                MoveTools.LogOut();
                break;
            }
        }