Example #1
0
        private void Button_AddToPayment_Click(object sender, EventArgs e)
        {
            if (ItemList.CheckedIndices.Count > 1)
            {
                DialogResult d = MessageBox.Show("You can only add one item at a time", "Warning - Multiple Items Selected", MessageBoxButtons.OK);
            }
            else
            {
                Customer    c         = CustomerContainer.S.Find(int.Parse(Label_Num_Cust_ID.Text));
                List <Item> purchases = new List <Item>();
                foreach (int num in ItemList.CheckedIndices)
                {
                    c.items.Add(ItemContainer.S.Find(num));
                    purchases.Add(ItemContainer.S.Find(num));
                }
                foreach (Item purchase in purchases)
                {
                    if (c is VipCustomer)
                    {
                        VipCustomer v = c as VipCustomer;
                        v.AddToPayment(purchase.Price);
                    }
                    else
                    {
                        c.AddToPayment(purchase.Price);
                    }
                }

                SetCustomerItemList(c);
                label_text_highestPrice.Text = c.GetHighestPrice().ToString();
                label_text_Total.Text        = c.GetTotalAmount().ToString();
            }
        }
Example #2
0
        public void ViewCustomer(int customerID)
        {
            currentMode = Mode.View;
            EnableAll(true);
            Customer c = CustomerContainer.S.Find(customerID);

            Group_CreateCustomer.Visible = false;
            Group_CreateCustomer.SendToBack();
            Group_Cust_Properties.Visible = true;
            Group_Cust_Properties.BringToFront();
            Button_DeleteCustomer.Enabled = false;
            Button_DeleteCustomer.Visible = false;
            try
            {
                Label_Num_Cust_ID.Text  = c.CustomerID.ToString();
                Label_TextName.Text     = c.Name;
                Label_Text_Address.Text = c.Address;
                Label_Date_Dob.Text     = c.dob.ToString();
                Label_Date_DOR.Text     = c.dor.ToString();
                listView1.Enabled       = true;
                InitItemList();
                SetCustomerItemList(c);
                label_text_highestPrice.Text = c.GetHighestPrice().ToString();
                label_text_Total.Text        = c.GetTotalAmount().ToString();
                Button_AddToPayment.Enabled  = true;

                if (c is VipCustomer)
                {
                    Label_Customer_isVIP.Text = "Yes";
                    VipCustomer v = c as VipCustomer;
                    Label_Discount.Enabled = true;
                    Combo_Discount.Enabled = false;
                    Console.WriteLine("Discount: " + v.Discount);
                    Combo_Discount.SelectedIndex         = (int)(v.Discount * 10);
                    Input_RegCustomerScore.SelectedIndex = 3;
                    Input_RegCustomerScore.Enabled       = false;
                }

                else if (c is RegCustomer)
                {
                    Label_Customer_isVIP.Text    = "No";
                    Label_Discount.Enabled       = false;
                    Combo_Discount.Enabled       = false;
                    Combo_Discount.SelectedIndex = 0;
                    RegCustomer r = c as RegCustomer;
                    Console.WriteLine(((int)r.RegType).ToString());
                    Input_RegCustomerScore.SelectedIndex = (int)r.RegType;
                    Input_RegCustomerScore.Enabled       = false;
                }
            }
            catch (NullReferenceException e)
            {
                DialogResult d = MessageBox.Show("Customer not found", "No ID found", MessageBoxButtons.OK);
            }
        }