// 作業項目マスタデータをItemList画面から得る private void chooseItemData(DataGridView dgv) { WorkItemsData wids = FormItemList.ReceiveItems(wid); if (wids == null) { return; } viewItemDataToDgv(dgv.Rows[dgv.CurrentCellAddress.Y], wids); if (wids.Unit != "") { dgv.CurrentCell = dgv.Rows[dgv.CurrentCellAddress.Y].Cells["Quantity"]; } Calculation calc = new Calculation(); if (calc.ExtractCalcWord(Convert.ToString(dgv.Rows[dgv.CurrentCellAddress.Y].Cells["Item"].Value)) != null) { verticalCalc(dgv); } }
// DataGridViewに選択された作業項目マスタデータの内容セット private void viewItemDataToDgv(DataGridViewRow dgvRow, WorkItemsData wids) { Calculation calc = new Calculation(); // データグリッドビューの編集ロック制御 if (wids.Unit == "") { dgvRow.Cells["Quantity"].ReadOnly = true; dgvRow.Cells["Quantity"].Value = null; dgvRow.Cells["Unit"].ReadOnly = true; dgvRow.Cells["Cost0"].ReadOnly = true; dgvRow.Cells["Cost1"].ReadOnly = true; dgvRow.Cells["Cost2"].ReadOnly = true; dgvRow.Cells["Amount0"].Value = null; dgvRow.Cells["Amount1"].Value = null; dgvRow.Cells["Amount2"].Value = null; } else { if (calc.ExtractCalcWord(wids.UItem) == Sign.Expenses) { dgvRow.Cells["Quantity"].ReadOnly = true; dgvRow.Cells["Quantity"].Value = null; dgvRow.Cells["Unit"].ReadOnly = true; dgvRow.Cells["Cost0"].ReadOnly = true; dgvRow.Cells["Cost1"].ReadOnly = true; dgvRow.Cells["Cost2"].ReadOnly = true; } else { dgvRow.Cells["Quantity"].ReadOnly = false; dgvRow.Cells["Unit"].ReadOnly = false; dgvRow.Cells["Cost0"].ReadOnly = false; dgvRow.Cells["Cost1"].ReadOnly = false; dgvRow.Cells["Cost2"].ReadOnly = false; } } if (calc.ExtractCalcWord(wids.UItem) == Sign.Discount) { dgvRow.Cells["Amount0"].ReadOnly = false; dgvRow.Cells["Amount1"].ReadOnly = false; dgvRow.Cells["Amount2"].ReadOnly = false; } else { dgvRow.Cells["Amount0"].ReadOnly = true; dgvRow.Cells["Amount1"].ReadOnly = true; dgvRow.Cells["Amount2"].ReadOnly = true; } dgvRow.Cells["Code"].Value = wids.ItemCode; dgvRow.Cells["Item"].Value = wids.UItem == "" ? wids.Item : wids.UItem; dgvRow.Cells["ItemDetail"].Value = wids.ItemDetail; dgvRow.Cells["Unit"].Value = wids.Unit; string arrayNo = "0"; if (DHandling.IsNumeric(wids.ItemCode)) { if (Convert.ToInt32(wids.ItemCode) > 799) { arrayNo = "2"; } } else { if (wids.ItemCode[0] == 'G') { arrayNo = "2"; } } if (wids.Unit != "") { if (calc.ExtractCalcWord(wids.UItem) != Sign.Expenses) { dgvRow.Cells["Cost" + arrayNo].Value = decFormat(wids.StdCost); } } }
// Cell 内容に変化があった時 private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (iniPro) { return; // 初期化中 } if (grdSet == true) { return; } DataGridView dgv = ( DataGridView )sender; Calculation calc = new Calculation(); switch (e.ColumnIndex) { case 1: // 「コード」列 EstPlanOp epo = new EstPlanOp(); // Code入力時作業項目マスタ読込 WorkItemsData wids = epo.LoadWorkItemsData(wid, Convert.ToString(dgv.Rows[e.RowIndex].Cells["Code"].Value)); if (wids != null) { viewItemDataToDgv(dgv.Rows[e.RowIndex], wids); } dgv.Refresh(); break; case 4: // 「数量」列 if (dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].ReadOnly == false) { editDGVRowCell(dgv.Rows[e.RowIndex], e.ColumnIndex); reCalculateAll(dataGridView1); } break; case 6: // 単価0 case 8: // 単価1 case 10: // 単価2 if (dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].ReadOnly == false) { if (Convert.ToString(dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value) != "") { editDGVRowCell(dgv.Rows[e.RowIndex], e.ColumnIndex); } reCalculateAll(dataGridView1); } break; case 7: if (dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].ReadOnly == false) { reCalculateAll(dataGridView1); } if (Convert.ToString(dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value) != "") { // 直営費金額 AmountReg[0] = Convert.ToString(dgv.Rows[e.RowIndex].Cells["Amount0"].Value); } break; case 9: if (dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].ReadOnly == false) { reCalculateAll(dataGridView1); } if (Convert.ToString(dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value) != "") { // 下請外注費金額 AmountReg[1] = Convert.ToString(dgv.Rows[e.RowIndex].Cells["Amount1"].Value); } break; case 11: if (dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].ReadOnly == false) { reCalculateAll(dataGridView1); } if (Convert.ToString(dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value) != "") { // 資材費金額 AmountReg[2] = Convert.ToString(dgv.Rows[e.RowIndex].Cells["Amount2"].Value); } break; case 12: if (Convert.ToString(dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value) != "") { // 計 AmountReg[3] = Convert.ToString(dgv.Rows[e.RowIndex].Cells["Sum"].Value); } break; default: break; } updateStat = true; }
private void returnValue(DataGridView dgv) { wids = (WorkItemsData)wid[dgv.CurrentCellAddress.Y].Clone(); this.Close(); }