Ejemplo n.º 1
0
        public SearchEmployee(IBL BL)
        {
            this.itsBL  = BL;
            minInt      = Convert.ToString(Int32.MinValue);
            maxInt      = Convert.ToString(Int32.MaxValue);
            minDateTime = Convert.ToString(DateTime.MinValue);
            maxDateTIme = Convert.ToString(DateTime.MaxValue);

            string cmd;

            while (true)
            {
                Console.Clear();
                Console.WriteLine("search employee by :");
                Console.WriteLine("\t1. his teudat Zehute ");
                Console.WriteLine("\t2. his first name ");
                Console.WriteLine("\t3. his last name ");
                Console.WriteLine("\t4. department ID ");
                Console.WriteLine("\t5. salary ");
                Console.WriteLine("\t6. gender ");
                Console.WriteLine("\t7. supervisor ID");
                Console.WriteLine("\t8. gat all employees ");
                Console.WriteLine("\t9. back ");
                Console.WriteLine("\t10. back to main menu ");

                cmd = Console.ReadLine();

                switch (cmd)
                {
                case "1":

                    Console.WriteLine("Enter the teudat Zehute you want to find (notice! must my numbers): ");
                    string eTZ = Console.ReadLine();
                    while (!(InputCheck.isInt(eTZ)))
                    {
                        Console.WriteLine("Invalid teudat zehute. \n enter again");
                        eTZ = Console.ReadLine();
                    }

                    List <object> tehudotList = itsBL.queryByString(Classes.Employee, stringFields.teudatZehute, eTZ);
                    Console.Clear();
                    Console.WriteLine("row. teudat Zehute|First Name|Last Name|Department ID|Salary|Gender|Supervisor IS ");
                    List <Employee> newDList1 = tehudotList.Cast <Employee>().ToList();
                    if (newDList1.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");
                    }
                    int counterT = 1;
                    foreach (Employee e in newDList1)
                    {
                        Console.WriteLine(+counterT + ".  " + e.TeudatZehute.ToString() + " | " + e.FirstName + " | " + e.LastName + " | " + e.DepartmentID.ToString() + " | " + e.Salary.ToString() + " | " + e.Gender.ToString() + " | " + e.SupervisorID.ToString());    // print the list on the screen
                        counterT++;
                    }
                    subMenu whatNext1 = new subMenu(itsBL);
                    whatNext1.Menu("5", counterT, tehudotList);

                    break;

                case "2":
                    Console.Clear();
                    Console.WriteLine("Enter the first name you want to find: ");
                    string        efirst    = Console.ReadLine();
                    List <object> firstList = itsBL.queryByString(Classes.Employee, stringFields.firstName, efirst);
                    Console.Clear();
                    Console.WriteLine("row. teudat Zehute|First Name|Last Name|Department ID|Salary|Gender|Supervisor IS ");
                    List <Employee> newDList2 = firstList.Cast <Employee>().ToList();
                    if (newDList2.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");
                    }
                    int counterF = 1;
                    foreach (Employee e in newDList2)
                    {
                        Console.WriteLine(+counterF + ".  " + e.TeudatZehute.ToString() + " | " + e.FirstName + " | " + e.LastName + " | " + e.DepartmentID.ToString() + " | " + e.Salary.ToString() + " | " + e.Gender.ToString() + " | " + e.SupervisorID.ToString());                 // print the list on the screen
                        counterF++;
                    }
                    subMenu whatNext2 = new subMenu(itsBL);
                    whatNext2.Menu("5", counterF, firstList);

                    break;

                case "3":
                    Console.Clear();
                    Console.WriteLine("Enter the last name you want to find: ");
                    string        elast    = Console.ReadLine();
                    List <object> lastList = itsBL.queryByString(Classes.Employee, stringFields.lastName, elast);
                    Console.Clear();
                    Console.WriteLine("row. teudat Zehute|First Name|Last Name|Department ID|Salary|Gender|Supervisor IS ");
                    List <Employee> newDList3 = lastList.Cast <Employee>().ToList();
                    if (newDList3.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");
                    }
                    int counterL = 1;
                    foreach (Employee e in newDList3)
                    {
                        Console.WriteLine(+counterL + ".  " + e.TeudatZehute.ToString() + " | " + e.FirstName + " | " + e.LastName + " | " + e.DepartmentID.ToString() + " | " + e.Salary.ToString() + " | " + e.Gender.ToString() + " | " + e.SupervisorID.ToString());                 // print the list on the screen
                        counterL++;
                    }
                    subMenu whatNext3 = new subMenu(itsBL);
                    whatNext3.Menu("5", counterL, lastList);

                    break;

                case "4":
                    Console.Clear();
                    Console.WriteLine("Enter the department ID you want to find: (notice! must be numbers) ");
                    string edepar = Console.ReadLine();
                    while (!(InputCheck.isInt(edepar)))
                    {
                        Console.WriteLine("Invalid department ID. \n enter again");
                        edepar = Console.ReadLine();
                    }
                    List <object> depList = itsBL.queryByString(Classes.Employee, stringFields.departmentID, edepar);
                    Console.Clear();
                    Console.WriteLine("row. teudat Zehute|First Name|Last Name|Department ID|Salary|Gender|Supervisor IS ");
                    List <Employee> newList4 = depList.Cast <Employee>().ToList();
                    if (newList4.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");
                    }
                    int counterD = 1;
                    foreach (Employee e in newList4)
                    {
                        Console.WriteLine(+counterD + ".  " + e.TeudatZehute.ToString() + " | " + e.FirstName + " | " + e.LastName + " | " + e.DepartmentID.ToString() + " | " + e.Salary.ToString() + " | " + e.Gender.ToString() + " | " + e.SupervisorID.ToString());                 // print the list on the screen
                        counterD++;
                    }
                    subMenu whatNext4 = new subMenu(itsBL);
                    whatNext4.Menu("5", counterD, depList);

                    break;

                case "5":
                    Console.Clear();
                    Console.WriteLine("Choose an option: ");
                    Console.WriteLine("\t1. Search for specific salary ");
                    Console.WriteLine("\t2. Search range of salary ");
                    string search    = Console.ReadLine();
                    string fromValue = null;
                    string toValue   = null;
                    //bool ans = true;
                    //while (ans)
                    //{
                    switch (search)
                    {
                    case "1":
                        Console.WriteLine("enter salary: ");
                        string salary = Console.ReadLine();
                        while (!(InputCheck.isDouble(salary)))
                        {
                            Console.WriteLine("invalid salary. \n try again");
                            salary = Console.ReadLine();
                        }
                        fromValue = salary;
                        toValue   = salary;
                        //ans=false;
                        break;

                    case "2":
                        Console.WriteLine("from which salary to search: ");
                        string fromSalary = Console.ReadLine();
                        while (!(InputCheck.isDouble(fromSalary)))
                        {
                            Console.WriteLine("invalid salary. \n try again");
                            fromSalary = Console.ReadLine();
                        }
                        fromValue = fromSalary;

                        Console.WriteLine("until which salary to search: ");
                        string toSalary = Console.ReadLine();
                        while (!(InputCheck.isDouble(toSalary)))
                        {
                            Console.WriteLine("invalid salary. \n try again");
                            toSalary = Console.ReadLine();
                        }
                        toValue = toSalary;

                        //ans=false;
                        break;

                    default:
                        Console.WriteLine("You perform illegal move, please choose 1 or 2");
                        break;
                    }
                    // }
                    List <object> salaryList = itsBL.queryByRange(Classes.Employee, rangeFields.salary, fromValue, toValue);
                    Console.Clear();
                    Console.WriteLine("row. teudat Zehute|First Name|Last Name|Department ID|Salary|Gender|Supervisor IS ");
                    List <Employee> newList5 = salaryList.Cast <Employee>().ToList();
                    if (newList5.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");
                    }
                    int counterS = 1;
                    foreach (Employee e in newList5)
                    {
                        Console.WriteLine(+counterS + ".  " + e.TeudatZehute.ToString() + " | " + e.FirstName + " | " + e.LastName + " | " + e.DepartmentID.ToString() + " | " + e.Salary.ToString() + " | " + e.Gender.ToString() + " | " + e.SupervisorID.ToString());                 // print the list on the screen
                        counterS++;
                    }
                    subMenu whatNext5 = new subMenu(itsBL);
                    whatNext5.Menu("5", counterS, salaryList);
                    break;

                case "6":
                    Console.Clear();
                    Console.WriteLine("Enter the gender you want to find: ");
                    Console.WriteLine("\t1. Male");
                    Console.WriteLine("\t2. Female");
                    string cho     = Console.ReadLine();
                    string eGender = "null";
                    bool   gend    = true;
                    while (gend)
                    {
                        if (cho == "1")
                        {
                            eGender = "Male"; gend = false;
                        }
                        else if (cho == "2")
                        {
                            eGender = "Female"; gend = false;
                        }
                        else
                        {
                            Console.WriteLine("choose 1 Or 2 only");
                            cho = Console.ReadLine();
                        }
                    }
                    List <object> genderList = itsBL.queryByString(Classes.Employee, stringFields.gender, eGender);
                    Console.Clear();
                    Console.WriteLine("row. teudat Zehute|First Name|Last Name|Department ID|Salary|Gender|Supervisor IS ");
                    List <Employee> newList6 = genderList.Cast <Employee>().ToList();
                    if (newList6.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");
                    }
                    int counterG = 1;
                    foreach (Employee e in newList6)
                    {
                        Console.WriteLine(+counterG + ".  " + e.TeudatZehute.ToString() + " | " + e.FirstName + " | " + e.LastName + " | " + e.DepartmentID.ToString() + " | " + e.Salary.ToString() + " | " + e.Gender.ToString() + " | " + e.SupervisorID.ToString());                 // print the list on the screen
                        counterG++;
                    }
                    subMenu whatNext6 = new subMenu(itsBL);
                    whatNext6.Menu("5", counterG, genderList);

                    break;

                case "7":
                    Console.Clear();
                    Console.WriteLine("Enter the supervisor ID you want to find (notice! must be numbers):  ");
                    string eSuper = Console.ReadLine();
                    while (!(InputCheck.isInt(eSuper)))
                    {
                        Console.WriteLine("Invalid supervisor ID. \n try again");
                        eSuper = Console.ReadLine();
                    }
                    List <object> superList = itsBL.queryByString(Classes.Employee, stringFields.supervisorID, eSuper);
                    Console.Clear();
                    Console.WriteLine("row. teudat Zehute|First Name|Last Name|Department ID|Salary|Gender|Supervisor IS ");
                    List <Employee> newList7 = superList.Cast <Employee>().ToList();
                    if (newList7.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");
                    }
                    int counterV = 1;
                    foreach (Employee e in newList7)
                    {
                        Console.WriteLine(+counterV + ".  " + e.TeudatZehute.ToString() + " | " + e.FirstName + " | " + e.LastName + " | " + e.DepartmentID.ToString() + " | " + e.Salary.ToString() + " | " + e.Gender.ToString() + " | " + e.SupervisorID.ToString());                 // print the list on the screen
                        counterV++;
                    }
                    subMenu whatNext7 = new subMenu(itsBL);
                    whatNext7.Menu("5", counterV, superList);

                    break;

                case "8":
                    List <Employee> newList8 = itsBL.getAllEmployees().Employeess;
                    Console.Clear();
                    Console.WriteLine("row. teudat Zehute|First Name|Last Name|Department ID|Salary|Gender|Supervisor IS ");
                    if (newList8.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");
                    }
                    int counterA = 1;
                    foreach (Employee e in newList8)
                    {
                        Console.WriteLine(+counterA + ".  " + e.TeudatZehute.ToString() + " | " + e.FirstName + " | " + e.LastName + " | " + e.DepartmentID.ToString() + " | " + e.Salary.ToString() + " | " + e.Gender.ToString() + " | " + e.SupervisorID.ToString());                 // print the list on the screen
                        counterA++;
                    }
                    List <object> allList   = newList8.Cast <object>().ToList();
                    subMenu       whatNext8 = new subMenu(itsBL);
                    whatNext8.Menu("5", counterA, allList);
                    break;

                case "9":
                    Search back = new Search(itsBL);
                    back.run();
                    break;

                case "10":
                    MainMenu moveToMenu = new MainMenu(itsBL);
                    break;

                default:
                    Console.WriteLine("You have performed an illegal move, please enter a number between 1-10");
                    Thread.Sleep(2400);

                    break;
                }
            }
        }
