Hello,
I have a really stupid problem, which I dont know how to solve. Been working for a while with desktop application, but I havent had situation like this (this program needs some basic math operations).
So here is the problem.
I have a dropdown list and when user select the manufacturer and its product, the price shows in two textboxes (first price as a manufacturer price and second price with VAT).
Next thing I need to do is when I add in other textbox some value (discount for some buyers etc), I want to show below all calculation.
The main problem is that I cannot make any calculation!
Im having an class object and situation for example like this doesnt work.
dboProducts product=new dboProducts();
txtPrice1.Text=(product.PriceVAT * product.PriceWithoutVAT).toString();
If its not too confusing for you guys, I would really appreciate your help.
Ok, so I`m using the query to find selected product by his id:
public static dboProducts getProduct(int id)
{
var query = (from x in dc.dboProducts
where x.ProductID == id
select x).SingleOrDefault();
return query;
}
On event selectedIndexChanged, I`m doing this:
if (cbox_product.SelectedValue is int)
{
int id = Convert.ToInt32(cbox_product.SelectedValue);
dboProducts product = ProductController.getProduct(id);
if (product != null)
{
lbl_group.Text =product.Group.Name;
txtPrice=product.Price.ToString();
txtPriceVAT=product.PriceVAT.ToString();
}
}
This above works well, but when I`m try to do some calculation, like this:
txt_NewPrice.Text = (product.Price - ((product.Price * Convert.ToDouble(txt_NewData.Text)) / 100)).ToString();
In textbox txt_NewPrice nothing shows :/
If I write for example:
txt_NewPrice.Text=(product.Price * 123).toString() // or any number, it works.
But with two instances of class, no.