В моем программном обеспечении для продаж я хочу рассчитать TotalCost, Discount, NettotalCost. После ввода Quanity и rate из текстового поля все значения должны быть заполнены автоматически. В моей программе он может показывать TotalCost и NetTotal, но не показывает значение скидки, всегда показывает только 0. Вот мой код, пожалуйста, кто-нибудь изменить его, что здесь не так ...
public class SalesEntity
{
private string custid;
private string custname;
private string productname;
private int quantity;
private float rate;
private float total;
private float discount;
private float NetTotal;
public string CUSTOMERID
{
get
{
return custid;
}
set
{
custid = value;
}
}
public string CUSTOMERNAME
{
get
{
return custname;
}
set
{
custname = value;
}
}
public string PRODUCTNAME
{
get
{
return productname;
}
set
{
productname = value;
}
}
public int QUANTITY
{
get
{
return quantity;
}
set
{
quantity = value;
}
}
public float RATE
{
get
{
return rate;
}
set
{
rate = value;
}
}
public float TOTAL
{
get
{
return total;
}
set
{
total = value; ;
}
}
public float DISCOUNT
{
get
{
return discount;
}
set
{
discount = value;
}
}
public float NETTOTAL
{
get
{
return NetTotal;
}
set
{
NetTotal = value;
}
}
}
public class SalesBALManager
{
public SalesEntity Compute(SalesEntity salesEntity)
{
salesEntity.TOTAL = salesEntity.QUANTITY * salesEntity.RATE;
salesEntity.DISCOUNT = (10 / 100 * salesEntity.TOTAL);
salesEntity.NETTOTAL = salesEntity.TOTAL - salesEntity.DISCOUNT;
return salesEntity;
}
}
protected void TxtRate_TextChanged(object sender, EventArgs e)
{
if (Page.IsPostBack)
{
SalesBALManager obj = new SalesBALManager();
SalesEntity salesentity = new SalesEntity();
salesentity.QUANTITY = Convert.ToInt32(TxtQuantity.Text);
salesentity.RATE = Convert.ToInt32(TxtRate.Text);
salesentity.CUSTOMERID = TxtCustId.Text;
salesentity.CUSTOMERNAME = TxtCustName.Text;
salesentity = obj.Compute(salesentity);
TxtTotal.Text = salesentity.TOTAL.ToString();
TxtDiscount.Text = salesentity.DISCOUNT.ToString();
TxtNetTotal.Text = salesentity.NETTOTAL.ToString();
}
}