Esempio n. 1
0
        /// <summary>
        /// Author: Cuong Nguyen
        /// Purpose: To calculate the sum of all the tax amount from all the package in 1 invoice
        /// </summary>
        /// <returns></returns>
        public void CalculateTax()
        {
            subTotal = 0;

            foreach (Package item in Packages)
            {
                if (item.ShippingMethod == "Over Night")
                {
                    OverNight newItem = new OverNight(item.Weight, item.CostPerOunce);
                    subTotal += newItem.CalculateCost();
                }
                else
                {
                    TwoDay newItem = new TwoDay(item.Weight, item.CostPerOunce);
                    subTotal += newItem.CalculateCost();
                }
            }
            TaxTotal += subTotal * TaxRate;
        }
Esempio n. 2
0
        private void Button5_Click(object sender, EventArgs e)
        {
            int id = listBox1.SelectedIndex;


            if (rbOverNight.Checked == true)
            {
                OverNight aPackage = new OverNight();
                aPackage.RecipientName    = txtBxRecipientName.Text;
                aPackage.RecipientAddress = txtBxRecipientAddress.Text;
                aPackage.RecipientCity    = txtBxRecipientAddress.Text;
                aPackage.RecipientState   = txtBxRecipientState.Text;
                aPackage.RecipientZipCode = txtBxRecipientZipCode.Text;

                aPackage.SenderName    = txtBxSenderName.Text;
                aPackage.SenderAddress = txtBxSenderAddress.Text;
                aPackage.SenderCity    = txtBxSenderCity.Text;
                aPackage.SenderState   = txtBxSenderState.Text;
                aPackage.SenderZipCode = txtBxSenderZipCode.Text;
                // This one is to get the checked shipping company
                for (int i = 0; i <= (chShipCompany.Items.Count - 1); i++)
                {
                    if (chShipCompany.GetItemChecked(i))
                    {
                        aPackage.ShippingCompany = chShipCompany.Items[i].ToString();
                    }
                }
                aPackage.ShippingMethod = "Over Night";
                aPackage.Weight         = Convert.ToDecimal(textBox1.Text);
                ServiceReference1.Service1Client service = new ServiceReference1.Service1Client();
                aPackage.CostPerOunce = service.GetCost(aPackage.ShippingCompany);
                aPackage.Cost         = aPackage.CalculateCost();
                ClearTextBoxes();
                listBox1.Items.Clear();
                //listBox1.Items.Add(aPackage);
                //anInvoice.Packages.Add(aPackage);
                Packages[id] = aPackage;
            }
            // Automatic become TwoDay Shiping if user does not state which kind of method shipping they want to chose
            else
            {
                TwoDay aPackage = new TwoDay();
                aPackage.RecipientName    = txtBxRecipientName.Text;
                aPackage.RecipientAddress = txtBxRecipientAddress.Text;
                aPackage.RecipientCity    = txtBxRecipientAddress.Text;
                aPackage.RecipientState   = txtBxRecipientState.Text;
                aPackage.RecipientZipCode = txtBxRecipientZipCode.Text;

                aPackage.SenderName    = txtBxSenderName.Text;
                aPackage.SenderAddress = txtBxSenderAddress.Text;
                aPackage.SenderCity    = txtBxSenderCity.Text;
                aPackage.SenderState   = txtBxSenderState.Text;
                aPackage.SenderZipCode = txtBxSenderZipCode.Text;
                // This one is to get the checked shipping company
                for (int i = 0; i <= (chShipCompany.Items.Count - 1); i++)
                {
                    if (chShipCompany.GetItemChecked(i))
                    {
                        aPackage.ShippingCompany = chShipCompany.Items[i].ToString();
                    }
                }
                aPackage.ShippingMethod = "Two Day";
                aPackage.Weight         = Convert.ToDecimal(textBox1.Text);
                ServiceReference1.Service1Client service = new ServiceReference1.Service1Client();
                aPackage.CostPerOunce = service.GetCost(aPackage.ShippingCompany);
                aPackage.Cost         = aPackage.CalculateCost();
                ClearTextBoxes();
                Packages[id] = aPackage;
            }
            listBox1.Items.Clear();
            foreach (var item in Packages)
            {
                listBox1.Items.Add(item);
            }
            Add.Visible     = true;
            button5.Visible = false;
            Delete.Visible  = false;
        }
