public static void StartShift(Employee emp) /// <summary> /// A method to start the epmloyee`s shift (starts the moment he calls this function - like swiping a card) /// start a shift means this.CurrentShift is updating /// The program picks the next available cash register which the employee will work on, and starts it /// if the last shift wasn`t ended (forgot to check out for example), he could not check in /// </summary> { if (emp.CurrentShift.Count == 1) { Console.WriteLine("Error! Your last shift was`nt ended. Please check out and try again"); } else { if (IsEmployeeAllowedToWork(emp)) { CashRegister CurrentCR = CashRegisterBL.GetClosedCashRegister(); if (CurrentCR is null) { Console.WriteLine($"No cash register available. You can`t start your shift, {emp.FullName}"); return; } emp.CurrentShift.Add(DateTime.Now); emp.CurrentCashRegister = CurrentCR.RegisterNumber; CashRegisterBL.StartTheCashRegister(emp, CurrentCR); Console.WriteLine($"Welcome, {emp.FullName}. Your cash register is {CurrentCR.RegisterNumber}"); //CashRegister.OpenedCashRegisters(); // for debugging } else { Console.WriteLine("You cannot work like that. Go home! Your debt has grown by 40 ILS."); emp.Debt += 40; } } }
public static void NextInLine() { if (SuperMarketQueue.Instance.GetCustQueue().Count == 0) { //throw new ArgumentNullException(paramName: "CustQueue", message: "Customers queue is empty. There is no one in line"); Console.WriteLine("Line is empty"); Console.WriteLine(); // to organize console for a better understanding } else { CashRegister cr = CashRegisterBL.MostAvailableCashRegister(); if (cr is null) { Console.WriteLine("No cash register available"); return; } Customer c = SuperMarketQueue.Instance.RemoveFromQueue(); CashRegisterBL.CustomerCheckout(c, cr); Console.WriteLine($"You can get in, {c.FullName}"); } }
public static void EndShift(Employee emp) /// <summary> /// A method to end the employee`s shift. /// First checking if this.CurrentShift has been started. /// If it does, the method ends the current shift, record it in this.Shifts, resets the current shift, ends the cash register and resets the current cash register property /// If not, prints an error /// </summary> { if (emp.CurrentShift.Count == 1 && emp.CurrentCashRegister != "0") { emp.CurrentShift.Add(DateTime.Now); Console.WriteLine($"Goodbye, {emp.FullName}"); SubFromDebtByWork(emp.CurrentShift[0], emp.CurrentShift[1], emp); emp.Shifts.Add(emp.CurrentShift); emp.CurrentShift = new List <DateTime>(); CashRegister CurrentCR = CashRegisterBL.GetCashRegisterByNumber(emp.CurrentCashRegister); CashRegisterBL.StopTheCashRegister(emp, CurrentCR); } else { Console.WriteLine("Error! There is no active shift. Please check in first."); } }
public static void CashRegistersManamgement() { Console.Write("Welcome to cash register management menu. Please enter cash register number [1/2/3/4]: "); string reg_choice = Console.ReadLine(); CashRegister CRegister = CashRegisterBL.GetCashRegisterByNumber(reg_choice); if (CRegister is null) { Console.WriteLine("Cash register doesn`t exist."); return; } StringBuilder sb = new StringBuilder(); sb.AppendLine(); sb.AppendLine(); sb.AppendLine("What would you like to do?"); sb.AppendLine(); sb.AppendLine("1 - Products history"); sb.AppendLine("2 - Cashiers history"); sb.AppendLine("3 - Customers history"); sb.AppendLine("4 - Go back to main menu"); Console.WriteLine(sb.ToString()); int choice = 5; // default value for the choice (if client`s input is wrong, program will get into the loop and give him another try) Console.Write("Your choice: "); string string_choice = Console.ReadLine(); // input for client`s choice try { choice = int.Parse(string_choice); } // trying to parse client`s choice to int catch { } // if client`s input is wrong, keeps choice as 5 while (choice != 4) { switch (choice) { case 1: CashRegisterBL.ShowProductHistory(CRegister); break; case 2: CashRegisterBL.ShowCashierHistory(CRegister); break; case 3: CashRegisterBL.ShowCustomersHistory(CRegister); break; case 4: return; default: Console.WriteLine("No such option"); break; } sb = new StringBuilder(); sb.AppendLine(); sb.AppendLine(); sb.AppendLine("What would you like to do?"); sb.AppendLine(); sb.AppendLine("1 - Products history"); sb.AppendLine("2 - Cashiers history"); sb.AppendLine("3 - Customers history"); sb.AppendLine("4 - Go back to main menu"); Console.WriteLine(sb.ToString()); Console.Write("Your choice: "); string_choice = Console.ReadLine(); try { choice = int.Parse(string_choice); } catch { choice = 5; } Console.Clear(); } }