Exemple #1
0
        public void DelIndex(Man man, string str)
        {
            int i = 0;
            Console.Write("\nEnter index for delete:");
            i = int.Parse(Console.ReadLine());
            try
            {
                switch (str)
                {

                    case "STUDENT":                        
                            man.ListStudent.RemoveAt(i);
                            Print.Proces("DELETE");                     
                        break;
                    case "TEACHER":
                            man.ListTeacher.RemoveAt(i);
                            Print.Proces("DELETE");
                            break;
                    case "ACCOUNTANT":
                            man.ListAccountant.RemoveAt(i);
                            Print.Proces("DELETE");                            
                        break;
                    default:
                        break;
                }
            }
            catch (Exception e)
            {
                Console.Write(e.Message);
                Print.Wait();
            }

        }
Exemple #2
0
 static void PrintTeacher(Man man)
 {
     Print.PrintDash(tableStudentWidth);
     string titleTable = ("|       Name:        |" +
                   "       LastName     |" +
                   "       Salary       |" +
                   "      Name Shool    |" +
                    "\n");
     Console.Write(titleTable);
     foreach (var teacher in man.ListTeacher)
         Print.PrintStr(teacher.Name, teacher.LastName, teacher.Salary, teacher.NameShool);
     Print.PrintDash(tableStudentWidth);
 }
Exemple #3
0
        static void Main(string[] args)
        {
            Console.WindowWidth = 100;
            Menu consoleMenu = new Menu();
            consoleMenu.MainMenu = new string[] { "   Student   ", "   Teacher   ", "   Accountant   ", "   Print all   ","   Parse XML   ", "   Exit   " };
            Menu subMenu = new Menu();
            subMenu.MainMenu = new string[] { "   ADD   ", "   EDIT   ", "   PRINT   ", "   DELETE   ", "   DELETE ALL   ", "   <-BACK   " };
            int exitMainMenu = 0;
            Man mainMan = new Man();
            do
            {

                switch (consoleMenu.ShowMenu(consoleMenu.MainMenu, "MENU"))
                {
                    case -1:
                        exitMainMenu = -1;
                        break;
                    case 0:
                        do
                        {                            
                            exitMainMenu = Menu.SubMenu(mainMan, subMenu, "STUDENT", exitMainMenu);
                        } while (exitMainMenu != -1);
                        exitMainMenu = 0;
                        break;
                    case 1:
                        do
                        {
                            exitMainMenu = Menu.SubMenu(mainMan, subMenu, "TEACHER", exitMainMenu);
                        } while (exitMainMenu != -1);
                        exitMainMenu = 0;
                        break;
                    case 2:
                        do
                        {
                            exitMainMenu = Menu.SubMenu(mainMan, subMenu, "ACCOUNTANT", exitMainMenu);
                        } while (exitMainMenu != -1);
                        exitMainMenu = 0;
                        break;
                    case 3:
                        Print.PrintAll(mainMan);
                        break;
                    case 4:
                        ParseXML.CreateXML(mainMan);
                        break;
                    default:
                        break;
                }

            } while (exitMainMenu != -1);

        }
Exemple #4
0
 static void PrintStudent(Man man)
 {
     Print.PrintDash(tableStudentWidth);
     string titleTable = ("|       Name:        |" +
                   "       LastName     |" +
                   "     AverageBall    |" +
                   "      YearBirth     |" +
                    "\n");
     Console.Write(titleTable);
     foreach (var list in man.ListStudent)
         Print.PrintStr(list.Name, list.LastName, list.AverageBall, list.YearBirth);
     Print.PrintDash(tableStudentWidth);
     
 }
Exemple #5
0
        static public void CreateXML(Man man)
        {
            XmlTextWriter writer = null;
            writer =new XmlTextWriter("Man.xml",System.Text.Encoding.Unicode);
            writer.Formatting= Formatting.Indented;
            writer.WriteStartDocument();
            writer.WriteStartElement("Man");
            
            for (int i = 0; i < man.ListStudent.Count; i++)
            {
                writer.WriteStartElement("Student");
                writer.WriteElementString("Name",man.ListStudent[i].Name );
                writer.WriteElementString("LastName", man.ListStudent[i].LastName);
                writer.WriteElementString("AverageBall", man.ListStudent[i].AverageBall);
                writer.WriteElementString("YearBirth", man.ListStudent[i].YearBirth);
                writer.WriteEndElement();
            }

            writer.WriteStartElement("School");
            for (int i = 0; i < man.ListStudent.Count; i++)
            {
                writer.WriteStartElement("Teacher");
                
                writer.WriteElementString("Name", man.ListTeacher[i].Name);
                writer.WriteElementString("LastName", man.ListTeacher[i].LastName);
                writer.WriteElementString("Salary", man.ListTeacher[i].Salary);
                writer.WriteElementString("Shool", man.ListTeacher[i].NameShool);
                writer.WriteEndElement();
            }
            
            
            for (int i = 0; i < man.ListStudent.Count; i++)
            {
                writer.WriteStartElement("Accountant");

                writer.WriteElementString("Name", man.ListAccountant[i].Name);
                writer.WriteElementString("LastName", man.ListAccountant[i].LastName);
                writer.WriteElementString("Salary", man.ListAccountant[i].Salary);
                writer.WriteElementString("Shool", man.ListAccountant[i].NameShool);
                writer.WriteEndElement();
            }
            
            writer.WriteEndElement();
            writer.WriteEndElement();

            if (writer != null)
                writer.Close();
            Print.Proces("XML Parse");
        }
