public RegCustomer(SerializationInfo info, StreamingContext ctxt) : base(info, ctxt)
 {
     this.RegType = (RegCustomerType)info.GetValue("RegType", typeof(RegCustomerType));
 }
 public RegCustomer(String name, String address, Date dob, Date dor, List <Item> _items, RegCustomerType regType) : base(name, address, dob, dor, _items)
 {
     this.RegType = regType;
 }
Ejemplo n.º 3
0
        public void SaveCustomer(Customer c)
        {
            if (currentMode == Mode.Create)
            {
                if (CheckBox_Create_isVIP.Checked)
                {
                    double discount = (double)(CreateCustomer_Discount_Input.SelectedIndex);
                    discount /= 10;
                    Console.WriteLine("New Customer Discount: " + discount);
                    c = new VipCustomer(Text_CreateName.Text, Text_Create_Address.Text, new Date(Date_Create_DOB.Value.Day, Date_Create_DOB.Value.Month, Date_Create_DOB.Value.Year), new Date(DateTime.Now.Day, DateTime.Now.Month, DateTime.Now.Year), tempItems, discount);

                    VipCustomer v = c as VipCustomer;
                }
                else
                {
                    RegCustomerType RegTypetemp = RegCustomerType.GOLD;
                    Console.WriteLine(CreateCustomer_RegScore_ComboBox.SelectedIndex);
                    switch (CreateCustomer_RegScore_ComboBox.SelectedItem.ToString())
                    {
                    case "SILVER":
                        RegTypetemp = RegCustomerType.SILVER;
                        break;

                    case "PLATINUM":
                        RegTypetemp = RegCustomerType.PLATINUM;
                        break;

                    default:
                        break;
                    }
                    c = new RegCustomer(Text_CreateName.Text, Text_Create_Address.Text, new Date(Date_Create_DOB.Value.Day, Date_Create_DOB.Value.Month, Date_Create_DOB.Value.Year), new Date(DateTime.Now.Day, DateTime.Now.Month, DateTime.Now.Year), tempItems, RegTypetemp);
                }
                CustomerContainer.S.Add(c);
            }
            else if (currentMode == Mode.Edit)

            {
                c = CustomerContainer.S.Find(currentCustomerID);
                Console.WriteLine("Name: " + c.Name + "Type: " + c.GetType().ToString());
                c.Name    = Text_CreateName.Text;
                c.Address = Text_Create_Address.Text;
                c.dob     = new Date(Date_Create_DOB.Value.Day, Date_Create_DOB.Value.Month, Date_Create_DOB.Value.Year);

                if (c is VipCustomer)
                {
                    VipCustomer v = c as VipCustomer;
                    v.Discount = (double)(CreateCustomer_Discount_Input.SelectedIndex) / 10;
                    CreateCustomer_Discount_Input.SelectedIndex = (int)(Math.Round(v.Discount * 10));
                }
                else if (c is RegCustomer)
                {
                    Console.WriteLine("c is REG");
                    RegCustomer r = c as RegCustomer;

                    RegCustomerType RegTypetemp = (RegCustomerType)CreateCustomer_RegScore_ComboBox.SelectedIndex;
                    Console.WriteLine("Save Cust RegType: " + RegTypetemp.ToString());
                    Console.WriteLine((RegCustomerType)CreateCustomer_RegScore_ComboBox.SelectedIndex);
                    switch (RegTypetemp)
                    {
                    case RegCustomerType.SILVER:
                        break;

                    case RegCustomerType.GOLD:
                        break;

                    case RegCustomerType.PLATINUM:
                        break;

                    default:
                        break;
                    }

                    r.RegType = RegTypetemp;
                }
            }

            DataManager.S.SaveToBinary(c);
            DataManager.S.SaveAllToBinary(CustomerContainer.S);
            _mainForm.Update();
        }