本文介绍了如何使用asp.net&amp ;;基于数量和价格获得SubTotal C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public void SalePrice()
    {
        double originalPrice, discountPercentage, discountAmount, salePrice;
        con.Open();
        SqlCommand sqlcom = new SqlCommand("USP_SalePriceCalculation", con);
        sqlcom.CommandType = CommandType.StoredProcedure;
        SqlDataAdapter da = new SqlDataAdapter(sqlcom);
        DataTable dt = new DataTable();
        da.Fill(dt);
        if (dt.Rows.Count > 0)
        {
            // Get item's original price.
            originalPrice = double.Parse(dt.Rows[0]["actprice"].ToString());

            // Get discount percentage.
            discountPercentage = double.Parse(dt.Rows[0]["Discount"].ToString());

            // Create decimal representation of %  (move point left two places)
            discountPercentage = discountPercentage / 100;

            // Calculate amount of the discount.
            discountAmount = originalPrice * discountPercentage;

            // Calculate sale price.
            salePrice = originalPrice - discountAmount;

            // Display sale price as Currency ("c")
            lblPrice.Text = salePrice.ToString("c", Cultures.INDIA);
        }
        con.Close();        
    }
    public static class Cultures
    {
        public static readonly CultureInfo INDIA =
            CultureInfo.GetCultureInfo("en-IN");
    }





现在我想根据SalePrice和Quantity(文本框)计算SubTotal

任何人都帮我解释如何计算SubTotal?



Now i want to Calcualate SubTotal Based on that SalePrice and Quantity(textbox)
Any one help me that how to calculate SubTotal?

推荐答案

SalePrice();
var unitPrice =  long.Parse(lblPrice.Text);
var qty = int.Parse(txbQty.Text);

var subTotal = unitPrice * qty;



通过salePrice()你有适用于所有产品的折扣价。所以小计是所有总数的总和。


By salePrice() you have the discounted price that applies to all products. So subtotal is the sum of all totals.


select sum(col) as SubTotal
from tablename
Group by Quantity, Price


这篇关于如何使用asp.net&amp ;;基于数量和价格获得SubTotal C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 19:49