예제 #1
0
        private static void Employeef()
        {
            try
            {
                string        u, p;
                int           eidf, ch;
                bool          status = false;
                EmployeeDAL   e      = new EmployeeDAL();
                logindelegate ld     = new logindelegate(e.Login);
                Console.WriteLine("Username: "******"Password: "******"Employee Menu");
                        Console.WriteLine("1.Apply Leave");
                        Console.WriteLine("2.Leave Application Status");
                        Console.WriteLine("3.Cancel Leave Application");
                        Console.WriteLine("4.View Leave History");
                        Console.WriteLine("5.View Leave Availablity");
                        Console.WriteLine("6.Logout");
                        Console.WriteLine("Choice: ");
                        ch = Convert.ToInt32(Console.ReadLine());
                        switch (ch)
                        {
                        case 1:
                        {
                            for (int i = 0; i < DataSource.lal.Count && status == false; i++)
                            {
                                if (DataSource.lal[i].propEmployeeId3 == eidf)
                                {
                                    e.ApplyLeave(DataSource.lal[i]);
                                    status = true;
                                    //break;
                                }
                            }
                            if (status == false)
                            {
                                Console.WriteLine("404: Leave Not Applied :(");
                            }
                            break;
                        }

                        case 2:
                        {
                            int leaveid;
                            status = false;
                            Console.WriteLine("Search Leave Application ID: ");
                            leaveid = Convert.ToInt32(Console.ReadLine());
                            for (int i = 0; i < DataSource.lal.Count && status == false; i++)
                            {
                                if (DataSource.lal[i].propEmployeeId3 == eidf && DataSource.lal[i].propLeaveApplicationId == leaveid)
                                {
                                    status = true;
                                    e.ViewCurrentLeaveStatus(DataSource.lal[i].propleavestatus);
                                    //break;
                                }
                            }
                            if (status == false)
                            {
                                Console.WriteLine("404: Leave Not Found :(");
                            }
                            break;
                        }

                        case 3:
                        {
                            int leaveid;
                            status = false;
                            Console.WriteLine("Search Leave Application ID: ");
                            leaveid = Convert.ToInt32(Console.ReadLine());
                            for (int i = 0; i < DataSource.lal.Count && status == false; i++)
                            {
                                if (DataSource.lal[i].propEmployeeId3 == eidf && DataSource.lal[i].propLeaveApplicationId == leaveid)
                                {
                                    status = true;
                                    e.CancelLeave(leaveid);
                                    //break;
                                }
                            }
                            if (status == false)
                            {
                                Console.WriteLine("404: Leave Not Found :(");
                            }
                            break;
                        }

                        case 4:
                        {
                            //int leaveid;
                            status = false;
                            //Console.WriteLine("Search Leave Application ID: ");
                            // leaveid = Convert.ToInt32(Console.ReadLine());
                            for (int i = 0; i < DataSource.lal.Count && status == false; i++)
                            {
                                if (DataSource.lal[i].propEmployeeId3 == eidf)
                                {
                                    status = true;
                                    e.ViewLeaveHistory(eidf, DataSource.lal[i].propLeaveTypeId);
                                    //break;
                                }
                            }
                            if (status == false)
                            {
                                Console.WriteLine("404: Leave Not Taken :(");
                            }
                            break;
                        }

                        case 5:
                        {
                            //int leaveid;
                            status = false;
                            //Console.WriteLine("Search Leave Application ID: ");
                            // leaveid = Convert.ToInt32(Console.ReadLine());
                            for (int i = 0; i < DataSource.lal.Count && status == false; i++)
                            {
                                if (DataSource.lal[i].propEmployeeId3 == eidf)
                                {
                                    status = true;
                                    e.ViewLeaveAvailability(eidf);
                                    //break;
                                }
                            }
                            if (status == false)
                            {
                                Console.WriteLine("404: Leave Not Found :(");
                            }
                            break;
                        }

                        case 6:
                        {
                            return;
                        }
                        }
                        Console.ReadKey();
                    }
                }
                else
                {
                    Console.WriteLine("Login Failed. Try Again.");
                }
                //throw new NotImplementedException();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            Console.ReadKey();
        }