Ejemplo n.º 2
0
        public SearchClubMember(IBL BL)
        {
            this.itsBL = BL;

            string cmd;

            while (true)
            {
                Console.Clear();
                Console.WriteLine("search club member by :");
                Console.WriteLine("\t1. his teudat Zehute ");
                Console.WriteLine("\t2. his first name ");
                Console.WriteLine("\t3. his last name ");
                Console.WriteLine("\t4. member ID ");
                Console.WriteLine("\t5. date of birth ");
                Console.WriteLine("\t6. gender ");
                Console.WriteLine("\t7. gat all clab members");
                Console.WriteLine("\t8. back ");
                Console.WriteLine("\t9. back to main menu ");

                cmd = Console.ReadLine();

                switch (cmd)
                {
                case "1":
                    Console.Clear();
                    Console.WriteLine("Enter the teudat Zehute you want to find: (notice! must by numbers) ");
                    string cTZ = Console.ReadLine();
                    while (!(InputCheck.isInt(cTZ)))
                    {
                        Console.WriteLine("Invalid teudat zehute. entar again");
                        cTZ = Console.ReadLine();
                    }
                    List <object> tehudotList = itsBL.queryByString(Classes.ClubMember, stringFields.teudatZehute, cTZ);
                    Console.Clear();
                    Console.WriteLine("row. teudat Zehute|First Name|Last Name|Member ID|Date Of Birth|Gender  ");
                    List <ClubMember> newList1 = tehudotList.Cast <ClubMember>().ToList();
                    if (newList1.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");
                    }
                    int counterT = 1;
                    foreach (ClubMember c in newList1)
                    {
                        Console.WriteLine(+counterT + ".  " + c.TeudatZehute.ToString() + " | " + c.FirstName + " | " + c.LastName + " | " + c.MemberID.ToString() + " | " + c.Date_of_birth.ToString() + " | " + c.Gender.ToString());              // print the list on the screen
                        counterT++;
                    }
                    subMenu whatNext1 = new subMenu(itsBL);
                    whatNext1.Menu("4", counterT, tehudotList);

                    break;

                case "2":
                    Console.Clear();
                    Console.WriteLine("Enter the first name you want to find: ");
                    string        cFirst    = Console.ReadLine();
                    List <object> firstList = itsBL.queryByString(Classes.ClubMember, stringFields.firstName, cFirst);
                    Console.Clear();
                    Console.WriteLine("row. teudat Zehute|First Name|Last Name|Member ID|Date Of Birth|Gender  ");
                    List <ClubMember> newList2 = firstList.Cast <ClubMember>().ToList();
                    if (newList2.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");
                    }
                    int counterF = 1;
                    foreach (ClubMember c in newList2)
                    {
                        Console.WriteLine(+counterF + ".  " + c.TeudatZehute.ToString() + " | " + c.FirstName + " | " + c.LastName + " | " + c.MemberID.ToString() + " | " + c.Date_of_birth.ToString() + " | " + c.Gender.ToString());             // print the list on the screen
                        counterF++;
                    }
                    subMenu whatNext2 = new subMenu(itsBL);
                    whatNext2.Menu("4", counterF, firstList);

                    break;

                case "3":
                    Console.Clear();
                    Console.WriteLine("Enter the last name you want to find: ");
                    string        clast    = Console.ReadLine();
                    List <object> lastList = itsBL.queryByString(Classes.ClubMember, stringFields.lastName, clast);
                    Console.Clear();
                    Console.WriteLine("row. teudat Zehute|First Name|Last Name|Member ID|Date Of Birth|Gender  ");
                    List <ClubMember> newList3 = lastList.Cast <ClubMember>().ToList();
                    if (newList3.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");
                    }
                    int counterL = 1;
                    foreach (ClubMember c in newList3)
                    {
                        Console.WriteLine(+counterL + ".  " + c.TeudatZehute.ToString() + " | " + c.FirstName + " | " + c.LastName + " | " + c.MemberID.ToString() + " | " + c.Date_of_birth.ToString() + " | " + c.Gender.ToString());             // print the list on the screen
                        counterL++;
                    }
                    subMenu whatNext3 = new subMenu(itsBL);
                    whatNext3.Menu("4", counterL, lastList);

                    break;

                case "4":
                    Console.Clear();
                    Console.WriteLine("Enter the member ID you want to find: ");
                    string cMember = Console.ReadLine();
                    while (!(InputCheck.isInt(cMember)))
                    {
                        Console.WriteLine("Invalid member ID. \n entar again");
                        cMember = Console.ReadLine();
                    }
                    List <object> membIDList = itsBL.queryByString(Classes.ClubMember, stringFields.memberID, cMember);
                    Console.Clear();
                    Console.WriteLine("row. teudat Zehute|First Name|Last Name|Member ID|Date Of Birth|Gender  ");
                    List <ClubMember> newList4 = membIDList.Cast <ClubMember>().ToList();
                    if (newList4.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");
                    }
                    int counterM = 1;
                    foreach (ClubMember c in newList4)
                    {
                        Console.WriteLine(+counterM + ".  " + c.TeudatZehute.ToString() + " | " + c.FirstName + " | " + c.LastName + " | " + c.MemberID.ToString() + " | " + c.Date_of_birth.ToString() + " | " + c.Gender.ToString());             // print the list on the screen
                        counterM++;
                    }
                    subMenu whatNext4 = new subMenu(itsBL);
                    whatNext4.Menu("4", counterM, membIDList);

                    break;

                case "5":
                    Console.Clear();
                    Console.WriteLine("Choose an option: ");
                    Console.WriteLine("\t1. Search for specific date of birth ");
                    Console.WriteLine("\t2. Search range of dates of birth ");
                    string search    = Console.ReadLine();
                    string fromValue = DateTime.MinValue.ToString();
                    string toValue   = DateTime.MaxValue.ToString();
                    bool   ans       = false;
                    while (!ans)
                    {
                        switch (search)
                        {
                        case "1":
                            Console.WriteLine("enter the date: ");
                            Console.Write("Year: ");
                            string year = Console.ReadLine();
                            Console.Write("Month: (notice! enter number between 01-12) ");
                            string month = Console.ReadLine();
                            Console.Write("Day: (notice! enter number between 01-31)");
                            string day = Console.ReadLine();
                            fromValue = (day + "/" + month + "/" + year);
                            toValue   = (day + "/" + month + "/" + year);

                            break;

                        case "2":
                            Console.WriteLine("enter from which data of birth to search: ");
                            Console.Write("Year: ");
                            string fromYear = Console.ReadLine();
                            Console.Write("Month: ");
                            string fromMonth = Console.ReadLine();
                            Console.Write("Day: ");
                            string fromDay = Console.ReadLine();
                            fromValue = (fromDay + "/" + fromMonth + "/" + fromYear);

                            Console.WriteLine("enter until which data of birth to search: ");
                            Console.Write("Year: ");
                            string toYear = Console.ReadLine();
                            Console.Write("Month: ");
                            string toMonth = Console.ReadLine();
                            Console.Write("Day: ");
                            string toDay = Console.ReadLine();
                            toValue = (toDay + "/" + toMonth + "/" + toYear);

                            break;

                        default:
                            Console.WriteLine("You perform illegal move, please choose 1 or 2");
                            Thread.Sleep(2400);
                            break;
                        }
                        try
                        {
                            bool ans1 = InputCheck.isDateTime(fromValue);
                            bool ans2 = InputCheck.isDateTime(toValue);
                            ans = ans1 || ans2;
                        }
                        catch (Exception e)
                        {
                            print(e.Message, "\n ERROR: ");                               // inform the user
                            Console.ReadKey();
                        }
                    }
                    List <object> birthList = itsBL.queryByRange(Classes.ClubMember, rangeFields.date_of_birth, fromValue, toValue);
                    Console.Clear();
                    Console.WriteLine("row. teudat Zehute|First Name|Last Name|Member ID|Date Of Birth|Gender  ");
                    List <ClubMember> newList5 = birthList.Cast <ClubMember>().ToList();
                    if (newList5.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");
                    }
                    int counterB = 1;
                    foreach (ClubMember c in newList5)
                    {
                        Console.WriteLine(+counterB + ".  " + c.TeudatZehute.ToString() + " | " + c.FirstName + " | " + c.LastName + " | " + c.MemberID.ToString() + " | " + c.Date_of_birth.ToString() + " | " + c.Gender.ToString());             // print the list on the screen
                        counterB++;
                    }
                    subMenu whatNext5 = new subMenu(itsBL);
                    whatNext5.Menu("4", counterB, birthList);
                    break;

                case "6":
                    Console.Clear();
                    Console.WriteLine("Enter the gender you want to find:  ");
                    Console.WriteLine("\t1. Male");
                    Console.WriteLine("\t2. Female");
                    string cho     = Console.ReadLine();
                    string cGender = "null";
                    bool   gend    = true;
                    while (gend)
                    {
                        if (cho == "1")
                        {
                            cGender = "Male"; gend = false;
                        }
                        else if (cho == "2")
                        {
                            cGender = "Female"; gend = false;
                        }
                        else
                        {
                            Console.WriteLine("choose 1 Or 2 only");
                            cho = Console.ReadLine();
                        }
                    }
                    List <object> genderList = itsBL.queryByString(Classes.ClubMember, stringFields.gender, cGender);
                    Console.Clear();
                    Console.WriteLine("row. teudat Zehute|First Name|Last Name|Member ID|Date Of Birth|Gender  ");
                    List <ClubMember> newList6 = genderList.Cast <ClubMember>().ToList();
                    if (newList6.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");
                    }
                    int counterG = 1;
                    foreach (ClubMember c in newList6)
                    {
                        Console.WriteLine(+counterG + ".  " + c.TeudatZehute.ToString() + " | " + c.FirstName + " | " + c.LastName + " | " + c.MemberID.ToString() + " | " + c.Date_of_birth.ToString() + " | " + c.Gender.ToString());             // print the list on the screen
                        counterG++;
                    }
                    subMenu whatNext6 = new subMenu(itsBL);
                    whatNext6.Menu("4", counterG, genderList);

                    break;

                case "7":
                    Console.Clear();
                    List <ClubMember> newList7 = itsBL.getAllClubMembers().ClubMemberss;
                    Console.Clear();
                    Console.WriteLine("row. teudat Zehute|First Name|Last Name|Member ID|Date Of Birth|Gender  ");
                    if (newList7.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");
                    }
                    int counterA = 1;
                    foreach (ClubMember c in newList7)
                    {
                        Console.WriteLine(+counterA + ".  " + c.TeudatZehute.ToString() + " | " + c.FirstName + " | " + c.LastName + " | " + c.MemberID.ToString() + " | " + c.Date_of_birth.ToString() + " | " + c.Gender.ToString());             // print the list on the screen
                        counterA++;
                    }
                    List <object> allList   = newList7.Cast <object>().ToList();
                    subMenu       whatNext7 = new subMenu(itsBL);
                    whatNext7.Menu("4", counterA, allList);
                    break;

                case "8":
                    Search back = new Search(itsBL);
                    back.run();
                    break;

                case "9":
                    MainMenu moveToMenu = new MainMenu(itsBL);
                    break;

                default:
                    Console.WriteLine("You have performed an illegal move, please enter a number between 1-9");
                    Thread.Sleep(2400);
                    break;
                }
            }
        }
