static void Main(string[] args)
        {
            int  id;
            bool valid;

            try{
                do
                {
                    Console.Write("Please enter Employee ID : ");
                    id = Convert.ToInt32(Console.ReadLine());

                    if (id < 100 || id > 110)
                    {
                        System.Console.WriteLine("Incorrect Employee ID");
                        valid = false;
                    }
                    else
                    {
                        valid = true;
                    }
                }while(valid == false);

                Writer w = new Writer(file_path);

                new Program().pathGetter();

                int choice;
                System.Console.WriteLine("1.Create Leave     2.List Leaves      3.Update Leaves       4.Search Leaves       5.Exit");
                System.Console.Write("Please enter your choice : ");
                choice = Convert.ToInt32(Console.ReadLine());


                while (choice != 5)
                {
                    switch (choice)
                    {
                    case 1:
                        //call to CreateLeave()
                        CreateLeave cl = new CreateLeave();
                        cl.Leave(id, w, file_path);
                        break;

                    case 2:
                        //call to ListLeaves()
                        ListLeaves ll = new ListLeaves();
                        ll.List(id, file_path);
                        break;

                    case 3:
                        //call to UpdateLeaves()
                        UpdateLeaves ul = new UpdateLeaves();
                        ul.Update(id, file_path);
                        break;

                    case 4:
                        //Call to SearchLeaves()
                        SearchLeaves sl = new SearchLeaves();
                        sl.Search(id, file_path);
                        break;

                    default:
                        System.Console.WriteLine("Invalid Choice");
                        break;
                    }

                    System.Console.WriteLine("1.Create Leave     2.List Leaves      3.Update Leaves       4.Search Leaves       5.Exit");
                    System.Console.Write("Please enter your choice : ");
                    choice = Convert.ToInt32(Console.ReadLine());
                }//end of while
            }
            catch (Exception)
            {
                System.Console.WriteLine("Error occured");
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            int id;
            int choice;


            do
            {
                Console.WriteLine("Enter the Employee ID : ");
                id = Convert.ToInt32(Console.ReadLine());
            }while(id < 100 && id >= 110);



            Program p = new Program();

            p.PathGetter();
            Writer w = new Writer(path);

            do
            {
                Console.WriteLine("Menu:\n1.Create Leave\n2.List Of Leaves\n3.Update Leave\n4.Search Leave\n");
                Console.WriteLine("Enter your choice : ");
                choice = Convert.ToInt32(Console.ReadLine());
                switch (choice)
                {
                case 1: {
                    //call to create leave
                    CreateLeave cl = new CreateLeave();
                    cl.Leave(w, id, path);
                    break;
                }

                case 2: {
                    //call to List of leave
                    ListLeaves list = new ListLeaves();
                    list.List(id, path);
                    break;
                }

                case 3: {
                    //call to Update leave
                    UpdateLeaves ul = new UpdateLeaves();
                    ul.Update(id, path);
                    break;
                }

                case 4: {
                    //call to Search leave
                    int ch;
                    Console.WriteLine("Search By\n1.Title\n2.Status\n");
                    Console.WriteLine("Enter Your choice: ");
                    ch = Convert.ToInt32(Console.ReadLine());
                    switch (ch)
                    {
                    case 1: {
                        //search by title
                        SearchLeaves sl = new SearchLeaves();
                        sl.SearchByTitle(id, path);
                        break;
                    }

                    case 2: {
                        //search by status
                        SearchLeaves sl = new SearchLeaves();
                        sl.SearchByStatus(id, path);
                        break;
                    }

                    default:
                        Console.WriteLine("Invalid choice\n");
                        break;
                    }
                    break;
                }

                case 0: {
                    return;
                }

                default:
                    Console.WriteLine("Invalid choice\n");
                    break;
                }
            }while(choice != 0);
        }