请教一下,我们的这个总薪资 = 产量薪资 + 出成奖励 + 包材奖励,其中,出成奖励 和 包材奖励,这两项都是手填的,填写后,公式根据填写的数值,计算出总薪资,请问这部分的代码应该怎么写呢,相关图片和我这部分的原代码如下,敬请指导;

private void btnquery_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("server=192.168.100.247;database=WHMesInfo;user=sa;password=whyy@2021");
conn.Open();
try
{
// string sqlquery = @"select t1.date,t1.batchNo,t1.probatchNo,t1.proname,t1.spec,t1.teams,t1.process,t1.unit,t1.ulh,t2.instock,t2.sample
// from w_prohourcount t1 join w_k3tran t2 on t1.batchNo = t2.batchNo where isnull(t1.batchNo,'') like '%" + txtbatchNo.Text
// + "%' ";
string sqlquery = @"select t1.date,t1.batchNo,t1.probatchNo,t1.proname,t1.spec,t1.teams,t1.process,t1.unit,t1.ulh,t2.instock,t2.sample,t3.price
from w_prohourcount t1 inner join w_k3tran t2 on t1.batchNo = t2.batchNo inner join w_productprice t3
on t1.proname = t3.proName
and t1.process = t3.process
and t1.teams = t3.teams
and t1.spec = t3.spec
where isnull(t1.batchNo,'') like '%" + txtbatchNo.Text + "%' ";
SqlCommand cmd = new SqlCommand(sqlquery, conn);
SqlDataAdapter sda = new SqlDataAdapter();
sda.TableMappings.Add("table", "w_prohourcount");
sda.TableMappings.Add("table1", "_k3tran");
sda.SelectCommand = cmd;
DataSet ds = new DataSet();
sda.Fill(ds);
DataTable resultTable = ds.Tables[0];
resultTable.Columns.Add("考核数量", typeof(decimal));
resultTable.Columns.Add("产量薪资", typeof(decimal));
resultTable.Columns.Add("出成奖励", typeof(decimal));
resultTable.Columns.Add("包材奖励", typeof(decimal));
resultTable.Columns.Add("总薪资", typeof(decimal));
resultTable.Columns.Add("工日单价", typeof(decimal));
resultTable.Columns.Add("万盒工时", typeof(decimal));
foreach (DataRow row in resultTable.Rows)
{
// 计算考核数量
decimal instock = Convert.ToDecimal(row["instock"]);
decimal sample = Convert.ToDecimal(row["sample"]);
decimal checkNum = instock + sample;
row["考核数量"] = checkNum;
// 计算产量薪资
decimal price = Convert.ToDecimal(row["price"]);
decimal salary = checkNum * price;
row["产量薪资"] = salary;
//将考核数量与产品单价,做序列的调换
decimal temp = (decimal)row["考核数量"];
row["考核数量"] = row["price"];
row["price"] = temp;
}
dataGridView1.DataSource = resultTable;
this.dataGridView1.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
dataGridView1.Columns[0].HeaderText = "日期";
dataGridView1.Columns[1].HeaderText = "批号";
dataGridView1.Columns[2].HeaderText = "产品批号";
dataGridView1.Columns[3].HeaderText = "产品名称";
dataGridView1.Columns[4].HeaderText = "规格";
dataGridView1.Columns[5].HeaderText = "班组";
dataGridView1.Columns[6].HeaderText = "工序";
dataGridView1.Columns[7].HeaderText = "单位";
dataGridView1.Columns[8].HeaderText = "工时";
dataGridView1.Columns[9].HeaderText = "入库数量";
dataGridView1.Columns[10].HeaderText = "取样数量";
dataGridView1.Columns[11].HeaderText = "考核数量";
dataGridView1.Columns[12].HeaderText = "产品单价";
dataGridView1.Columns[13].HeaderText = "产量薪资";
dataGridView1.Columns[14].HeaderText = "出成奖励";
dataGridView1.Columns[15].HeaderText = "包材奖励";
dataGridView1.Columns[16].HeaderText = "总薪资";
dataGridView1.Columns[17].HeaderText = "工日单价";
dataGridView1.Columns[18].HeaderText = "万盒工时";
//DataTable w_protran = resultTable.Copy();
decimal workhourtotal = 0; //给第八列的工时,加上合计总数;
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (row.Cells[8].Value != null && !string.IsNullOrEmpty(row.Cells[11].Value.ToString()))
{
decimal value = decimal.Parse(row.Cells[8].Value.ToString());
workhourtotal += value;
}
}
// 将合计值赋值给最后一行的该列单元格,并在相邻单元格上,加上标识;
dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[8].Value = workhourtotal.ToString();
dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[7].Value = "合计工时";
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally { conn.Close(); }
}