Ejemplo n.º 3
0
        public SearchProduct(IBL BL)
        {
            this.itsBL = BL;

            string cmd;

            while (true)
            {
                Console.Clear();
                Console.WriteLine("search product by :");
                Console.WriteLine("\t1. name ");
                Console.WriteLine("\t2. type ");
                Console.WriteLine("\t3. product ID ");
                Console.WriteLine("\t4. location (department ID ");
                Console.WriteLine("\t5. product in stock ");
                Console.WriteLine("\t6. stock count ");
                Console.WriteLine("\t7. price");
                Console.WriteLine("\t8. gat all the products ");
                Console.WriteLine("\t9. back ");
                Console.WriteLine("\t10. back to main menu ");

                cmd = Console.ReadLine();

                switch (cmd)
                {
                case "1":                                                    // search product by name
                    Console.WriteLine("Enter product name which you want to search: ");
                    string        pName    = Console.ReadLine();             // get the name the user want to search
                    List <object> nameList = itsBL.queryByString(Classes.Product, stringFields.name, pName);
                    Console.Clear();
                    Console.WriteLine("row. Product Name|Product Type|Inventory ID|Location|In Stock|Stock Count|Price");
                    List <Product> newList1 = nameList.Cast <Product>().ToList();
                    if (newList1.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");
                    }
                    int counterN = 1;
                    foreach (Product p in newList1)
                    {
                        Console.WriteLine(counterN + ".  " + p.Name + " | " + p.Type.ToString() + " | " + p.InventoryID.ToString() + " | " + p.Location.ToString() + " | " + p.INStock.ToString() + " | " + p.StockCount.ToString() + " | " + p.Price.ToString()); // print the list on the screen
                        counterN++;
                    }
                    subMenu whatNext1 = new subMenu(itsBL);
                    whatNext1.Menu("1", counterN, nameList);

                    break;

                case "2":                                                           // search by type
                    Console.WriteLine("Search for products from this type : ");
                    string pType = Console.ReadLine();                              // get the type the user want to search
                    try
                    {
                        InputCheck.isType(pType);
                    }
                    catch (Exception e)
                    {
                        print(e.Message, "\n ERROR: ");                           // inform the user
                        Console.ReadKey();
                    }
                    List <object> typeList = itsBL.queryByString(Classes.Product, stringFields.type, pType);
                    Console.Clear();
                    Console.WriteLine("row. Product Name|Product Type|Inventory ID|Location|In Stock|Stock Count|Price");
                    List <Product> newList2 = typeList.Cast <Product>().ToList();
                    if (newList2.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");
                    }
                    int counterT = 1;
                    foreach (Product p in newList2)
                    {
                        Console.WriteLine(counterT + ".  " + p.Name + " | " + p.Type.ToString() + " | " + p.InventoryID.ToString() + " | " + p.Location.ToString() + " | " + p.INStock.ToString() + " | " + p.StockCount.ToString() + " | " + p.Price.ToString());                // print the list on the screen
                        counterT++;
                    }
                    subMenu whatNext2 = new subMenu(itsBL);
                    whatNext2.Menu("1", counterT, typeList);
                    break;


                case "3":                                                          // search by product ID
                    Console.WriteLine("Search products by the ID : (notice! numbers only) ");
                    string pID = Console.ReadLine();                               // get the product ID the user want to search
                    while (!(InputCheck.isInt(pID)))
                    {
                        Console.WriteLine("Invalid ID. \n enter again");
                        pID = Console.ReadLine();
                    }
                    List <object> iDList = itsBL.queryByString(Classes.Product, stringFields.inventoryID, pID);
                    Console.Clear();
                    Console.WriteLine("row. Product Name|Product Type|Inventory ID|Location|In Stock|Stock Count|Price");
                    List <Product> newList3 = iDList.Cast <Product>().ToList();
                    if (newList3.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");
                    }
                    int counterI = 1;
                    foreach (Product p in newList3)
                    {
                        Console.WriteLine(counterI + ".  " + p.Name + " | " + p.Type.ToString() + " | " + p.InventoryID.ToString() + " | " + p.Location.ToString() + " | " + p.INStock.ToString() + " | " + p.StockCount.ToString() + " | " + p.Price.ToString());                // print the list on the screen
                        counterI++;
                    }
                    subMenu whatNext3 = new subMenu(itsBL);
                    whatNext3.Menu("1", counterI, iDList);
                    break;


                case "4":                                                          // search product by name
                    Console.WriteLine("Search all products in the department (notice! enter ID department- only numbers) : ");
                    string pDepartment = Console.ReadLine();                       // get the name the user want to search
                    while (!(InputCheck.isInt(pDepartment)))
                    {
                        Console.WriteLine("Invalid department ID. \n enter again");
                        pDepartment = Console.ReadLine();
                    }

                    List <object> departmentList = itsBL.queryByString(Classes.Product, stringFields.location, pDepartment);
                    Console.Clear();
                    Console.WriteLine("row. Product Name|Product Type|Inventory ID|Location|In Stock|Stock Count|Price");
                    List <Product> newList4 = departmentList.Cast <Product>().ToList();
                    if (newList4.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");
                    }
                    int counterD = 1;
                    foreach (Product p in newList4)
                    {
                        Console.WriteLine(counterD + ".  " + p.Name + " | " + p.Type.ToString() + " | " + p.InventoryID.ToString() + " | " + p.Location.ToString() + " | " + p.INStock.ToString() + " | " + p.StockCount.ToString() + " | " + p.Price.ToString());            // print the list on the screen
                        counterD++;
                    }
                    subMenu whatNext4 = new subMenu(itsBL);
                    whatNext4.Menu("1", counterD, departmentList);
                    break;



                case "5":
                    Console.WriteLine("choose a number: ");
                    Console.WriteLine("\t1. show all the product that in stock ");
                    Console.WriteLine("\t2. show all the product that not in stock ");
                    Console.WriteLine("\t3. show all the product that need to ordered ");
                    string pStock   = Console.ReadLine();
                    string pInStock = "";
                    switch (pStock)
                    {
                    case "1":
                        pInStock = "True";
                        break;

                    case "2":
                        pInStock = "False";
                        break;

                    case "3":
                        pInStock = "NeedToOrder";
                        break;

                    default:
                        Console.WriteLine("You have performed an illegal move, please enter 1 or 2");
                        break;
                    }
                    List <object> inStockList = itsBL.queryByString(Classes.Product, stringFields.inStock, pInStock);
                    Console.Clear();
                    Console.WriteLine("row. Product Name|Product Type|Inventory ID|Location|In Stock|Stock Count|Price");
                    List <Product> newList5 = inStockList.Cast <Product>().ToList();
                    if (newList5.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");
                    }
                    int counterS = 1;
                    foreach (Product p in newList5)
                    {
                        Console.WriteLine(+counterS + ".  " + p.Name + " | " + p.Type.ToString() + " | " + p.InventoryID.ToString() + " | " + p.Location.ToString() + " | " + p.INStock.ToString() + " | " + p.StockCount.ToString() + " | " + p.Price.ToString());                // print the list on the screen
                        counterS++;
                    }
                    subMenu whatNext5 = new subMenu(itsBL);
                    whatNext5.Menu("1", counterS, inStockList);
                    break;

                case "6":
                    Console.WriteLine("Choose an option: ");
                    Console.WriteLine("\t1. Search for specific stock count ");
                    Console.WriteLine("\t2. Search range of stock count ");
                    string search    = Console.ReadLine();
                    string fromValue = Int32.MinValue.ToString();
                    string toValue   = Int32.MaxValue.ToString();
                    switch (search)
                    {
                    case "1":
                        Console.WriteLine("enter stock count: ");
                        string stockCount = Console.ReadLine();
                        while (!(InputCheck.isInt(stockCount)))
                        {
                            Console.WriteLine("Invalid stock count. \n try again");
                            stockCount = Console.ReadLine();
                        }

                        fromValue = stockCount;
                        toValue   = stockCount;

                        break;

                    case "2":
                        Console.WriteLine("from which stock count to search: ");
                        string fromCount = Console.ReadLine();
                        while (!(InputCheck.isInt(fromCount)))
                        {
                            Console.WriteLine("Invalid stock count. \n try again");
                            fromCount = Console.ReadLine();
                        }
                        fromValue = fromCount;

                        Console.WriteLine("until which stock count to search: ");
                        string toCount = Console.ReadLine();
                        while (!(InputCheck.isInt(toCount)))
                        {
                            Console.WriteLine("Invalid stock count. \n try again");
                            toCount = Console.ReadLine();
                        }
                        toValue = toCount;

                        break;

                    default:
                        Console.WriteLine("You perform illegal move, please choose 1 or 2");
                        Thread.Sleep(2400);
                        break;
                    }
                    List <object> stockList = itsBL.queryByRange(Classes.Product, rangeFields.stockCount, fromValue, toValue);
                    Console.Clear();
                    Console.WriteLine("row. Product Name|Product Type|Inventory ID|Location|In Stock|Stock Count|Price");
                    int            counterC = 1;
                    List <Product> newList6 = stockList.Cast <Product>().ToList();
                    if (newList6.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");
                    }
                    foreach (Product p in newList6)
                    {
                        Console.WriteLine(+counterC + ".  " + p.Name + " | " + p.Type.ToString() + " | " + p.InventoryID.ToString() + " | " + p.Location.ToString() + " | " + p.INStock.ToString() + " | " + p.StockCount.ToString() + " | " + p.Price.ToString());                // print the list on the screen     Console.WriteLine(+counterC + ".  " + p.Name + "  " + p.Type.ToString() + "  " + p.InventoryID.ToString());         // print the list on the screen
                        counterC++;
                    }
                    subMenu whatNext6 = new subMenu(itsBL);
                    whatNext6.Menu("1", counterC, stockList);
                    break;

                case "7":
                    Console.WriteLine("Choose an option: ");
                    Console.WriteLine("\t1. Search for specific price ");
                    Console.WriteLine("\t2. Search range of prices ");
                    string howSearch = Console.ReadLine();
                    string fromPrice = Int32.MinValue.ToString();
                    string toPrice   = Int32.MaxValue.ToString();
                    switch (howSearch)
                    {
                    case "1":
                        Console.WriteLine("enter price: ");
                        string price = Console.ReadLine();
                        while (!(InputCheck.isDouble(price)))
                        {
                            Console.WriteLine("Invalid price. \n try again");
                            price = Console.ReadLine();
                        }
                        fromPrice = price;
                        toPrice   = price;

                        break;

                    case "2":
                        Console.WriteLine("from which price to search: ");
                        string price1 = Console.ReadLine();
                        while (!(InputCheck.isDouble(price1)))
                        {
                            Console.WriteLine("Invalid price. \n try again");
                            price1 = Console.ReadLine();
                        }
                        fromPrice = price1;

                        Console.WriteLine("until which price count to search: ");
                        string price2 = Console.ReadLine();
                        while (!(InputCheck.isDouble(price2)))
                        {
                            Console.WriteLine("Invalid price. \n try again");
                            price2 = Console.ReadLine();
                        }
                        toPrice = price2;

                        break;

                    default:
                        Console.WriteLine("You perform illegal move, please choose 1 or 2");
                        Thread.Sleep(2400);
                        break;
                    }
                    List <object> priceList = itsBL.queryByRange(Classes.Product, rangeFields.price, fromPrice, toPrice);
                    Console.Clear();
                    Console.WriteLine("row. Product Name|Product Type|Inventory ID|Location|In Stock|Stock Count|Price");
                    List <Product> newList7 = priceList.Cast <Product>().ToList();
                    if (newList7.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");
                    }
                    int counterP = 1;
                    foreach (Product p in newList7)
                    {
                        Console.WriteLine(+counterP + ".  " + p.Name + " | " + p.Type.ToString() + " | " + p.InventoryID.ToString() + " | " + p.Location.ToString() + " | " + p.INStock.ToString() + " | " + p.StockCount.ToString() + " | " + p.Price.ToString());                // print the list on the screen
                        counterP++;
                    }
                    subMenu whatNext7 = new subMenu(itsBL);
                    whatNext7.Menu("1", counterP, priceList);
                    break;

                case "8":
                    List <Product> newList8 = itsBL.getAllProducts().Productss;
                    Console.Clear();
                    Console.WriteLine("row. Product Name|Product Type|Inventory ID|Location|In Stock|Stock Count|Price");
                    if (newList8.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");
                    }
                    int counterA = 1;
                    foreach (Product p in newList8)
                    {
                        Console.WriteLine(+counterA + ".  " + p.Name + " | " + p.Type.ToString() + " | " + p.InventoryID.ToString() + " | " + p.Location.ToString() + " | " + p.INStock.ToString() + " | " + p.StockCount.ToString() + " | " + p.Price.ToString());                // print the list on the screen
                        counterA++;
                    }
                    List <object> allList   = newList8.Cast <object>().ToList();
                    subMenu       whatNext8 = new subMenu(itsBL);
                    whatNext8.Menu("1", counterA, allList);
                    break;

                case "9":
                    Search back = new Search(itsBL);
                    back.run();
                    break;

                case "10":
                    MainMenu moveToMenu = new MainMenu(itsBL);
                    break;

                default:
                    Console.WriteLine("You have performed an illegal move, please enter a number between 1-10");
                    Thread.Sleep(2400);
                    break;
                }
            }
        }
