I need proper syntax to get the price from my inventory table and use it in calculations. Here is the method I have so far but I don't know where to start with the calculation.
public void btnItemEnter_Click(object sender, EventArgs e)
{
/**This event handler will look up the item and get the description
* and the price to display into the lstItemsSold box. It will also
* keep a running total in the total labels while calculatin taxes**/
// double price;
//double tax = 0.07;
//double subtotal = price + tax;
String Item = txtItem.Text;
SqlConnection Sql = new SqlConnection("Data Source=. SAMANTHAWHITAKE\\MYSQL2012; Integrated Security=true");
Sql.Open();
Sql.ChangeDatabase("Inventory");
string ItemNumber = "SELECT ItemNumber * FROM Inventory";
SqlCommand getRecord = new SqlCommand(ItemNumber, Sql);
SqlDataReader invRecord = getRecord.ExecuteReader();
if (Item.Equals(getRecord))
{
string LineItem = "SELECT ItemNumber, ItemName, ItemPrice * FROM Inventory WHERE ItemNumber = '" + Item + "'";
SqlCommand getLine = new SqlCommand(LineItem, Sql);
SqlDataReader invLine = getLine.ExecuteReader();
while (invLine.Read())
{
lstItemsPurchased.Items.Add(invLine.GetValue(0).ToString());
}
Comments
Leave a comment