예제 #1
0
        private void btnEndSession_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Are you sure you want to end the session? Client details will be reset.", "End Session", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                Customer           = null;
                LoanOrder          = null;
                ReturnOrder        = null;
                SelectedReturnItem = null;
                UpdateCustomerGUI();
                RefreshLoanOrderGUI();
                timerDBCheck.Enabled = true;
            }
            else if (dialogResult == DialogResult.No)
            {
            }
        }
예제 #2
0
        private void btnLogOff_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Are you sure you want to log off? You will be returned to the login page.", "Logg Off", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                Customer           = null;
                LoanOrder          = null;
                ReturnOrder        = null;
                SelectedReturnItem = null;
                UpdateCustomerGUI();
                RefreshLoanOrderGUI();
                RFIDReader.Close();
                LoadingLoginWindow();
                timerDBCheck.Enabled = true;
            }
            else if (dialogResult == DialogResult.No)
            {
            }
        }
예제 #3
0
        public void OnLoginSuccess(object source, LoginEventArgs e)
        {
            this.WindowState     = FormWindowState.Normal;
            this.ShowInTaskbar   = true;
            this.Visible         = true;
            Customer             = null;
            timerDBCheck.Enabled = true;
            LoanOrder            = null;
            UpdateCustomerGUI();
            RefreshLoanOrderGUI();
            RFIDReader.Open();

            List <string> temp = StoreDLL.GetEmployeeData(e.Username, e.Password);

            if (temp.Count() > 0)
            {
                string fullname;
                fullname           = temp[2] + " " + temp[3];
                lblStaffName.Text  = fullname;
                lblStaffLevel.Text = temp[7];
            }
        }
예제 #4
0
        private void RFIDReader_Tag(object sender, RFIDTagEventArgs e)
        {
            if (Customer == null)
            {
                try
                {
                    timerDBCheck.Enabled = false;
                    List <string> temp = StoreDLL.GetCostumerData(e.Tag);

                    Customer         = new Customer(Convert.ToInt32(temp[0]), temp[1], temp[2], Convert.ToDouble(temp[3]), temp[6]);
                    LoanOrder        = new LoanOrder(Customer.CostumerID);
                    ReturnOrder      = new ReturnOrder(Customer.CostumerID);
                    LoanOrder.Error += this.OnError;
                    UpdateCustomerGUI();
                    RefreshLoanOrderGUI();
                }

                catch (MySqlException)
                {
                    MessageBox.Show("Check your connection. Unable to reach database.");
                    Customer  = null;
                    LoanOrder = null;
                    UpdateCustomerGUI();
                    RefreshLoanOrderGUI();
                    timerDBCheck.Enabled = true;
                }

                catch (System.ArgumentOutOfRangeException)
                {
                    MessageBox.Show("Tag does not conform with a visitor.");
                    Customer  = null;
                    LoanOrder = null;
                    UpdateCustomerGUI();
                    RefreshLoanOrderGUI();
                    timerDBCheck.Enabled = true;
                }
            }
        }
예제 #5
0
        private void pnlConfirmLoan_Click(object sender, EventArgs e)
        {
            if (LoanOrder.OrderList.Count != 0)
            {
                DialogResult dialogResult = MessageBox.Show("Press YES if you want to process order and move to the next client.", "Confirm Loan", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    if (Customer != null && LoanOrder != null)
                    {
                        try
                        {
                            LoanOrder.ProcessLoanOrder(Customer.BalanceLeft);
                            Customer             = null;
                            LoanOrder            = null;
                            ReturnOrder          = null;
                            SelectedReturnItem   = null;
                            timerDBCheck.Enabled = true;
                            UpdateCustomerGUI();
                            RefreshLoanOrderGUI();
                        }

                        catch (MySqlException)
                        {
                            MessageBox.Show("Check your connection. Unable to reach the database.");
                        }
                    }
                }
                else if (dialogResult == DialogResult.No)
                {
                }
            }

            else
            {
                MessageBox.Show("No items in order.");
            }
        }
예제 #6
0
        private void btnConfirmReturn_Click(object sender, EventArgs e)
        {
            if (ReturnOrder != null)
            {
                if (SelectedReturnItem != null)
                {
                    if (SelectedReturnItem.ReturnStatus != null)
                    {
                        try
                        {
                            if (SelectedReturnItem.ReturnStatus == "NO DAMAGE")
                            {
                                StoreDLL.ProcessReturnItem(Customer.CostumerID, SelectedReturnItem.ID, SelectedReturnItem.ItemNumber, SelectedReturnItem.ReturnStatus);
                                int quantity = StoreDLL.GetQuantity(SelectedReturnItem.ID, "borrowable");
                                quantity = quantity + 1;
                                StoreDLL.ProcessReturnStockBalance(Customer.CostumerID, Customer.BalanceLeft, SelectedReturnItem.ID, quantity);
                            }

                            else
                            {
                                if (Customer.BalanceLeft >= SelectedReturnItem.Penalty)
                                {
                                    StoreDLL.ProcessReturnItem(Customer.CostumerID, SelectedReturnItem.ID, SelectedReturnItem.ItemNumber, SelectedReturnItem.ReturnStatus);
                                    Customer.BalanceLeft = Customer.BalanceLeft - SelectedReturnItem.Penalty;
                                    int quantity = StoreDLL.GetQuantity(SelectedReturnItem.ID, "borrowable");
                                    StoreDLL.ProcessReturnStockBalance(Customer.CostumerID, Customer.BalanceLeft, SelectedReturnItem.ID, quantity);
                                }

                                else
                                {
                                    MessageBox.Show("No enough balance left.");
                                }
                            }

                            LoanOrder          = null;
                            SelectedReturnItem = null;
                            ReturnOrder        = null;
                            ReturnOrder        = new ReturnOrder(Customer.CostumerID);
                            LoanOrder          = new LoanOrder(Customer.CostumerID);
                        }

                        catch
                        {
                            MessageBox.Show("Check your connection. Unable to reach database.");
                        }
                    }

                    else
                    {
                        MessageBox.Show("No return status selected.");
                    }
                }

                else
                {
                    MessageBox.Show("No item selected.");
                }
            }

            RefreshLoanOrderGUI();
            UpdateCustomerGUI();
        }