Ejemplo n.º 4
0
        public SearchDepartment(IBL bl)
        {
            this.itsBL = bl;
            string cmd;

            while (true)
            {
                Console.Clear();
                Console.WriteLine("search department by :");
                Console.WriteLine("\t1. name ");
                Console.WriteLine("\t2. department ID ");
                Console.WriteLine("\t3. gat all department");
                Console.WriteLine("\t4. back ");
                Console.WriteLine("\t5. back to main menu ");

                cmd = Console.ReadLine();

                switch (cmd)
                {
                case "1":
                    Console.WriteLine("search department with the name: ");
                    string        dName    = Console.ReadLine();                                                         //get fron the user the requested name
                    List <object> nameList = itsBL.queryByString(Classes.Department, stringFields.name, dName);          // sand the name to the appropriate query
                    Console.Clear();
                    Console.WriteLine("row. Department Name|Department ID");
                    List <Department> newDList1 = nameList.Cast <Department>().ToList();                                    // convert the list to department type
                    if (newDList1.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");                                                    // if the list is empty
                    }
                    int counterN = 1;
                    foreach (Department d in newDList1)
                    {
                        Console.WriteLine(+counterN + ".  " + d.Name + " | " + d.DepartmentID.ToString());             // print the list on the screen
                        counterN++;
                    }
                    subMenu whatNext1 = new subMenu(itsBL);
                    whatNext1.Menu("2", counterN, nameList);                                                            // send the object list to screen that presents remove and edit option

                    break;

                case "2":

                    Console.WriteLine("search department with the department ID: ");
                    string dID = Console.ReadLine();                                                                       //get fron the user the requested department ID
                    while (!(InputCheck.isInt(dID)))                                                                       // check if the user enter valid department ID
                    {
                        Console.WriteLine("Department Id must be number. enter ID again");                                 // if he didnt , asked him to enter ID again
                        dID = Console.ReadLine();
                    }
                    List <object> listID = itsBL.queryByString(Classes.Department, stringFields.departmentID, dID);          //if the ID is valid send him to the appropiate query
                    Console.Clear();
                    Console.WriteLine("row. Department Name|Department ID");
                    List <Department> newDList2 = listID.Cast <Department>().ToList();                                      //convert the list to deprtment type
                    if (newDList2.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");                                                    //if the list is empty
                    }
                    int counterI = 1;
                    foreach (Department d in newDList2)
                    {
                        Console.WriteLine(+counterI + ".  " + d.Name + "  " + d.DepartmentID.ToString());             // print the list on the screen
                        counterI++;
                    }
                    subMenu whatNext2 = new subMenu(itsBL);
                    whatNext2.Menu("2", counterI, listID);                                                              // send the object list to screen that presents remove and edit option

                    break;

                case "3":
                    List <Department> newList3 = itsBL.getAllDepartments().Departmentss;                            //presents all the departments that in the system
                    Console.Clear();
                    Console.WriteLine("row. Department Name|Department ID");
                    if (newList3.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");                                            // if the list is empty
                    }
                    int counterA = 1;
                    foreach (Department d in newList3)
                    {
                        Console.WriteLine(+counterA + ".  " + d.Name + "  " + d.DepartmentID.ToString());             // print the list on the screen
                        counterA++;
                    }
                    List <object> allList   = newList3.Cast <object>().ToList();
                    subMenu       whatNext3 = new subMenu(itsBL);
                    whatNext3.Menu("2", counterA, allList);                                                              // send the object list to screen that presents remove and edit option
                    break;

                case "4":
                    Search back = new Search(itsBL);                                                                    // return to the serch menu
                    back.run();
                    break;

                case "5":
                    MainMenu moveToMenu = new MainMenu(itsBL);                                                          //return to the main menu
                    break;

                default:
                    Console.WriteLine("You have performed an illegal move, please enter a number between 1-5");                     // if the user tried to do illegal move
                    Thread.Sleep(2400);
                    break;
                }
            }
        }
