示例#1
0
        private void btnOrderState_Click(object sender, EventArgs e)
        {
            //Stall select
            lbStall.Hide();
            lbl1.Hide();
            lbl2.Hide();
            vbStallSelect.Hide();
            cbStall.Hide();
            btnSearch.Hide();
            //Order
            lbOrder.Hide();
            lbl3.Hide();
            lbl4.Hide();
            lbl5.Hide();
            lbl6.Hide();
            lblNotification.Hide();
            lblNotification.Text = "";
            vbCheckOrder.Hide();
            vbOrderView.Hide();
            cbAmount.Hide();
            cbFood.Hide();
            btnAddFood.Hide();
            btnRemoveFood.Hide();
            btnOrder.Hide();
            btnNewOrder.Hide();
            //State
            lbl7.Show();
            lbl8.Show();
            lblState.Show();
            lblState.Text = "";
            lbOrderState.Show();
            vbOrderState.Show();
            lbl11.Show();
            lbl12.Show();
            cbOrderList.Show();
            cbOrderList.Text = "";
            btnViewState.Show();
            vbOrderID.Show();
            vbOrderState.Items.Clear();
            //Bill
            lbl10.Hide();
            vbBillView.Hide();
            lblMoney.Hide();
            lblMoney.Text = "";
            btnViewBill.Hide();
            lbl13.Hide();
            lblPay.Hide();
            lblPay.Text = "";
            btnPay.Hide();

            vbOrderID.Items.Clear();
            cbOrderList.Items.Clear();
            for (int i = 0; i < orderDatabase.getCount(); i++)
            {
                Order order = orderDatabase.getOrderList(i);
                if (order.getName() == account.getName())
                {
                    string[] arr = new string[1];
                    arr[0] = order.getID().ToString();
                    ListViewItem l1 = new ListViewItem(arr);
                    vbOrderID.Items.Add(l1);
                    cbOrderList.Items.Add(order.getID().ToString());
                }
            }
        }
        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);
        }
示例#3
0
        public Customer(CustomerAccount account, StallDatabase stallDatabase, OrderDatabase orderDatabase)
        {
            InitializeComponent();
            this.stallDatabase   = stallDatabase;
            this.orderDatabase   = orderDatabase;
            this.account         = account;
            this.reOrder         = false;
            this.orderID         = orderDatabase.getCount() + 1;
            myOrder              = new Order(orderID, account.getName());
            lblCustomerName.Text = account.getName();
            for (int i = 0; i < stallDatabase.getCount(); i++)
            {
                string[] arr = new string[2];
                arr[0] = stallDatabase.getStall(i).getID().ToString();
                arr[1] = stallDatabase.getStall(i).getName();
                ListViewItem l1 = new ListViewItem(arr);
                vbStallSelect.Items.Add(l1);
                cbStall.Items.Add(stallDatabase.getStall(i).getName());
            }

            //Stall select
            lbStall.Hide();
            lbl1.Hide();
            lbl2.Hide();
            vbStallSelect.Hide();
            cbStall.Hide();
            btnSearch.Hide();
            //Order
            lbOrder.Hide();
            lbl3.Hide();
            lbl4.Hide();
            lbl5.Hide();
            lbl6.Hide();
            lblNotification.Hide();
            lblNotification.Text = "";
            lblNoFood.Hide();
            vbCheckOrder.Hide();
            vbOrderView.Hide();
            cbAmount.Hide();
            cbFood.Hide();
            btnAddFood.Hide();
            btnRemoveFood.Hide();
            btnOrder.Hide();
            btnNewOrder.Hide();
            //State
            lbl7.Hide();
            lbl8.Hide();
            lblState.Hide();
            lblState.Text = "";
            lbOrderState.Hide();
            vbOrderState.Hide();

            lbl11.Hide();
            lbl12.Hide();
            cbOrderList.Hide();
            btnViewState.Hide();
            vbOrderID.Hide();
            //Bill
            lbl10.Hide();
            vbBillView.Hide();
            lblMoney.Hide();
            lblMoney.Text = "";
            btnViewBill.Hide();
            lbl13.Hide();
            lblPay.Hide();
            lblPay.Text = "";
            btnPay.Hide();
        }