在我的銷售詳細軟件中,我想計算TotalCost,Discount,NettotalCost。一旦從文本框輸入質量和比率,所有值都應該自動填充。在我的程序中,它能夠顯示TotalCost和NetTotal,但沒有顯示折扣價值,它總是隻顯示0。這裏是我的代碼,請人修改它有什麼錯在這裏....在BAL類邏輯中需要幫助
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();
}
}
嗨先生tvanfosson,謝謝你的回覆現在工作正常... – sumit 2010-02-02 12:47:50