Ejemplo n.º 5
0
        public SearchTransaction(IBL BL)
        {
            this.itsBL = BL;

            string cmd;

            while (true)
            {
                Console.Clear();
                Console.WriteLine("search transaction by :");
                Console.WriteLine("\t1. transaction ID ");
                Console.WriteLine("\t2. date time ");
                Console.WriteLine("\t3. is a return ");
                Console.WriteLine("\t4. payment method ");
                Console.WriteLine("\t5. gat all transaction ");
                Console.WriteLine("\t6. back ");
                Console.WriteLine("\t7. back to main menu ");

                cmd = Console.ReadLine();

                switch (cmd)
                {
                case "1":
                    Console.WriteLine("Enter the ID you want to search (notice! must be numbers): ");
                    string tID = Console.ReadLine();
                    while (!(InputCheck.isInt(tID)))
                    {
                        Console.WriteLine("Invalid ID. \n try again");
                        tID = Console.ReadLine();
                    }
                    List <object> tIDList = itsBL.queryByString(Classes.Transaction, stringFields.transactionID, tID);
                    Console.Clear();
                    Console.WriteLine("row. Transaction ID|Transaction Date Time|Is a Return|Payment Method");
                    List <Transaction> newList1 = tIDList.Cast <Transaction>().ToList();
                    if (newList1.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");
                    }
                    int counterI = 1;
                    foreach (Transaction t in newList1)
                    {
                        Console.WriteLine(counterI + ".  " + t.TransactionID.ToString() + " | " + t.DateTime.ToString() + " | " + t.Is_a_return.ToString() + " | " + t.PaymentMethod.ToString());                 // print the list on the screen
                        counterI++;
                    }
                    subMenu whatNext1 = new subMenu(itsBL);
                    whatNext1.Menu("3", counterI, tIDList);

                    break;

                case "2":
                    Console.WriteLine("Choose an option: ");
                    Console.WriteLine("\t1. Search for specific date ");
                    Console.WriteLine("\t2. Search range of dates ");
                    string search    = Console.ReadLine();
                    string fromValue = DateTime.MinValue.ToString();
                    string toValue   = DateTime.MaxValue.ToString();
                    bool   ans       = false;
                    while (!ans)
                    {
                        switch (search)
                        {
                        case "1":
                            Console.WriteLine("enter the date: ");
                            Console.Write("Year: ");
                            string year = Console.ReadLine();
                            Console.Write("Month: ");
                            string month = Console.ReadLine();
                            Console.Write("Day: ");
                            string day = Console.ReadLine();
                            fromValue = (day + "/" + month + "/" + year);
                            toValue   = (day + "/" + month + "/" + year);

                            break;

                        case "2":
                            Console.WriteLine("enter from when to search: ");
                            Console.Write("Year: ");
                            string fromYear = Console.ReadLine();
                            Console.Write("Month: ");
                            string fromMonth = Console.ReadLine();
                            Console.Write("Day: ");
                            string fromDay = Console.ReadLine();
                            fromValue = (fromDay + "/" + fromMonth + "/" + fromYear);

                            Console.WriteLine("enter until when to search: ");
                            Console.Write("Year: ");
                            string toYear = Console.ReadLine();
                            Console.Write("Month: ");
                            string toMonth = Console.ReadLine();
                            Console.Write("Day: ");
                            string toDay = Console.ReadLine();
                            toValue = (toDay + "/" + toMonth + "/" + toYear);

                            break;

                        default:
                            Console.WriteLine("You perform illegal move, please choose 1 or 2");
                            Thread.Sleep(2400);
                            break;
                        }
                        try
                        {
                            bool ans1 = InputCheck.isDateTime(fromValue);
                            bool ans2 = InputCheck.isDateTime(toValue);
                            ans = ans1 || ans2;
                        }
                        catch (Exception e)
                        {
                            print(e.Message, "\n ERROR: ");                               // inform the user
                            Console.ReadKey();
                        }
                    }

                    List <object> dateList = itsBL.queryByRange(Classes.Transaction, rangeFields.dateTime, fromValue, toValue);
                    Console.Clear();
                    Console.WriteLine("row. Transaction ID|Transaction Date Time|Is a Return|Payment Method");
                    List <Transaction> newList2 = dateList.Cast <Transaction>().ToList();
                    if (newList2.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");
                    }
                    int counterD = 1;
                    foreach (Transaction t in newList2)
                    {
                        Console.WriteLine(counterD + ".  " + t.TransactionID.ToString() + " | " + t.DateTime.ToString() + " | " + t.Is_a_return.ToString() + " | " + t.PaymentMethod.ToString());                 // print the list on the screen
                        counterD++;
                    }
                    subMenu whatNext2 = new subMenu(itsBL);
                    whatNext2.Menu("3", counterD, dateList);

                    break;

                case "3":
                    Console.WriteLine("choose an option: ");
                    Console.WriteLine("\t1. show all the transaction that returned ");
                    Console.WriteLine("\t2. show all the transaction that didn't reurn ");
                    string tReturn   = Console.ReadLine();
                    string tIsReturn = "";
                    switch (tReturn)
                    {
                    case "1":
                        tIsReturn = "true";
                        break;

                    case "2":
                        tIsReturn = "false";
                        break;

                    default:
                        Console.WriteLine("You have performed an illegal move, please enter 1 or 2");
                        Thread.Sleep(2400);
                        break;
                    }
                    List <object> isReturnList = itsBL.queryByString(Classes.Transaction, stringFields.is_A_Return, tIsReturn);
                    Console.Clear();
                    Console.WriteLine("row. Transaction ID|Transaction Date Time|Is a Return|Payment Method");
                    List <Transaction> newList3 = isReturnList.Cast <Transaction>().ToList();
                    if (newList3.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");
                    }
                    int counterR = 1;
                    foreach (Transaction t in newList3)
                    {
                        Console.WriteLine(counterR + ".  " + t.TransactionID.ToString() + " | " + t.DateTime.ToString() + " | " + t.Is_a_return.ToString() + " | " + t.PaymentMethod.ToString());                 // print the list on the screenn
                        counterR++;
                    }
                    subMenu whatNext3 = new subMenu(itsBL);
                    whatNext3.Menu("3", counterR, isReturnList);

                    break;

                case "4":
                    Console.WriteLine("Choose the number of the payment method that you want to search by:  ");
                    Console.WriteLine("\t1. Cash \n\t 2. Credit \n\t 3. Check  ");
                    string tPay     = Console.ReadLine();
                    string tPayment = "";
                    switch (tPay)
                    {
                    case "1":
                        tPayment = "Cash";
                        break;

                    case "2":
                        tPayment = "Credit";
                        break;

                    case "3":
                        tPayment = "Check";
                        break;

                    default:
                        Console.WriteLine("You have to choose number between 1 to 3");
                        Thread.Sleep(2400);
                        break;
                    }
                    List <object> paymentList = itsBL.queryByString(Classes.Transaction, stringFields.paymentMethod, tPayment);
                    Console.Clear();
                    Console.WriteLine("row. Transaction ID|Transaction Date Time|Is a Return|Payment Method");
                    List <Transaction> newList4 = paymentList.Cast <Transaction>().ToList();
                    if (newList4.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");
                    }
                    int counterP = 1;
                    foreach (Transaction t in newList4)
                    {
                        Console.WriteLine(counterP + ".  " + t.TransactionID.ToString() + " | " + t.DateTime.ToString() + " | " + t.Is_a_return.ToString() + " | " + t.PaymentMethod.ToString());                 // print the list on the screen
                        counterP++;
                    }
                    subMenu whatNext4 = new subMenu(itsBL);
                    whatNext4.Menu("3", counterP, paymentList);

                    break;

                case "5":
                    List <Transaction> newList5 = itsBL.getAllTransaction().Transactionss;
                    Console.Clear();
                    Console.WriteLine("row. Transaction ID|Transaction Date Time|Is a Return|Payment Method");
                    if (newList5.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");
                    }
                    int counterA = 1;
                    foreach (Transaction t in newList5)
                    {
                        Console.WriteLine(counterA + ".  " + t.TransactionID.ToString() + " | " + t.DateTime.ToString() + " | " + t.Is_a_return.ToString() + " | " + t.PaymentMethod.ToString());                 // print the list on the screen
                        counterA++;
                    }
                    List <object> allList   = newList5.Cast <object>().ToList();
                    subMenu       whatNext5 = new subMenu(itsBL);
                    whatNext5.Menu("3", counterA, allList);
                    break;

                case "6":
                    Search back = new Search(itsBL);
                    back.run();
                    break;

                case "7":
                    MainMenu moveToMenu = new MainMenu(itsBL);
                    break;

                default:
                    Console.WriteLine("You have performed an illegal move, please enter a number between 1-7");
                    Thread.Sleep(2400);
                    break;
                }
            }
        }