예제 #2
0
        private static void Employeef()
        {
            try
            {
                string u, p = "";

                int           eidf, ch;
                bool          status = false;
                EmployeeDAL   e      = new EmployeeDAL();
                logindelegate ld     = new logindelegate(e.Login);
                Console.WriteLine("\n\n\n");
                Console.WriteLine("Username: "******"Password: "******"Password: "******"";
                ConsoleKeyInfo kk;
                do
                {
                    kk = Console.ReadKey(true);
                    if (kk.Key != ConsoleKey.Backspace && kk.Key != ConsoleKey.Enter)
                    {
                        // p2.Append(kk.KeyChar);
                        p += kk.KeyChar;

                        Console.Write("*");
                    }
                    else if (kk.Key == ConsoleKey.Backspace && p.Length > 0)
                    {
                        p = p.Substring(0, p.Length - 1);
                        Console.Write("\b \b");
                    }
                } while (kk.Key != ConsoleKey.Enter);
                // p = Console.ReadLine();
                //p2.Remove(p2.Length - 1,1);
                //p = p2.ToString();

                //Console.WriteLine(p.GetType());
                //Console.WriteLine(p2);
                //Console.WriteLine(p);
                //Console.WriteLine(p.Length);

                if (ld.Invoke(u, p, out eidf))
                {
                    while (true)
                    {
                        Console.Clear();

                        Console.WriteLine("Employee Menu");
                        alertpublisher a1 = new alertpublisher();
                        empsubscriber  e1 = new empsubscriber();

                        e1.subscribe(a1);
                        bool x = a1.trigger();
                        Console.WriteLine();
                        Console.WriteLine();
                        Console.WriteLine("1.Leave Application Status");
                        Console.WriteLine("2.Cancel Leave Application");
                        Console.WriteLine("3.View Leave History");
                        Console.WriteLine("4.View Leave Availablity");
                        if (x == true)
                        {
                            Console.WriteLine("5.Apply Leave");
                        }
                        Console.WriteLine("66.Logout");
                        Console.WriteLine("Choice: ");
                        ch = Convert.ToInt32(Console.ReadLine());
                        switch (ch)
                        {
                        case 5:
                        {
                            if (x == true)
                            {
                                for (int i = 0; i < DataSource.lal.Count && status == false; i++)
                                {
                                    if (DataSource.lal[i].propEmployeeId3 == eidf)
                                    {
                                        e.ApplyLeave(DataSource.lal[i]);
                                        status = true;
                                        //break;
                                    }
                                }
                                if (status == false)
                                {
                                    Console.WriteLine("404: Leave Not Applied :(");
                                }
                            }
                            else
                            {
                                Console.WriteLine("Leave can be applied only during office hours.");
                            }
                            break;
                        }

                        case 1:
                        {
                            int leaveid;
                            status = false;
                            Console.WriteLine("Search Leave Application ID: ");
                            leaveid = Convert.ToInt32(Console.ReadLine());
                            for (int i = 0; i < DataSource.lal.Count && status == false; i++)
                            {
                                if (DataSource.lal[i].propEmployeeId3 == eidf && DataSource.lal[i].propLeaveApplicationId == leaveid)
                                {
                                    status = true;
                                    e.ViewCurrentLeaveStatus(DataSource.lal[i].propleavestatus);
                                    //break;
                                }
                            }
                            if (status == false)
                            {
                                Console.WriteLine("404: Leave Not Found :(");
                            }
                            break;
                        }

                        case 2:
                        {
                            int leaveid;
                            status = false;
                            Console.WriteLine("Search Leave Application ID: ");
                            leaveid = Convert.ToInt32(Console.ReadLine());
                            for (int i = 0; i < DataSource.lal.Count && status == false; i++)
                            {
                                if (DataSource.lal[i].propEmployeeId3 == eidf && DataSource.lal[i].propLeaveApplicationId == leaveid)
                                {
                                    status = true;
                                    e.CancelLeave(leaveid);
                                    //break;
                                }
                            }
                            if (status == false)
                            {
                                Console.WriteLine("404: Leave Not Found :(");
                            }
                            break;
                        }

                        case 3:
                        {
                            //int leaveid;
                            status = false;
                            //Console.WriteLine("Search Leave Application ID: ");
                            // leaveid = Convert.ToInt32(Console.ReadLine());
                            for (int i = 0; i < DataSource.lal.Count && status == false; i++)
                            {
                                if (DataSource.lal[i].propEmployeeId3 == eidf)
                                {
                                    status = true;
                                    e.ViewLeaveHistory(eidf, DataSource.lal[i].propLeaveTypeId);
                                    //break;
                                }
                            }
                            if (status == false)
                            {
                                Console.WriteLine("404: Leave Not Taken :(");
                            }
                            break;
                        }

                        case 4:
                        {
                            //int leaveid;
                            status = false;
                            //Console.WriteLine("Search Leave Application ID: ");
                            // leaveid = Convert.ToInt32(Console.ReadLine());
                            for (int i = 0; i < DataSource.lal.Count && status == false; i++)
                            {
                                if (DataSource.lal[i].propEmployeeId3 == eidf)
                                {
                                    status = true;
                                    e.ViewLeaveAvailability(eidf);
                                    //break;
                                }
                            }
                            if (status == false)
                            {
                                Console.WriteLine("404: Leave Not Found :(");
                            }
                            break;
                        }

                        case 66:
                        {
                            return;
                        }
                        }
                        Console.ReadKey();
                    }
                }
                else
                {
                    Console.WriteLine("Login Failed. Try Again.");
                }
                //throw new NotImplementedException();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            Console.ReadKey();
        }