StockCalulate Aleart
Picture 1:
Picture 2:
CODE:
try {
con = new SqlConnection(cs.DBConn);
con.Open();
string cb = "Update OrderDetailNum set ImportPrice = (@d1 /100) * (select StockCalulate=((StockCalulate/Sum(StockCalulate))*100) from OrderDetailNum Where StockID='" + lblStockID.Text + "' AND Orderid='" + comboOrder.Text + "' group by StockCalulate) Where StockID='" + lblStockID.Text + "' AND Orderid='" + comboOrder.Text + "'";
cmd = new SqlCommand(cb);
cmd.Connection = con;
cmd.Parameters.AddWithValue("@d1", Convert.ToDecimal(lblPr.Text.ToString()));
cmd.ExecuteReader();
con.Close();
MessageBox.Show("Successfully updated", "Record", MessageBoxButtons.OK, MessageBoxIcon.Information);
dataGridView1.DataSource = GetData();
ClearAllText(this);
} catch (Exception ex) {
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Try following
string cb = string.Format("Update OrderDetailNum set ImportPrice = (@d1 /100) * (select StockCalulate=((StockCalulate/Sum(StockCalulate))*100))" +
" from OrderDetailNum" +
" Where StockID='{0}' AND Orderid='{1}'",
lblStockID.Text, comboOrder.Text);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.