我開發推定的應用程序和我有硬的時刻寫入的公式得到所需結果如下:如下所示如何將datagridview單元格格式化爲%或將公式寫入正確?
Quantity/Production * Non productive % = Labor Hours
上述公式應該被數學回答:
1000 SF/300 SF per hour * @10% Non Productive= 3.6 Labor hours
我的問題是如何編寫一個公式來正確計算人工小時數?
謝謝
這是我的代碼:
private void dgv1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
double cell2 = Convert.ToSingle(dgv1.CurrentRow.Cells[2].Value);
double cell4 = Convert.ToSingle(dgv1.CurrentRow.Cells[4].Value);
double cell5 = Convert.ToSingle(dgv1.CurrentRow.Cells[5].Value);
double cell6 = Convert.ToSingle(dgv1.CurrentRow.Cells[6].Value);
double cell7 = Convert.ToSingle(dgv1.CurrentRow.Cells[7].Value);
double cell8 = Convert.ToSingle(dgv1.CurrentRow.Cells[8].Value);
double cell9 = Convert.ToSingle(dgv1.CurrentRow.Cells[9].Value);
double cell10 = Convert.ToSingle(dgv1.CurrentRow.Cells[10].Value);
double cell11 = Convert.ToSingle(dgv1.CurrentRow.Cells[11].Value);
double cell12 = Convert.ToSingle(dgv1.CurrentRow.Cells[12].Value);
double cell13 = Convert.ToSingle(dgv1.CurrentRow.Cells[13].Value);
double cell14 = Convert.ToSingle(dgv1.CurrentRow.Cells[14].Value);
double cell15 = Convert.ToSingle(dgv1.CurrentRow.Cells[15].Value);
double cell16 = Convert.ToSingle(dgv1.CurrentRow.Cells[16].Value);
double cell17 = Convert.ToSingle(dgv1.CurrentRow.Cells[17].Value);
if (2.ToString() != "" && cell4.ToString() != "" && cell5.ToString() != "" && cell6.ToString() != "" && cell7.ToString() != "" && cell8.ToString() != "" && cell9.ToString() != "" && cell10.ToString() != "" && cell11.ToString() != "" && cell12.ToString() != "" && cell13.ToString() != "" && cell14.ToString() != "" && cell15.ToString() != "" && cell16.ToString() != "" && cell17.ToString() != "")
{
dgv1.CurrentRow.Cells[6].Value = cell2/cell4 * cell5; // <------ This is the formula I'm talking about//
dgv1.CurrentRow.Cells[10].Value = cell6 * cell7 *cell8 *cell9;
dgv1.CurrentRow.Cells[13].Value = cell2/cell11;
dgv1.CurrentRow.Cells[17].Value = cell13 * cell14 * cell15 * cell16;
}
}
,你在哪裏讀作Quantity','Production'並在代碼'非productive',以及如何計算'非productive'百分比是多少?我的意思是它應該分成什麼?總時數?如果是的話,你在哪裏閱讀? – mrz