StockCalulate Aleart
图片1:
图片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);
}
答案 0 :(得分:-1)
尝试以下
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);