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(); } }