Exemple #6
0
       static public int SubMenu(Man mainMan,Menu subMenu, string str, int exitMainMenu)
       {
           switch (subMenu.ShowMenu(subMenu.MainMenu, str))
           {
               case -1:
                   exitMainMenu = -1;
                   break;
               case 0:
                   mainMan.CreateListStudent(mainMan,str);
                   break;
               case 1:
                   mainMan.Edit(mainMan,str);
                   break;
               case 2:
                   Print.PrintInfo(mainMan, str);
                   break;
               case 3:
                   mainMan.DelIndex(mainMan, str);
                   break;
               case 4:
                   switch (str)
                   {
                       case "STUDENT":
                           mainMan.ListStudent.Clear();
                           break;
                       case "TEACHER":
                           mainMan.ListTeacher.Clear();
                           break;
                       case "ACCOUNTANT":
                           mainMan.ListAccountant.Clear();
                           break;
                       default:
                           break;
                   }
                   Print.Proces("DELETE");
                   break;
               default:
                   break;
           }

           return exitMainMenu;
       }
Exemple #7
0
 static public void PrintInfo(Man man, string option)
 {
     switch (option)
     {
         case "STUDENT":
             Print.PrintStudent(man);
             Print.Wait();
             break;
         case "TEACHER":
             Print.PrintTeacher(man);
             Print.Wait();
             break;
         case "ACCOUNTANT":
             Print.PrintAccountant(man);
             Print.Wait();
             break;
         default:
             Console.WriteLine("Failed option!!!");
             break;
     }
     Console.Clear();
 }
Exemple #8
0
        public void CreateListStudent(Man man, string str)
        {
            int count;
            Console.Write("Enter the number :");
            count = int.Parse(Console.ReadLine());
            switch (str)
            {
                case "STUDENT":
                    Student[] st = new Student[count];
                    for (int i = 0; i < count; i++)
                    {
                        st[i] = new Student();
                        Console.Write("Enter Name Student № {0} :", i);
                        st[i].Name = Console.ReadLine();
                        Console.Write("Enter LastName Student № {0} :", i);
                        st[i].LastName = Console.ReadLine();
                        Console.Write("Enter AverageBall Student № {0} :", i);
                        st[i].AverageBall = Console.ReadLine();
                        Console.Write("Enter YearBirth  Student № {0} :", i);
                        st[i].YearBirth = Console.ReadLine();


                        man.ListStudent.Add(st[i]);
                    }
                    break;
                case "TEACHER":
                    Teacher[] teacher = new Teacher[count];
                    for (int i = 0; i < count; i++)
                    {
                        teacher[i] = new Teacher();
                        Console.Write("Enter Name Teacher № {0} :", i);
                        teacher[i].Name = Console.ReadLine();
                        Console.Write("Enter Last Name Teacher № {0} :", i);
                        teacher[i].LastName = Console.ReadLine();
                        Console.Write("Enter Salary Teacher № {0} :", i);
                        teacher[i].Salary = Console.ReadLine();
                        Console.Write("Enter Name School № {0} :", i);
                        teacher[i].NameShool = Console.ReadLine();
                        man.ListTeacher.Add(teacher[i]);
                    }
                    break;
                case "ACCOUNTANT":
                    Accountant[] accountant =new Accountant[count];
                    for (int i = 0; i < count; i++)
                    {
                        accountant[i] = new Accountant();
                        Console.Write("Enter Name Accountant № {0} :", i);
                        accountant[i].Name = Console.ReadLine();
                        Console.Write("Enter Last Name Accountant № {0} :", i);
                        accountant[i].LastName = Console.ReadLine();
                        Console.Write("Enter Salary Accountant № {0} :", i);
                        accountant[i].Salary = Console.ReadLine();
                        Console.Write("Enter Name School № {0} :", i);
                        accountant[i].NameShool = Console.ReadLine();
                        man.ListAccountant.Add(accountant[i]);
                    }
                    break;
                default:
                    break;
            }

            Console.Clear();
        }
