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(); }
//TOSTRING (with delimitter) public string ToString(string delim) { return(RecordType + delim + VendorCode + delim + LocationCode + delim + PurchaseOrderNo + delim + ((Object)ExpectedDeliveryDate ?? " ") + delim + VendorInvoiceNo + delim + InvoiceDate.ToString("MM'/'dd'/'yyyy") + delim + //11/16/2016 (forces the "/" separator) InvoiceTotal.ToString("0.00") + delim + //format (two decimal places) (TaxGlDescription ?? " ") + delim + ((Object)TaxValue ?? " ") + delim + (FreightShippingGlDescription ?? " ") + delim + ((Object)FreightShippingValue ?? " ") + delim + Misc1GlDescription + delim + Misc1Value.ToString("0.00")); }
//TOSTRING OVERRIDE public override string ToString() { return(RecordType + "\t" + VendorCode + "\t" + LocationCode + "\t" + PurchaseOrderNo + "\t" + ((Object)ExpectedDeliveryDate ?? " ") + "\t" + VendorInvoiceNo + "\t" + InvoiceDate.ToString("MM'/'dd'/'yyyy") + "\t" + //11/16/2016 (forces the "/" separator) InvoiceTotal.ToString("0.00") + "\t" + //format (two decimal places) (TaxGlDescription ?? " ") + "\t" + //(handle NULL value and converting (double? to double) in the correct format) MyDoubleToString(TaxValue) + "\t" + //((Object)TaxValue ?? " ") + "\t" + (FreightShippingGlDescription ?? " ") + "\t" + //(handle NULL value and converting (double? to double) in the correct format) MyDoubleToString(FreightShippingValue) + "\t" + //((Object)FreightShippingValue ?? " ") + "\t" + Misc1GlDescription + "\t" + Misc1Value.ToString("0.00")); }