Answer to Question #29395 in C# for Whitaker

Question #29395
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());
}


}
Sql.Close();



}
0
Expert's answer

Answer in progress...

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS