Esempio n. 1
0
        private bool viewEstimateContToDgv(DataTable dt, DataGridView dgv)
        {
            string  wkCode;
            string  arrayNo;
            DataRow dr;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dr     = dt.Rows[i];
                wkCode = Convert.ToString(dr["ItemCode"]);
                dgv.Rows[i].Cells["Code"].Value       = wkCode;
                dgv.Rows[i].Cells["Item"].Value       = Convert.ToString(dr["Item"]);
                dgv.Rows[i].Cells["ItemDetail"].Value = Convert.ToString(dr["ItemDetail"]);
                if (Convert.ToString(dr["Unit"]) != "")
                {
                    dgv.Rows[i].Cells["Quantity"].Value = decPointFormat(Convert.ToDecimal(dr["Quantity"]));
                    dgv.Rows[i].Cells["Unit"].Value     = string.IsNullOrEmpty(Convert.ToString(dr["Unit"]))? null : Convert.ToString(dr["Unit"]);

                    arrayNo = "0";
                    if (!string.IsNullOrEmpty(wkCode))
                    {
                        if (DHandling.IsNumeric(wkCode))
                        {
                            if (Convert.ToInt32(wkCode) > 799)
                            {
                                arrayNo = "2";
                            }
                        }
                        else
                        {
                            if (wkCode[0] == 'G')
                            {
                                arrayNo = "2";
                            }
                        }
                    }

                    dgv.Rows[i].Cells["Cost" + arrayNo].Value = decFormat(Convert.ToDecimal(dr["Cost"]));
                }
            }
            return(true);
        }
Esempio n. 2
0
        // Cellの内容に変化があったとき
        private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (iniPro)
            {
                return;            // 初期化中
            }
            DataGridView dgv = ( DataGridView )sender;

            string WorkString = "";

            switch (e.ColumnIndex)
            {
            case 0:         // 「削除」チェックボックス列
                break;

            case 1:         // 「No.」列
                break;

            case 2:         // 「原価コード」列
                break;

            case 3:         // 「注文番号」列
                break;

            case 4:         // 「原価内容」列
                break;

            case 5:         // 「業務番号」列
                break;

            case 6:         // 「業務名」列
                break;

            case 7:         // 「発注金額」列
                if (Convert.ToString(dgv.Rows[e.RowIndex].Cells["OAmount"].Value) == "")
                {
                    return;
                }
                WorkString = Convert.ToString(dgv.Rows[e.RowIndex].Cells["OAmount"].Value);
                if (!(DHandling.IsDecimal(WorkString)))
                {
                    WorkString = "0";
                }
                dgv.Rows[e.RowIndex].Cells["OAmount"].Value = decFormat(Convert.ToDecimal(WorkString));
                calculateInvolvedItems(dgv.Rows[e.RowIndex]);
                break;

            case 8:         // 「前月累計出来高」列
                if (Convert.ToString(dgv.Rows[e.RowIndex].Cells["SAmount"].Value) == "")
                {
                    return;
                }
                WorkString = Convert.ToString(dgv.Rows[e.RowIndex].Cells["SAmount"].Value);
                if (!(DHandling.IsDecimal(WorkString)))
                {
                    WorkString = "0";
                }
                dgv.Rows[e.RowIndex].Cells["SAmount"].Value = decFormat(Convert.ToDecimal(WorkString));
                break;

            case 9:         // 「今月出来高」列
                if (Convert.ToString(dgv.Rows[e.RowIndex].Cells["Amount"].Value) == "")
                {
                    return;
                }
                WorkString = Convert.ToString(dgv.Rows[e.RowIndex].Cells["Amount"].Value);
                if (!(DHandling.IsDecimal(WorkString)))
                {
                    WorkString = "0";
                }
                dgv.Rows[e.RowIndex].Cells["Amount"].Value = decFormat(Convert.ToDecimal(WorkString));
                calculateInvolvedItems(dgv.Rows[e.RowIndex]);
                updateStat = true;
                break;

            case 10:         // 「発注残額」列
                break;

            case 11:         // 「伝票番号」列
                if (dgv.Rows[e.RowIndex].Cells["SlipNo"].Value == null || Convert.ToString(dgv.Rows[e.RowIndex].Cells["SlipNo"].Value) == "")
                {
                    return;
                }
                WorkString = Convert.ToString(dgv.Rows[e.RowIndex].Cells["SlipNo"].Value);
                if (!(DHandling.IsNumeric(WorkString)))
                {
                    WorkString = "";
                }
                dgv.Rows[e.RowIndex].Cells["SlipNo"].Value = WorkString;
                break;

            default:
                break;
            }
            //updateStat = true;
        }
Esempio n. 3
0
        // 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);
                }
            }
        }
Esempio n. 4
0
        private void textBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (iniPro)
            {
                return;
            }

            TextBox tb = (TextBox)sender;

            if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Tab)
            {
                switch (tb.Name)
                {
                case "textBoxSlipNo":
                    if (textBoxSlipNo.Text == "")
                    {
                        DMessage.ValueErrMsg();
                        return;
                    }

                    if (!DHandling.IsNumeric(textBoxSlipNo.Text))
                    {
                        DMessage.ValueErrMsg();
                        return;
                    }

                    if (curSlipNo == Convert.ToInt32(textBoxSlipNo.Text))
                    {
                        return;
                    }

                    if (!dispCostReportData(Convert.ToInt32(textBoxSlipNo.Text)))
                    {
                        MessageBox.Show("指定された伝票番号のデータはありません");
                        return;
                    }

                    curSlipNo = Convert.ToInt32(textBoxSlipNo.Text);

                    break;

                case "textBoxTaskCode":
                    if (!dispTaskInformation(textBoxTaskCode.Text))
                    {
                        MessageBox.Show("指定された業務番号のデータはありません");
                    }
                    break;

                default:
                    break;
                }
            }

            if ((e.Modifiers & Keys.Control) != Keys.Control)
            {
                return;                                                 // Ctrlキーが押下された時のみ以下処理
            }
            switch (e.KeyCode)
            {
            case Keys.A:
                chooseTaskCodeNameData();
                break;

            default:
                break;
            }
        }