Example #1
0
        private void button_Click(object sender, EventArgs e)
        {
            if (iniPro) return;

            Button btn = (Button)sender;
            GenericData gd;

            switch (btn.Name)
            {
                case "buttonOpen":
                    fileName = Files.Open("zan.csv", Folder.MyDocuments(), "csv");
                    if (fileName == null)
                    {
                        textBoxMsg.AppendText("× ファイルが指定せれていません。処理続行不可能です。\r\n");
                    }
                    else
                    {
                        textBoxMsg.AppendText("☆ " + fileName + "を基に" + comboBoxOffice.Text + "の出来高システム原価データ(D_CostReport)を作成します。" + Environment.NewLine);
                    }
                    break;
                case "buttonCancel":
                    // Wakamatsu 20170323
                    fileName = null;
                    textBoxMsg.Text = "";
                    break;
                case "buttonStart":
                    if (fileName == null)
                    {
                        // Wakamatsu 20170323
                        textBoxMsg.AppendText("× 取り込むファイルを指定してください。\r\n");
                        return;
                    }

                    gd = new GenericData();
                    int procCount = 0;
                    if (System.IO.Path.GetExtension(fileName) == ".csv" || System.IO.Path.GetExtension(fileName) == ".CSV")
                    {
                        procCount = gd.CreateCostReportDataByCSVData(fileName, Convert.ToString(comboBoxOffice.SelectedValue));
                    }
                    else
                    {
                        procCount = -1;
                        textBoxMsg.AppendText("× " + fileName + "は処理できないファイルです!" + Environment.NewLine);
                    }

                    if (procCount < 0)
                    {
                        textBoxMsg.AppendText("× " + fileName + "の内容登録に失敗しました!" + Environment.NewLine);
                        return;
                    }
                    textBoxMsg.AppendText("〇 " + fileName + "の処理が正常終了しました。" + Environment.NewLine);
                    textBoxMsg.AppendText("〇 " + procCount + "件のデータが原価データに登録されました。" + Environment.NewLine);
                    textBoxMsg.AppendText(Environment.NewLine);

                    break;
                case "buttonDateSet":
                    if (fileName == null) return;
                    gd = new GenericData();
                    int setCount;
                    if (System.IO.Path.GetExtension(fileName) == ".csv" || System.IO.Path.GetExtension(fileName) == ".CSV")
                    {
                        setCount = gd.CountCostReportDataByCSVData(fileName);
                    }
                    else
                    {
                        setCount = -1;
                        textBoxMsg.AppendText("× " + fileName + "は処理できないファイルです!" + Environment.NewLine);
                    }
                    if (setCount < 0)
                    {
                        textBoxMsg.AppendText("× " + fileName + "には登録できる内容がありませんでした!" + Environment.NewLine);
                        return;
                    }
                    textBoxMsg.AppendText("〇 " + fileName + "の確認処理が正常終了しました。\r\n");
                    break;
                case "buttonEnd":
                    this.Close();
                    break;
                default:
                    break;
            }
        }