public StallOwner(StaffAccount account, ReportDatabase reportDatabase, StallDatabase stallDatabase) { InitializeComponent(); lblName.Text = account.getName(); this.stallDatabase = stallDatabase; this.reportDatabase = reportDatabase; this.account = account; this.myStall = stallDatabase.getOwnerStall(account.getID()); //Add food lbl1.Hide(); lbl2.Hide(); lbl3.Hide(); txtFoodID.Hide(); txtFoodName.Hide(); txtCost.Hide(); btnAdd.Hide(); lblAddFoodNotification.Hide(); lblAddFoodNotification.Text = ""; //View food lbl4.Hide(); lbl5.Hide(); lbl6.Hide(); lblStallID.Hide(); lblStallName.Hide(); vbFoodList.Hide(); //View report vbReport.Hide(); }
public bool addStaffAccount(String name, String pass, Authorization authorization, int id) { for (int i = 0; i < accounts.Count(); i++) { if (accounts.ElementAt <Account>(i).getName() == name) { return(false); } } Account newAccount = new StaffAccount(name, pass, authorization, id); accounts.AddLast(newAccount); count++; return(true); }
public bool checkAuthorization(int id) { for (int i = 0; i < accounts.Count(); i++) { Account otherAccount = accounts.ElementAt <Account>(i); if (otherAccount.GetType() == typeof(StaffAccount)) { StaffAccount account = (StaffAccount)otherAccount; if (account.getID() == id && account.getAuthorization() == Authorization.MASTERITSTAFF) { return(true); } } } return(false); }
public ITStaff(StaffAccount account, AccountDatabase accountDatabase, StallDatabase stallDatabase) { InitializeComponent(); this.accountDatabase = accountDatabase; this.account = account; this.stallDatabase = stallDatabase; lbName.Text = account.getName(); //Maintenance Mode btnMaintenanceOK.Hide(); btnMaintenanceCancel.Hide(); lbMaintenance.Hide(); lblMaintenanceFailed.Text = ""; //Add Account for Staff lblAccName.Hide(); lblAccPass.Hide(); lblAccPassCheck.Hide(); lblAddAccNoti.Hide(); txtStaffName.Hide(); txtStaffPass.Hide(); txtStaffPassCheck.Hide(); btnAddAccount.Hide(); btnAccCancel.Hide(); lblAuthorization.Hide(); cbAuthorization.Hide(); lblAccID.Hide(); txtAccID.Hide(); lblAddAccNoti.Text = ""; //Add/RemoveStall btnAddStall.Hide(); btnRemoveStall.Hide(); lblStallID.Hide(); lblStallName.Hide(); txtStallID.Hide(); txtStallName.Hide(); btnAddStallCmd.Hide(); lsEditStall.Hide(); btnAddStallCancel.Hide(); btnRemoveStallCmd.Hide(); btnRemoveStallCancel.Hide(); lblRemoveNotification.Hide(); lblRemoveNotification.Text = ""; btnRemoveCheck.Hide(); lblAddNotification.Hide(); lblAddNotification.Text = ""; txtStallOwner.Hide(); lbl1.Hide(); }
public Cook(StaffAccount account, OrderDatabase orderDatabase) { InitializeComponent(); this.account = account; this.orderDatabase = orderDatabase; lblName.Text = account.getName(); //View order lbl1.Hide(); lbl2.Hide(); lbl3.Hide(); cbSearchName.Hide(); btnView.Hide(); vbOrderInfo.Hide(); vbOrderList.Hide(); lblNotification.Hide(); lblNotification.Text = ""; lbList.Hide(); //Update state lbl4.Hide(); lbl5.Hide(); lbl6.Hide(); cbState.Hide(); lblStateNotification.Hide(); lblStateNotification.Text = ""; lblCurrentState.Hide(); lblCurrentState.Text = ""; btnOK.Hide(); for (int i = 0; i < orderDatabase.getCount(); i++) { string[] arr = new string[1]; arr[0] = orderDatabase.getOrderList(i).getName(); ListViewItem l1 = new ListViewItem(arr); vbOrderList.Items.Add(l1); cbSearchName.Items.Add(orderDatabase.getOrderList(i).getName()); } }
static void Main() { AccountDatabase accountDatabase = new AccountDatabase(); StallDatabase stallDatabase = new StallDatabase(); OrderDatabase orderDatabase = new OrderDatabase(); ReportDatabase reportDatabase = new ReportDatabase(); string[] line_1 = System.IO.File.ReadAllLines("Accountdatabase.txt"); foreach (string line in line_1) { int count = 0; for (int i = 0; i < line.Length; i++) { if (line[i] == ' ') { count++; } } if (count == 3) //Staff { Account account = new StaffAccount(); String temp = ""; int d = 0; for (int i = 0; i < line.Length; i++) { if (line[i] == ' ') { if (d == 0) { account.setName(temp); } else if (d == 1) { account.setPassword(temp); } else if (d == 2) { Authorization authorization = Authorization.COOK; switch (temp) { case "MANAGER": authorization = Authorization.MANAGER; break; case "COOK": authorization = Authorization.COOK; break; case "ITSTAFF": authorization = Authorization.ITSTAFF; break; case "STALLOWNER": authorization = Authorization.STALLOWNER; break; case "CUSTOMER": authorization = Authorization.CUSTOMER; break; case "MASTERITSTAFF": authorization = Authorization.MASTERITSTAFF; break; } account.setAuthorization(authorization); } d++; temp = ""; } else { temp += line[i]; } } accountDatabase.addStaffAccount(account.getName(), account.getPassword(), account.getAuthorization(), (int)Double.Parse(temp)); } else { Account account = new CustomerAccount(); String temp = ""; int d = 0; for (int i = 0; i < line.Length; i++) { if (line[i] == ' ') { if (d == 0) { account.setName(temp); } else { account.setPassword(temp); } d++; temp = ""; } else { temp += line[i]; } } accountDatabase.addCustomerAccount(account.getName(), account.getPassword()); } } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1(accountDatabase)); String[] lines = new String[accountDatabase.getCount()]; for (int i = 0; i < lines.Length; i++) { //CustomerAccount customerAccount = null; Account otherAccount = accountDatabase.getAccount(i); if (otherAccount.GetType() == typeof(CustomerAccount)) { CustomerAccount account = (CustomerAccount)otherAccount; lines[i] = account.getName() + " " + account.getPassword() + " CUSTOMER"; } else { StaffAccount account = (StaffAccount)accountDatabase.getAccount(i); String authorization = ""; switch (accountDatabase.getAccount(i).getAuthorization()) { case Authorization.MANAGER: authorization = "MANAGER"; break; case Authorization.COOK: authorization = "COOK"; break; case Authorization.ITSTAFF: authorization = "ITSTAFF"; break; case Authorization.STALLOWNER: authorization = "STALLOWNER"; break; case Authorization.MASTERITSTAFF: authorization = "MASTERITSTAFF"; break; } lines[i] = account.getName() + " " + account.getPassword() + " " + authorization + " " + account.getID(); } } System.IO.File.WriteAllLines("Accountdatabase.txt", lines); }