Example #1
0
        public void Menu(string classNum, int toatlRow, List <object> list)
        {
            if (list.LongCount() == 0)
            {
                string whatNext;
                while (true)
                {
                    Console.WriteLine("\t1. back");
                    Console.WriteLine("\t2. Bask to main menu");
                    whatNext = Console.ReadLine();

                    switch (whatNext)
                    {
                    case "1":
                        Search back = new Search(itsBL);
                        back.run();
                        break;

                    case "2":
                        MainMenu backTo = new MainMenu(itsBL);
                        break;

                    default:
                        Console.WriteLine("you must enter 1 or 2 only");
                        Thread.Sleep(1700);
                        break;
                    }
                }
            }
            else
            {
                string whatNext1;
                while (true)
                {
                    Console.WriteLine("\t1. Remove ");
                    Console.WriteLine("\t2. Edit ");
                    Console.WriteLine("\t3. Save");
                    Console.WriteLine("\t4. back");
                    Console.WriteLine("\t5. Bask to main menu");

                    if (classNum == "1")
                    {
                        list.Cast <Product>().ToList();
                    }
                    if (classNum == "2")
                    {
                        list.Cast <Department>().ToList();
                    }
                    if (classNum == "3")
                    {
                        list.Cast <Transaction>().ToList();
                    }
                    if (classNum == "4")
                    {
                        list.Cast <ClubMember>().ToList();
                    }
                    if (classNum == "5")
                    {
                        list.Cast <Employee>().ToList();
                    }
                    if (classNum == "6")
                    {
                        list.Cast <User>().ToList();
                    }

                    whatNext1 = Console.ReadLine();

                    switch (whatNext1)
                    {
                    case "1":
                        Console.WriteLine("Enter the row number of the item that you want to remove :");
                        String remove1  = Console.ReadLine();
                        bool   toRemove = true;
                        while (toRemove)
                        {
                            while (!(InputCheck.isInt(remove1)))
                            {
                                Console.WriteLine("You have to choose number. \n enter row");
                                remove1 = Console.ReadLine();
                            }
                            int rowNum = Convert.ToInt32(remove1);
                            if (rowNum > 0 && rowNum <= toatlRow)                            // check if the user choose product from the list
                            {
                                try
                                {
                                    itsBL.remove(list.ElementAt(rowNum - 1));                        // remove the prodect
                                    Console.WriteLine("item successfully removed \n");
                                    Thread.Sleep(2200);
                                    Console.WriteLine("press 1 to remove more items ");
                                    Console.WriteLine("if you finish press any other key ");
                                    string choice = Console.ReadLine();
                                    if (choice != "1")
                                    {
                                        toRemove = false;
                                    }
                                }
                                catch (Exception e)
                                {
                                    toRemove = false;
                                    print(e.Message, "ERROR: ");
                                    Thread.Sleep(2500);
                                }
                            }
                            else
                            {
                                Console.WriteLine("You have to enter number from the list");
                                Thread.Sleep(2200);
                            }
                        }
                        break;

                    case "2":
                        Console.WriteLine("Enter the row number for the item you want to edit : ");
                        String remove2 = Console.ReadLine();
                        bool   ans     = true;
                        while (ans)
                        {
                            while (!(InputCheck.isInt(remove2)))
                            {
                                Console.WriteLine("You have to enter number. \n enter row");
                                remove2 = Console.ReadLine();
                            }
                            int rowNumber = Convert.ToInt32(remove2);
                            if (rowNumber > 0 && rowNumber <= toatlRow - 1)
                            {
                                ans = false;
                                object toEdit     = list.ElementAt(rowNumber - 1);
                                Edit   moveToEdit = new Edit(itsBL);
                                moveToEdit.toEdit(toEdit, classNum);
                            }
                            else
                            {
                                Console.WriteLine("you have to choose number from the list");
                                remove2 = Console.ReadLine();
                            }
                        }
                        break;

                    case "3":
                        itsBL.saveDataToFile();
                        Console.WriteLine("saved");
                        Thread.Sleep(2300);
                        break;

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

                    case "5":
                        MainMenu backTo = new MainMenu(itsBL);
                        break;

                    default:
                        Console.WriteLine("You have to choose number between 1-5 ");
                        Thread.Sleep(2200);
                        break;
                    }
                }
            }
        }
Example #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;
                }
            }
        }
Example #3
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;
                }
            }
        }