Esempio n. 3
0
        /// <summary>
        /// Author: Cuong Nguyen
        /// Purpose: Push all data from the form to the object and then add to the Pacckages array
        /// Note:   aPackage.Weight  IS NEEDED TO BE EMPLEMENT
        /// Note: NEED TO DO SOMETHING FOR THE SUBTOTAL AND TAX AND TOTAL
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Add_Click(object sender, EventArgs e)
        {
            #region Scratch for checking all texboxes
            //foreach (TextBox tb in this.Controls.OfType<TextBox>().Where(x => x.CausesValidation == true))
            //{
            //    tb.Validating += TextBox_Validating;
            //}
            ///////////
            //foreach (Control c in this.Controls)
            //{
            //    if (c is TextBox)
            //    {
            //        TextBox textBox = c as TextBox;
            //        if (textBox.Text == string.Empty)
            //        {
            //            // Text box is empty.
            //            // You COULD store information about this textbox is it's tag.
            //        }
            //    }
            //}
            #endregion
            //DataAdapter.Invoices[idxInvoice] = anInvoice;

            //Invoice anInvoice = new Invoice();
            if (txtBxSenderName.Text == "") // Constraint for sender box
            {
                MessageBox.Show("Sender Name CANNOT be empty!");
            }
            else
            {
                if (rbOverNight.Checked == true)
                {
                    OverNight aPackage = new OverNight();
                    aPackage.RecipientName    = txtBxRecipientName.Text;
                    aPackage.RecipientAddress = txtBxRecipientAddress.Text;
                    aPackage.RecipientCity    = txtBxRecipientAddress.Text;
                    aPackage.RecipientState   = txtBxRecipientState.Text;
                    aPackage.RecipientZipCode = txtBxRecipientZipCode.Text;

                    aPackage.SenderName    = txtBxSenderName.Text;
                    aPackage.SenderAddress = txtBxSenderAddress.Text;
                    aPackage.SenderCity    = txtBxSenderCity.Text;
                    aPackage.SenderState   = txtBxSenderState.Text;
                    aPackage.SenderZipCode = txtBxSenderZipCode.Text;
                    // This one is to get the checked shipping company
                    for (int i = 0; i <= (chShipCompany.Items.Count - 1); i++)
                    {
                        if (chShipCompany.GetItemChecked(i))
                        {
                            aPackage.ShippingCompany = chShipCompany.Items[i].ToString();
                        }
                    }
                    aPackage.ShippingMethod = "Over Night";
                    aPackage.Weight         = Convert.ToDecimal(textBox1.Text);
                    ServiceReference1.Service1Client service = new ServiceReference1.Service1Client();
                    aPackage.CostPerOunce = service.GetCost(aPackage.ShippingCompany);
                    aPackage.Cost         = aPackage.CalculateCost();
                    ClearTextBoxes();
                    listBox1.Items.Clear();
                    //listBox1.Items.Add(aPackage);
                    //anInvoice.Packages.Add(aPackage);
                    Packages.Add(aPackage);
                    foreach (var item in Packages)
                    {
                        listBox1.Items.Add(item);
                    }
                    Console.WriteLine(aPackage);
                }
                // Automatic become TwoDay Shiping if user does not state which kind of method shipping they want to chose
                else
                {
                    TwoDay aPackage = new TwoDay();
                    aPackage.RecipientName    = txtBxRecipientName.Text;
                    aPackage.RecipientAddress = txtBxRecipientAddress.Text;
                    aPackage.RecipientCity    = txtBxRecipientAddress.Text;
                    aPackage.RecipientState   = txtBxRecipientState.Text;
                    aPackage.RecipientZipCode = txtBxRecipientZipCode.Text;

                    aPackage.SenderName    = txtBxSenderName.Text;
                    aPackage.SenderAddress = txtBxSenderAddress.Text;
                    aPackage.SenderCity    = txtBxSenderCity.Text;
                    aPackage.SenderState   = txtBxSenderState.Text;
                    aPackage.SenderZipCode = txtBxSenderZipCode.Text;
                    // This one is to get the checked shipping company
                    for (int i = 0; i <= (chShipCompany.Items.Count - 1); i++)
                    {
                        if (chShipCompany.GetItemChecked(i))
                        {
                            aPackage.ShippingCompany = chShipCompany.Items[i].ToString();
                        }
                    }
                    aPackage.ShippingMethod = "Two Day";
                    aPackage.Weight         = Convert.ToDecimal(textBox1.Text);
                    ServiceReference1.Service1Client service = new ServiceReference1.Service1Client();
                    aPackage.CostPerOunce = service.GetCost(aPackage.ShippingCompany);
                    aPackage.Cost         = aPackage.CalculateCost();
                    ClearTextBoxes();
                    listBox1.Items.Clear();
                    //listBox1.Items.Add(aPackage);
                    //anInvoice.Packages.Add(aPackage);
                    Packages.Add(aPackage);
                    foreach (var item in Packages)
                    {
                        listBox1.Items.Add(item);
                    }
                }
            }
        } // END OF ADD METHOD