Beispiel #1
0
        /// <summary>
        /// Calculating total after discount 0.1%
        /// </summary>
        private void CalculateTotal()
        {
            const double DiscountPercent = 0.1;
            double       SubTotal;
            double       DiscountAmount;
            double       Total;

            try
            {
                SubTotal       = Convert.ToDouble(subTotalTextBox);
                DiscountAmount = SubTotal * DiscountPercent;
                Total          = SubTotal - DiscountAmount;


                discountAmountTextBox.Text = DiscountAmount.ToString("C2");
                totalTextBox.Text          = Total.ToString("C2");
            }
            catch (Exception exception)
            {
                MessageBox.Show("Invalid Data Entered", "Input Error");
                Debug.WriteLine(exception.Message);
                subTotalTextBox.Focus();
                subTotalTextBox.SelectAll();
                ResetSubTotalMethod();
            }
        }
        /// <summary>
        /// this method does has
        /// no arguments
        /// </summary>

        private void CalculateTotal()
        {
            try
            {
                //read values
                double       SubTotal;
                double       DiscountAmount;
                double       Total;
                const double DiscountPercent = 0.1;
                //convert string to double
                SubTotal = Convert.ToDouble(Sub_Total_TextBox.Text);
                //DiscountAmount=Subtotal*0.1
                DiscountAmount = SubTotal * DiscountPercent;
                //Total= Subtotal-DiscountAmount
                Total = SubTotal - DiscountAmount;
                //Display DiscountAmount in proper Textbox
                DiscountAmount_TextBox.Text = DiscountAmount.ToString("C2");
                //display total in proper Textbox
                Total_TextBox.Text = Total.ToString("C2");
            }
            catch (Exception)
            {
                //throw;
                MessageBox.Show("Please Enter a number", "Input Error");
                ResetSubTotalTextBox();
            }
        }
Beispiel #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            double Subtotal;
            double DiscountPercent;
            double DiscountAmount;
            double InvoiceTotal;

            Subtotal = double.Parse(txtSubtotal.Text);
            if (Subtotal >= 500)
            {
                DiscountPercent = 0.2;
            }
            else if (Subtotal >= 250 && Subtotal < 500)
            {
                DiscountPercent = 0.15;
            }
            else if (Subtotal >= 100 && Subtotal < 250)
            {
                DiscountPercent = 0.1;
            }
            else
            {
                DiscountPercent = 0.0;
            }
            DiscountAmount          = Subtotal * DiscountPercent;
            InvoiceTotal            = Subtotal - DiscountAmount;
            txtDiscountPercent.Text = DiscountPercent.ToString("p1"); //p1 means percentage
            txtDiscountAmount.Text  = "$" + DiscountAmount.ToString();
            txtTotal.Text           = "$" + InvoiceTotal.ToString();
            txtResult.Text          = "Dear Customer you have to pay: $" + InvoiceTotal.ToString();
        }
        /// <summary>
        /// Formatted amount Decimal(15,2) with sign
        /// </summary>
        /// <returns>
        /// Formatted amount
        /// </returns>
        private string FormattedDiscountAmount()
        {
            const string fmt             = "0000000000000.##";
            string       formattedAmount = DiscountAmount.ToString(fmt);

            if (DiscountAmount > 0)
            {
                formattedAmount = "+" + formattedAmount;
            }
            return(formattedAmount);
        }
Beispiel #5
0
        void ToggleDiscountType()
        {
            BunifuElipse DiscountTypeImgElipse = new BunifuElipse {
                ElipseRadius = 5
            };
            Image ColoredImgCashDiscountType = ImageUtil.ColorImage(imgbtnCashDiscountType.Image, SoftColor);
            Image ColoredImgPtgDiscountType  = ImageUtil.ColorImage(imgbtnPtgDiscountType.Image, SoftColor);
            Image ImgCashDiscountType        = ImageUtil.ColorImage(imgbtnCashDiscountType.Image, Color.White);
            Image ImgPtgDiscountType         = ImageUtil.ColorImage(imgbtnPtgDiscountType.Image, Color.White);

            txtDiscountValue.Text = "";

            if (IsCashDiscount)
            {
                //Cash
                lblDiscountType.Text      = StringAmount;
                txtDiscountValue.HintText = (DiscountAmount == 0) ? "00,00" : DiscountAmount.ToString();
                lblUnit.Text          = Currency;
                txtDiscountValue.Text = DiscountAmount.ToString();

                // Change Both Control Color, Image Oppositely
                imgbtnCashDiscountType.BackColor = SoftColor;
                imgbtnCashDiscountType.Image     = ImgCashDiscountType;

                imgbtnPtgDiscountType.BackColor = Color.White;
                imgbtnPtgDiscountType.Image     = ColoredImgPtgDiscountType;

                DiscountTypeImgElipse.TargetControl = imgbtnCashDiscountType;
            }
            else
            {
                // Percentage
                lblDiscountType.Text      = stringPercentage;
                txtDiscountValue.HintText = DiscountPercentage.ToString();
                txtDiscountValue.Text     = DiscountPercentage.ToString();
                lblUnit.Text = "%";

                //Refresh UI  : Change Both Control Color, Image Oppositely
                imgbtnCashDiscountType.BackColor = Color.White;
                imgbtnCashDiscountType.Image     = ColoredImgCashDiscountType;

                imgbtnPtgDiscountType.BackColor = SoftColor;
                imgbtnPtgDiscountType.Image     = ImgPtgDiscountType;

                DiscountTypeImgElipse.TargetControl = imgbtnPtgDiscountType;
            }
            txtDiscountName.Text = DiscountName;
        }
Beispiel #6
0
 public string GetDiscountAmount()
 {
     return(DiscountAmount.ToString("C"));
 }