Example #4
0
        public void showProductList()                                               // Displays the list of products
        {
            AddScreen      addprodect   = new AddScreen(itsBL);
            Receipt        receiptToAdd = new Receipt();
            List <Product> list;
            string         choice;
            bool           ans = true;

            while (ans)
            {
                Console.WriteLine("How do you want to find the product: ");        // first we create list according to what the user want to search
                Console.WriteLine("\t1. by product name");
                Console.WriteLine("\t2. by product ID");
                choice = Console.ReadLine();

                switch (choice)
                {
                case "1":                                                                           // by product name
                    Console.WriteLine("Enter product name");
                    string name = Console.ReadLine();
                    list = itsBL.queryByString(Classes.Product, stringFields.name, name).Cast <Product>().ToList();
                    Console.WriteLine("row.  Product Name | Product Type | Inventory ID");
                    if (list.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");
                        Thread.Sleep(1200);
                        AddScreen back = new AddScreen(itsBL);
                        back.run();
                    }
                    int counter = 1;
                    foreach (Product p in list)
                    {
                        Console.WriteLine("\t" + counter + ". " + p.Name + "  |  " + p.Type.ToString() + "  |  " + p.InventoryID.ToString());
                        counter++;
                    }
                    receiptToAdd = addprodect.creatReceipt(list, counter);
                    ans          = false;
                    break;

                case "2":                                                               //by prodect ID
                    Console.WriteLine("Enter product ID: ");
                    string id = Console.ReadLine();
                    while (!(InputCheck.isInt(id)))                             // check that the ID is numbers
                    {
                        Console.WriteLine("ID must be number. enter id again");
                        id = Console.ReadLine();
                    }
                    list = itsBL.queryByString(Classes.Product, stringFields.inventoryID, id).Cast <Product>().ToList();
                    Console.WriteLine("row. | Product Name | Product Type | Inventory ID");
                    if (list.LongCount() == 0)
                    {
                        Console.WriteLine("There are no items to show");
                        Thread.Sleep(1200);
                        AddScreen back = new AddScreen(itsBL);
                        back.run();
                    }
                    int counter2 = 1;
                    foreach (Product p in list)
                    {
                        Console.WriteLine("\t" + counter2 + ". " + p.Name + "  |  " + p.Type.ToString() + "  |  " + p.InventoryID.ToString());
                        counter2++;
                    }
                    receiptToAdd = addprodect.creatReceipt(list, counter2);
                    ans          = false;
                    break;

                default:
                    Console.WriteLine("You have to choose 1 or 2 \n");
                    Thread.Sleep(2200);
                    break;
                }
            }
        }
Example #5
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;
                }
            }
        }
Example #6
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;
                }
            }
        }
Example #7
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;
                }
            }
        }
Example #8
0
        public void editEmployee(Employee preEmployee)                                              /////employee
        {
            Console.Clear();
            Employee newEmployee = new Employee(preEmployee);

            Console.WriteLine("you choose to edit the next employee: ");
            Console.WriteLine(preEmployee.toString() + "\n");
            bool ans = true;

            while (ans)
            {
                string cmd;
                Console.WriteLine("Choose the field you want to change: ");
                Console.WriteLine("\t1. employee first name ");
                Console.WriteLine("\t2. Employee last name ");
                Console.WriteLine("\t3. location (department ID) ");
                Console.WriteLine("\t4. Employee salary ");
                Console.WriteLine("\t5. supervisor ID ");
                cmd = Console.ReadLine();

                switch (cmd)
                {
                case "1":
                    Console.WriteLine("enter the new first name");
                    string newFirst = Console.ReadLine();
                    if (newFirst.Length < 1)
                    {
                        throw new Exception("Invalid First Name, Must Have Atleast One Character");
                    }
                    else
                    {
                        newEmployee.FirstName = newFirst;
                    }
                    break;

                case "2":
                    Console.WriteLine("enter the new last name");
                    string newLast = Console.ReadLine();
                    if (newLast.Length < 1)
                    {
                        throw new Exception("Invalid First Name, Must Have Atleast One Character");
                    }
                    else
                    {
                        newEmployee.LastName = newLast;
                    }
                    break;

                case "3":
                    Console.WriteLine("enter the new employee location (notice! department ID must be number ");
                    string newdepar = Console.ReadLine();
                    while (!(InputCheck.isInt(newdepar)))
                    {
                        Console.WriteLine("department ID must be numbers");
                        Console.WriteLine("enter again the new employee location");
                        newdepar = Console.ReadLine();
                    }
                    newEmployee.DepartmentID = Convert.ToInt32(newdepar);

                    break;


                case "4":
                    Console.WriteLine("enter the new employee's salary: ");
                    string salaryS = Console.ReadLine();
                    while (!(InputCheck.isDouble(salaryS)))
                    {
                        Console.WriteLine("The salary must be a posative number");
                        Console.WriteLine("enter the salary again");
                        salaryS = Console.ReadLine();
                    }
                    newEmployee.Salary = Convert.ToDouble(salaryS);

                    break;

                case "5":
                    Console.WriteLine("the new employee's suprvisor ID is (notice! supervisor ID must be number) : ");
                    string superID = Console.ReadLine();
                    while (!(InputCheck.isInt(superID)))
                    {
                        Console.WriteLine("supervisor ID must be number bigger then 0");
                        Console.WriteLine("enter new employee's supervisor ID again: ");
                        superID = Console.ReadLine();
                    }
                    newEmployee.SupervisorID = Convert.ToInt32(superID);

                    break;

                default:
                    Console.WriteLine("You have performed an illegal move");
                    break;
                }
                Console.WriteLine("if you want to change more fields press 1");
                Console.WriteLine("if you finish press any other key ");
                string want = Console.ReadLine();
                if (want != "1")
                {
                    ans = false;
                    try
                    {
                        itsBL.edit(newEmployee);
                        Console.WriteLine("Changes have been done");
                        Thread.Sleep(2000);
                        saveAndBack();
                    }
                    catch (Exception e)
                    {
                        print(e.Message, "ERROR: ");
                        Console.ReadKey();
                    }
                }
            }
        }
