c# - Need help in BAL Class logic -
In my sales expansion software I want to calculate the TotalCost, discount, Nettolkast. Once recorded rate diplomacy and text box, all values should be filled automatically is my program is capable of showing Kulkast and Netotikl but showing no discount value, it is always just show 0. Here is my code, any person modifies what is wrong in it ....
public class salesTenity {private string custid; Private string custname; Private string product name; Private Ent Quantity; Private float rate; Private Float Total; Personal float discount; Private Names NetTotal; Public string CUSTOMERID {back {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 the return amount; } Set {quantity = value; }} Public float rate (or rate of {return;} Get set {rate = value;}} public float of ({total return};} set {total = value;;}} public float discount {return exempted Do;} set {discount = value;}} public float NETTOTAL {get {return NetTotal;} set {net = value;}}} public class Selsblmanger {public Selsintiti compute (Selsintiti Bikrian) {salesEntity.TOTAL = Bikriankkuntiti * SalesEntity.RAT; SalesEntity.DISCOUNT = (10/100 * Sold) Riviram. Tiotiael); SalesEntity.NETTOTAL = Bikrian. Tiattiel - Bikrividhi. Discount; return Bikrian;}} protected void TxtRate_TextChanged (object sender, EventArgs e) {if (Page.IsPostBack) {SalesBalmanager obj = new SalesBalmanager (); Selsantiti Selentiti = new Selstentiti (); Salesentity.QUANTITY = convert. ToInt32 (TxtQuantity.Text); Salesentity.RATE = convert. ToInt32 (TxtRate.Text); Salesentity.CUSTOMERID = TxtCustId.Text; Salesentity.CUSTOMERNAME = TxtCustName.Text; Vikrykta = Obj.compute; TxtTotal.Text = Sales. Toll Toasting (); TxtDiscount.Text = Sales DISCOUNT.ToString (); TxtNetTotal.Text = Sales NETTOTAL.ToString (); }}
You have at least two problems first, when you have decimal and second If you are using floats, you are using integer arithmetic while dividing 10/100
. When using integer arithmetic, its zero is zero. I change floats to decimal and specify 0.1M
instead of 10/100
. I would like to be more careful with my string formats so that the number of decimal digits in decimals is fixed, like, discount.ToString ("0.00")
.
Comments
Post a Comment