Ejemplo n.º 6
0
        public SearchUser(IBL BL)
        {
            this.itsBL = BL;

            string cmd;

            while (true)
            {
                Console.Clear();
                Console.WriteLine("\t1. search user by username");
                Console.WriteLine("\t2. gat all users");
                Console.WriteLine("\t3. back");
                Console.WriteLine("\t4. back to main menu ");
                cmd = Console.ReadLine();

                switch (cmd)
                {
                case "1":
                    Console.WriteLine("enter the username you want to search: ");
                    string        userName = Console.ReadLine();
                    List <object> userList = itsBL.queryByString(Classes.User, stringFields.userName, userName);                // Sends the requested user to the appropriate query
                    Console.Clear();
                    Console.WriteLine("row. Username");
                    List <User> newList1 = userList.Cast <User>().ToList();             // convert the list to user
                    if (newList1.LongCount() == 0)                                      // if the list is empty
                    {
                        Console.WriteLine("There are no items to show");
                    }
                    int counterU = 1;
                    foreach (User u in newList1)                                       // If the query has found requested users
                    {
                        Console.WriteLine(counterU + ".  " + u.UserName);              // print the list on the screen
                        counterU++;
                    }
                    subMenu whatNext = new subMenu(itsBL);
                    whatNext.Menu("6", counterU, userList);                     // send the (object) list to edit and remove option
                    break;

                case "2":
                    List <User> newList2 = itsBL.getAllUsers().Userss;                          // list of all the users
                    Console.Clear();
                    Console.WriteLine("row. Username");
                    if (newList2.LongCount() == 0)                                          // if the list is empty
                    {
                        Console.WriteLine("There are no items to show");
                    }
                    int counterA = 1;
                    foreach (User u in newList2)
                    {
                        Console.WriteLine(counterA + ".  " + u.UserName);              // print the list on the screen
                        counterA++;
                    }
                    List <object> allList   = newList2.Cast <object>().ToList();        // convert the list to object type
                    subMenu       whatNext2 = new subMenu(itsBL);
                    whatNext2.Menu("6", counterA, allList);                             // send the list to edit and remove option

                    break;

                case "3":
                    Search back = new Search(itsBL);                                // return to the last screen. (the search screen)
                    back.run();
                    break;

                case "4":
                    MainMenu moveToMenu = new MainMenu(itsBL);                      // return to the main menu.
                    break;

                default:
                    Console.WriteLine("You have performed an illegal move, please enter a number between 1-3");
                    Thread.Sleep(2400);
                    break;
                }
            }
        }