Exemple #9
0
        public void Edit(Man man, string str)
        {
            int i = 0;
            Console.Write("\nEnter index for edit:");
            i = int.Parse(Console.ReadLine());
            try
            {
                switch (str)
                {
                    case "STUDENT":
                        Console.Write("\nEnter new Name:");
                        man.ListStudent[i].Name = Console.ReadLine();
                        Console.Write("\nEnter new LasyName:");
                        man.ListStudent[i].LastName = Console.ReadLine();
                        Console.Write("\nEnter new AverageBall:");
                        man.ListStudent[i].AverageBall = Console.ReadLine();
                        Console.Write("\nEnter new YearBirth:");
                        man.ListStudent[i].YearBirth = Console.ReadLine();
                        break;
                    case "TEACHER":
                        Console.Write("\nEnter new Name:");
                        man.ListTeacher[i].Name = Console.ReadLine();
                        Console.Write("\nEnter new LasyName:");
                        man.ListTeacher[i].LastName = Console.ReadLine();
                        Console.Write("\nEnter new Salary:");
                        man.ListTeacher[i].Salary = Console.ReadLine();
                        Console.Write("\nEnter new Scholl Name:");
                        man.ListTeacher[i].NameShool = Console.ReadLine();
                        break;
                    case "ACCOUNTANT":
                        Console.Write("\nEnter new Name:");
                        man.ListAccountant[i].Name = Console.ReadLine();
                        Console.Write("\nEnter new LasyName:");
                        man.ListAccountant[i].LastName = Console.ReadLine();
                        Console.Write("\nEnter new Salary:");
                        man.ListAccountant[i].Salary = Console.ReadLine();
                        Console.Write("\nEnter new Scholl Name:");
                        man.ListAccountant[i].NameShool = Console.ReadLine();
                        break;
                    default:
                        break;
                }
                
                

            }
            catch (Exception e)
            {
                Console.Write(e.Message);

            }
            Console.Clear();
        }
Exemple #10
0
 static void PrintAccountant(Man man)
 {
     Print.PrintDash(tableStudentWidth);
     string titleTable = ("|       Name:        |" +
                   "       LastName     |" +
                   "       Salary       |" +
                   "      Name Shool    |" +
                    "\n");
     Console.Write(titleTable);
     foreach (var list in man.ListAccountant)
         Print.PrintStr(list.Name, list.LastName, list.Salary, list.NameShool);
     Print.PrintDash(tableStudentWidth);
 }
Exemple #11
0
 public static void PrintAll(Man man)
 {
     Print.PrintStudent(man);
     Print.PrintTeacher(man);
     Print.PrintAccountant(man);
     Print.Wait();
 }
Exemple #12
0
        public void CreateListStudent(Man man, string str)
        {
            int count;

            Console.Write("Enter the number :");
            count = int.Parse(Console.ReadLine());
            switch (str)
            {
            case "STUDENT":
                Student[] st = new Student[count];
                for (int i = 0; i < count; i++)
                {
                    st[i] = new Student();
                    Console.Write("Enter Name Student № {0} :", i);
                    st[i].Name = Console.ReadLine();
                    Console.Write("Enter LastName Student № {0} :", i);
                    st[i].LastName = Console.ReadLine();
                    Console.Write("Enter AverageBall Student № {0} :", i);
                    st[i].AverageBall = Console.ReadLine();
                    Console.Write("Enter YearBirth  Student № {0} :", i);
                    st[i].YearBirth = Console.ReadLine();


                    man.ListStudent.Add(st[i]);
                }
                break;

            case "TEACHER":
                Teacher[] teacher = new Teacher[count];
                for (int i = 0; i < count; i++)
                {
                    teacher[i] = new Teacher();
                    Console.Write("Enter Name Teacher № {0} :", i);
                    teacher[i].Name = Console.ReadLine();
                    Console.Write("Enter Last Name Teacher № {0} :", i);
                    teacher[i].LastName = Console.ReadLine();
                    Console.Write("Enter Salary Teacher № {0} :", i);
                    teacher[i].Salary = Console.ReadLine();
                    Console.Write("Enter Name School № {0} :", i);
                    teacher[i].NameShool = Console.ReadLine();
                    man.ListTeacher.Add(teacher[i]);
                }
                break;

            case "ACCOUNTANT":
                Accountant[] accountant = new Accountant[count];
                for (int i = 0; i < count; i++)
                {
                    accountant[i] = new Accountant();
                    Console.Write("Enter Name Accountant № {0} :", i);
                    accountant[i].Name = Console.ReadLine();
                    Console.Write("Enter Last Name Accountant № {0} :", i);
                    accountant[i].LastName = Console.ReadLine();
                    Console.Write("Enter Salary Accountant № {0} :", i);
                    accountant[i].Salary = Console.ReadLine();
                    Console.Write("Enter Name School № {0} :", i);
                    accountant[i].NameShool = Console.ReadLine();
                    man.ListAccountant.Add(accountant[i]);
                }
                break;

            default:
                break;
            }

            Console.Clear();
        }