Example #9
0
        public void editProduct(Product prevproduct)                                                                    /////product
        {
            Console.Clear();
            Product newProduct = new Product(prevproduct);

            Console.WriteLine("you choose to edit the next product: ");
            Console.WriteLine(prevproduct.toString() + "\n");
            bool ans = true;

            while (ans)
            {
                string cmd;
                Console.WriteLine("Choose the field you want to change: ");
                Console.WriteLine("\t1. name ");
                Console.WriteLine("\t2. type ");
                Console.WriteLine("\t3. location (department ID) ");
                Console.WriteLine("\t4. stock count ");
                Console.WriteLine("\t5. price ");
                Console.WriteLine("\t6. when to order ");

                cmd = Console.ReadLine();

                switch (cmd)
                {
                case "1":
                    Console.WriteLine("enter the new name:");
                    string name = Console.ReadLine();
                    if (name.Length < 1)
                    {
                        Console.WriteLine("Invalid product Name, Must Have Atleast One Character");
                    }
                    else
                    {
                        newProduct.Name = name;
                    }
                    break;

                case "2":
                    Console.WriteLine("enter new type: ");
                    string type = Console.ReadLine();
                    try
                    {
                        InputCheck.isType(type);
                        newProduct.Type = (Backend.Type)Enum.Parse(typeof(Backend.Type), type);
                    }
                    catch (Exception e)
                    {
                        print(e.Message, "\n ERROR: ");
                        Console.ReadKey();
                    }
                    break;

                case "3":
                    Console.WriteLine("enter the new product location (notice! department ID must be numbers): ");
                    string newdepar = Console.ReadLine();
                    while (!(InputCheck.isInt(newdepar)))
                    {
                        Console.WriteLine("department ID must be numbers");
                        Console.WriteLine("enter again the new product location");
                        newdepar = Console.ReadLine();
                    }
                    newProduct.Location = Convert.ToInt32(newdepar);
                    break;

                case "4":
                    Console.WriteLine("enter new stock count:");
                    string stockCountString = Console.ReadLine();
                    while (!(InputCheck.isInt(stockCountString)))
                    {
                        Console.WriteLine("stock count must be number bigger or equal to 0 ");
                        Console.WriteLine("enter stock count again: ");
                        stockCountString = Console.ReadLine();
                    }
                    newProduct.StockCount = Convert.ToInt32(stockCountString);

                    break;

                case "5":
                    Console.WriteLine("enter new price:");
                    string priceS = Console.ReadLine();
                    while (!(InputCheck.isDouble(priceS)))
                    {
                        Console.WriteLine("price must be number above 0 (it can be Decimals) ");
                        Console.WriteLine("enter new price again:");
                        priceS = Console.ReadLine();
                    }

                    newProduct.Price = Convert.ToDouble(priceS);

                    break;

                case "6":
                    Console.WriteLine("change whan to order value");
                    string whenToOrderS = Console.ReadLine();
                    while (!(InputCheck.isInt(whenToOrderS)))
                    {
                        Console.WriteLine("whan to order must be a number");
                        Console.WriteLine("enter the whan to order value");
                        whenToOrderS = Console.ReadLine();
                    }

                    newProduct.WhenToOrder = Convert.ToInt32(whenToOrderS);

                    break;

                default:
                    Console.WriteLine("You have performed an illegal move");
                    break;
                }
                Console.WriteLine("if you want to change more fields press 1");
                Console.WriteLine("if you finish press any other key ");
                string want = Console.ReadLine();
                if (want != "1")
                {
                    ans = false;
                    try
                    {
                        itsBL.edit(newProduct);
                        Console.WriteLine("Changes have been done");
                        Thread.Sleep(2000);
                        saveAndBack();
                    }
                    catch (Exception e)
                    {
                        print(e.Message, "ERROR: ");
                        Console.ReadKey();
                    }
                }
            }
        }
Example #10
0
        public void editClubMember(ClubMember premember)                            /////club member
        {
            Console.Clear();
            ClubMember newClubMember = new ClubMember(premember);

            Console.WriteLine("you choose to edit the next club member: ");
            Console.WriteLine(premember.toString() + "\n");
            bool ans = true;

            while (ans)
            {
                string cmd;
                Console.WriteLine("Choose the field you want to change: ");
                Console.WriteLine("\t1. Club member's first name ");
                Console.WriteLine("\t2. Club member's last name ");
                Console.WriteLine("\t3. Club member's transaction history ");
                cmd = Console.ReadLine();

                switch (cmd)
                {
                case "1":
                    Console.WriteLine("enter the new first name: ");
                    string first = Console.ReadLine();
                    if (first.Length < 1)
                    {
                        Console.WriteLine("Invalid First Name, Must Have Atleast One Character");
                    }
                    else
                    {
                        newClubMember.FirstName = first;
                    }

                    break;

                case "2":
                    Console.WriteLine("enter the new last name: ");
                    string last = Console.ReadLine();
                    if (last.Length < 1)
                    {
                        Console.WriteLine("Invalid last Name, Must Have Atleast One Character");
                    }
                    else
                    {
                        newClubMember.LastName = last;
                    }

                    break;

                case "3":
                    Console.WriteLine("press 1 to add transaction to club member's transaction history ");
                    Console.WriteLine("press 2 to remove transaction from club member's transaction history ");
                    string next = Console.ReadLine();
                    switch (next)
                    {
                    case "1":
                        Console.WriteLine("enter transaction ID for add it to the history (notice! must be numbers): ");
                        string tranID = Console.ReadLine();
                        while (!(InputCheck.isInt(tranID)))
                        {
                            Console.WriteLine("The transaction ID must be a positive number");
                            Console.WriteLine("enter transaction ID (notice! must be numbers): ");
                            tranID = Console.ReadLine();
                        }
                        int add = Convert.ToInt32(tranID);
                        try
                        {
                            newClubMember.addTransactionToHistory(add);
                        }
                        catch (Exception e)
                        {
                            print(e.Message, "ERROR: ");
                            Console.ReadKey();
                        }
                        break;

                    case "2":
                        Console.WriteLine("enter transaction to remove fron the history");
                        string remove = Console.ReadLine();
                        while (!(InputCheck.isInt(remove)))
                        {
                            Console.WriteLine("The transaction ID must be a positive number");
                            Console.WriteLine("enter transaction ID (notice! must be numbers): ");
                            tranID = Console.ReadLine();
                        }
                        int toRemove = Convert.ToInt32(remove);
                        try{
                            newClubMember.removeTransactionHostory(toRemove);
                        }
                        catch (Exception e)
                        {
                            print(e.Message, "ERROR: ");
                            Console.ReadKey();
                        }

                        break;

                    default:
                        Console.WriteLine(" You have performed an illegal move ");
                        break;
                    }
                    break;
                }

                Console.WriteLine("In order to continue edit the same club member press  1 ");
                Console.WriteLine("if you finish press any other key ");
                string indicate = Console.ReadLine();
                if (indicate != "1")
                {
                    ans = false;
                    try
                    {
                        itsBL.edit(newClubMember);
                        Console.WriteLine("Changes have been done");
                        Thread.Sleep(2000);
                        saveAndBack();
                    }
                    catch (Exception e)
                    {
                        print(e.Message, "ERROR: ");
                        Console.ReadKey();
                    }
                }
            }
        }