Beispiel #1
0
        private void ExcelExport()
        {
            PublishData pd = new PublishData();

            pd.OfficeName     = Convert.ToString(this.comboBoxOffice.Text);                         // 部門
            pd.Department     = Convert.ToString(this.comboBoxDepartment.Text);                     // 部署
            pd.OrderStartDate = Convert.ToDateTime(this.dateTimePickerFR.Text);                     // 表示期間開始
            pd.OrderEndDate   = Convert.ToDateTime(this.dateTimePickerTO.Text);                     // 表示期間終了
            pd.TaskCode       = Convert.ToString(this.textBoxTaskCode.Text);                        // 業務番号
            pd.TaskName       = Convert.ToString(this.labelTaskName.Text);                          // 業務名
            pd.PartnerName    = Convert.ToString(this.labelPartnerName.Text);                       // 取引先名
            pd.Note           = Convert.ToString(this.labelTerm.Text).Replace("工期:", "");           // 工期

            PrintOut.Publish publ = new PrintOut.Publish(Folder.DefaultExcelTemplate("業務元帳.xlsx"));
            publ.ExcelFile("TaskSummary", pd, this.dataGridView1);
        }
Beispiel #2
0
        private void button_Click(object sender, EventArgs e)
        {
            if (initProc)
            {
                return;
            }

            Button btn = (Button)sender;

            switch (btn.Name)
            {
            case "buttonOpen":
                //fileName = Files.Open( "M_Calendar.xlsx", Folder.MyDocuments(), "xlsx" );
                fileName = Files.Open(BookName, Folder.MyDocuments(), "xlsx");
                if (fileName == null)
                {
                    textBoxMsg.AppendText("× " + fileName + "は不適切なファイルです。処理続行不可能です。\r\n");
                }
                else
                {
                    textBoxMsg.AppendText("☆ " + fileName + "の内容でカレンダマスタを再作成します。\r\n");
                }
                break;

            case "buttonCancel":
                // Wakamatsu 20170323
                fileName        = null;
                textBoxMsg.Text = "";
                break;

            case "buttonStart":
                if (fileName == null)
                {
                    // Wakamatsu 20170323
                    textBoxMsg.AppendText("× 取り込むファイルを指定してください。\r\n");
                    return;
                }

                MasterMaintOp mmo = new MasterMaintOp();
                // Wakamatsu 20170227
                //if (!mmo.MCalendar_Delete())
                //{
                //    textBoxMsg.AppendText("× " + "旧データの削除に失敗しました処理を中断します。\r\n");
                //    return;
                //}
                //mmo = new MasterMaintOp();
                // Wakamatsu 20170227
                int procCount = 0;
                switch (System.IO.Path.GetExtension(fileName))
                {
                case ".xlsx":
                    // Wakamatsu 20170227
                    try
                    {
                        oWBook    = new XLWorkbook(fileName);
                        procCount = mmo.MaintCalendarByExcelData(oWBook.Worksheet(1));

                        // Wakamatsu 20170227
                        if (procCount < 0)
                        {
                            if (procCount == -2)
                            {
                                textBoxMsg.AppendText("× 旧データの削除に失敗しました処理を中断します。\r\n");
                            }

                            textBoxMsg.AppendText("× " + fileName + "を処理できませんでした。\r\n");
                            return;
                        }
                        // Wakamatsu 20170227
                    }
                    // Wakamatsu 20170227
                    catch (Exception ex)
                    {
                        textBoxMsg.AppendText(ex.Message + "\r\n");
                        textBoxMsg.AppendText("× " + fileName + "を処理できませんでした。\r\n");
                        return;
                    }
                    // Wakamatsu 20170227
                    break;

                default:
                    procCount = -1;
                    textBoxMsg.AppendText("× " + fileName + "は処理できないファイルです。\r\n");
                    break;
                }

                if (procCount < 0)
                {
                    return;
                }
                textBoxMsg.AppendText("〇 " + fileName + "を処理しました。\r\n");
                textBoxMsg.AppendText(procCount + "件のデータを登録しました。\r\n");
                break;

            // Wakamatsu
            case "buttonExport":
                textBoxMsg.AppendText("☆ 処理を開始しました。\r\n");
                string SetSQL = "";

                SetSQL += "MDate, DType ";
                SetSQL += "FROM M_Calendar ";
                SetSQL += "ORDER BY MDate";

                SqlHandling sqlh = new SqlHandling();                   // SQL実行クラス
                // レコードを取得する
                DataTable dt = sqlh.SelectFullDescription(SetSQL);
                if (dt == null)
                {
                    textBoxMsg.AppendText("× Excel出力ができませんでした。\r\n");
                    return;
                }

                // フォーマット設定用構造体
                PrintOut.Publish.FormatSet[] FormatSet = new PrintOut.Publish.FormatSet[dt.Columns.Count];
                // フォーマット設定
                FormatSetting(ref FormatSet);

                // Excel出力クラス
                //PrintOut.Publish publ = new PrintOut.Publish( Folder.DefaultExcelTemplate( "M_Calendar.xlsx" ) );
                PrintOut.Publish publ = new PrintOut.Publish(Folder.DefaultExcelTemplate(BookName));
                // Excelファイル出力
                //textBoxMsg.AppendText( publ.ExcelFile( "M_Calendar", dt, FormatSet ) );
                // Wakamatsu 20170301
                //textBoxMsg.AppendText(publ.ExcelFile(SheetName, dt, FormatSet));
                textBoxMsg.AppendText(publ.ExcelFile(masterName, SheetName, dt, FormatSet));
                // Wakamatsu 20170301
                break;

            // Wakamatsu
            case "buttonEnd":
                this.Close();
                break;

            default:
                break;
            }
        }
Beispiel #3
0
        private void button_Click(object sender, EventArgs e)
        {
            if (initProc)
            {
                return;
            }

            Button btn = (Button)sender;

            switch (btn.Name)
            {
            case "buttonOpen":
                // Wakamatsu 20170301
                //fileName = Files.Open("M_Partners.xlsx", Folder.MyDocuments(), "xlsx");
                fileName = Files.Open(BookName, Folder.MyDocuments(), "xlsx");
                // Wakamatsu 20170301
                if (fileName == null)
                {
                    textBoxMsg.AppendText("× " + fileName + "は不適切なファイルです。処理続行不可能です。\r\n");
                }
                else
                {
                    textBoxMsg.AppendText("☆ " + fileName + "の内容で取引先マスタを登録・更新します。\r\n");
                }
                break;

            case "buttonCancel":
                // Wakamatsu 20170323
                fileName        = null;
                textBoxMsg.Text = "";
                break;

            case "buttonStart":
                if (fileName == null)
                {
                    // Wakamatsu 20170323
                    textBoxMsg.AppendText("× 取り込むファイルを指定してください。\r\n");
                    return;
                }

                MasterMaintOp mmo = new MasterMaintOp();

                /*
                 * if (!mmo.AllMPartners_Delete())
                 * {
                 *  labelMsg.Text += "旧データの削除に失敗しました処理を中断します。\r\n";
                 *  return;
                 * }
                 */
                int[] procArray = new int[] { 0, 0 };
                switch (System.IO.Path.GetExtension(fileName))
                {
                case ".xlsx":
                    // Wakamatsu 20170227
                    try
                    {
                        oWBook    = new XLWorkbook(fileName);
                        procArray = mmo.MaintPartnersByExcelData(oWBook.Worksheet(1));

                        // Wakamatsu 20170227
                        if (procArray[0] < 0)
                        {
                            textBoxMsg.AppendText("× " + fileName + "を処理できませんでした。\r\n");
                            return;
                        }
                        // Wakamatsu 20170227
                    }
                    // Wakamatsu 20170227
                    catch (Exception ex)
                    {
                        textBoxMsg.AppendText(ex.Message + "\r\n");
                        textBoxMsg.AppendText("× " + fileName + "を処理できませんでした。\r\n");
                        return;
                    }
                    // Wakamatsu 20170227
                    break;

                default:
                    procArray[0] = -1;
                    textBoxMsg.AppendText("× " + fileName + "は処理できないファイルです。\r\n");
                    break;
                }

                if (procArray[0] < 0)
                {
                    return;
                }
                textBoxMsg.AppendText("〇 " + fileName + "を処理しました。\r\n");
                textBoxMsg.AppendText(procArray[0] + "件のデータを登録しました。\r\n");
                textBoxMsg.AppendText(procArray[1] + "件のデータを更新しました。\r\n");
                break;

            case "buttonEnd":
                this.Close();
                break;

            case "buttonExport":
                textBoxMsg.AppendText("☆ 処理を開始しました。\r\n");
                string SetSQL = "";

                SetSQL += "PartnerCode, PartnerName, PartnerPhonetic, CorporateForm, ";
                SetSQL += "SignPosition, PostCode, Address, TelNo, FaxNo, Capital, ";
                SetSQL += "Representative, Title, CellularNo, EMail, BankName, ";
                SetSQL += "BBranchName, AccountType, AccountNo, ClosingDay, PayDay, ";
                SetSQL += "PayType, PayLT, RelCusto, RelSubco, RelSuppl, RelOther, ";
                SetSQL += "StartDate, AccountCode, ChiefTrans ";
                SetSQL += "FROM M_Partners ";
                SetSQL += "ORDER BY RIGHT('000000' + PartnerCode,6)";

                SqlHandling sqlh = new SqlHandling();                   // SQL実行クラス
                // レコードを取得する
                DataTable dt = sqlh.SelectFullDescription(SetSQL);
                if (dt == null)
                {
                    textBoxMsg.AppendText("× Excel出力ができませんでした。\r\n");
                    return;
                }

                // フォーマット設定用構造体
                PrintOut.Publish.FormatSet[] FormatSet = new PrintOut.Publish.FormatSet[dt.Columns.Count];
                // フォーマット設定
                FormatSetting(ref FormatSet);

                // Excel出力クラス
                // Wakamatsu 20170301
                //PrintOut.Publish publ = new PrintOut.Publish(Folder.DefaultExcelTemplate("M_Partners.xlsx"));
                PrintOut.Publish publ = new PrintOut.Publish(Folder.DefaultExcelTemplate(BookName));
                // Wakamatsu 20170301
                // Excelファイル出力
                // Wakamatsu 20170301
                //textBoxMsg.AppendText(publ.ExcelFile("M_Partners",dt,FormatSet));
                textBoxMsg.AppendText(publ.ExcelFile(masterName, SheetName, dt, FormatSet));
                // Wakamatsu 20170301
                break;

            default:
                break;
            }
        }
Beispiel #4
0
        private void button_Click(object sender, EventArgs e)
        {
            if (initProc)
            {
                return;
            }

            Button btn = ( Button )sender;

            switch (btn.Name)
            {
            case "buttonOpen":
                fileName = Files.Open(bookName, Folder.MyDocuments(), "xlsx");
                if (fileName == null)
                {
                    textBoxMsg.AppendText("× " + fileName + "は不適切なファイルです。処理続行不可能です。\r\n");
                }
                else
                {
                    textBoxMsg.AppendText("☆ " + fileName + "の内容を作業項目マスタに書き込みます。\r\n");
                }
                break;

            case "buttonCancel":
                textBoxMsg.Text = "";
                break;

            case "buttonStart":
                if (fileName == null)
                {
                    return;
                }

                MasterMaintOp mmo = new MasterMaintOp();
                if (!mmo.MWorkItems_Delete(hp.MemberCode))
                {
                    textBoxMsg.AppendText("× 旧データの削除に失敗しました処理を中断します。\r\n");
                    return;
                }
                mmo = new MasterMaintOp();
                int procCount = 0;
                switch (System.IO.Path.GetExtension(fileName))
                {
                case ".csv":
                    procCount = mmo.MaintWorkItemsByCSVData(fileName, hp.MemberCode);
                    break;

                case ".xlsx":
                    oWBook    = new XLWorkbook(fileName);
                    procCount = mmo.MaintWorkItemsByExcelData(oWBook.Worksheet(1), hp.MemberCode);
                    break;

                default:
                    procCount = -1;
                    textBoxMsg.AppendText("× " + fileName + "は処理できないファイルです。\r\n");
                    break;
                }

                if (procCount < 0)
                {
                    return;
                }
                textBoxMsg.AppendText("〇 " + fileName + "を処理しました。\r\n");
                textBoxMsg.AppendText(procCount + "件のデータを登録しました。\r\n");
                break;

            case "buttonExport":
                textBoxMsg.AppendText("☆ 処理を開始しました。\r\n");
                //string SetSQL = "ItemCode, UItem, Item, ItemDetail, Unit, StdCost, MemberCode, UpdateDate"
                //                + " FROM M_WorkItems WHERE MemberCode = '" + hp.MemberCode + "'";
                string SetSQL = "ItemCode, UItem, Item, ItemDetail, Unit, StdCost, MemberCode, UpdateDate"
                                + " FROM M_WorkItems WHERE MemberCode = ";

                SqlHandling sqlh = new SqlHandling();                   // SQL実行クラス
                // レコードを取得する
                DataTable dt = sqlh.SelectFullDescription(SetSQL + "'" + hp.MemberCode + "'");
                if (dt == null)
                {
                    dt = sqlh.SelectFullDescription(SetSQL + "'000'");
                    if (dt == null)
                    {
                        textBoxMsg.AppendText("× Excel出力ができませんでした。\r\n");
                        return;
                    }
                    else
                    {
                        textBoxMsg.AppendText("△ " + hp.MemberName + "様の作業項目マスタが未登録のため、共用の作業項目マスタをExcel出力します。\r\n");
                    }
                }

                // フォーマット設定用構造体
                PrintOut.Publish.FormatSet[] FormatSet = new PrintOut.Publish.FormatSet[dt.Columns.Count];
                // フォーマット設定
                FormatSetting(ref FormatSet);

                // Excel出力クラス
                PrintOut.Publish publ = new PrintOut.Publish(Folder.DefaultExcelTemplate(bookName));
                // Excelファイル出力
                textBoxMsg.AppendText(publ.ExcelFile(masterName, sheetName, dt, FormatSet));
                break;

            case "buttonEnd":
                this.Close();
                break;

            default:
                break;
            }
        }
Beispiel #5
0
        private void button_Click(object sender, EventArgs e)
        {
            if (initProc)
            {
                return;
            }

            Button btn = (Button)sender;

            switch (btn.Name)
            {
            case "buttonOpen":
                // Wakamatsu 20170301
                //fileName = Files.Open("M_Members.xlsx",Folder.MyDocuments(),"xlsx");
                fileName = Files.Open(BookName, Folder.MyDocuments(), "xlsx");
                // Wakamatsu 20170301
                if (fileName == null)
                {
                    textBoxMsg.AppendText("× " + fileName + "は不適切なファイルです。処理続行不可能です。\r\n");
                }
                else
                {
                    textBoxMsg.AppendText("☆ " + fileName + "の内容で社員マスタを登録・更新します。\r\n");
                }
                break;

            case "buttonCancel":
                // Wakamatsu 20170323
                fileName        = null;
                textBoxMsg.Text = "";
                break;

            case "buttonStart":
                if (fileName == null)
                {
                    // Wakamatsu 20170323
                    textBoxMsg.AppendText("× 取り込むファイルを指定してください。\r\n");
                    return;
                }

                MasterMaintOp mmo       = new MasterMaintOp();
                int[]         procArray = new int[] { 0, 0 };
                switch (System.IO.Path.GetExtension(fileName))
                {
                case ".xlsx":
                    // Wakamatsu 20170227
                    try
                    {
                        oWBook    = new XLWorkbook(fileName);
                        procArray = mmo.MaintMembersByExcelData(oWBook.Worksheet(1));

                        // Wakamatsu 20170227
                        if (procArray[0] < 0)
                        {
                            textBoxMsg.AppendText("× " + fileName + "を処理できませんでした。\r\n");
                            return;
                        }
                        // Wakamatsu 20170227
                    }
                    // Wakamatsu 20170227
                    catch (Exception ex)
                    {
                        textBoxMsg.AppendText(ex.Message + "\r\n");
                        textBoxMsg.AppendText("× " + fileName + "を処理できませんでした。\r\n");
                        return;
                    }
                    // Wakamatsu 20170227
                    break;

                default:
                    procArray[0] = -1;
                    textBoxMsg.AppendText("× " + fileName + "は処理できないファイルです。\r\n");
                    break;
                }

                if (procArray[0] < 0)
                {
                    return;
                }
                textBoxMsg.AppendText("〇 " + fileName + "を処理しました。\r\n");
                textBoxMsg.AppendText(procArray[0] + "件のデータを登録しました。\r\n");
                textBoxMsg.AppendText(procArray[1] + "件のデータを更新しました。\r\n");
                break;

            case "buttonExport":
                textBoxMsg.AppendText("☆ 処理を開始しました。\r\n");
                string SetSQL = "";

                SetSQL += "MemberCode, Name, Phonetic, OfficeCode + Department, ";
                SetSQL += "BirthDate, PostCode, Address, PostCode2, Address2, TelNo, ";
                SetSQL += "CellularNo, CellularNo2, EMail, MobileEMail, BloodType, ";
                SetSQL += "JoinDate, FinalEducation, GradDate, BasicPNo, HealthInsNo, ";
                SetSQL += "EmploymentInsNo, GainQDate, BankName, BBranchName, AccountType, ";
                SetSQL += "AccountNo, EContact, RadiationMedical, MedicalCheckup, ";
                SetSQL += "FormWage, MemberType, AccessLevel, Enrollment, Note ";
                SetSQL += "FROM M_Members ";
                SetSQL += "ORDER BY RIGHT('0000' + MemberCode,4)";

                SqlHandling sqlh = new SqlHandling();                   // SQL実行クラス
                // レコードを取得する
                DataTable dt = sqlh.SelectFullDescription(SetSQL);
                if (dt == null)
                {
                    textBoxMsg.AppendText("× Excel出力ができませんでした。\r\n");
                    return;
                }

                // フォーマット設定用構造体
                PrintOut.Publish.FormatSet[] FormatSet = new PrintOut.Publish.FormatSet[dt.Columns.Count];
                // フォーマット設定
                FormatSetting(ref FormatSet);

                // Excel出力クラス
                // Wakamatsu 20170301
                //PrintOut.Publish publ = new PrintOut.Publish(Folder.DefaultExcelTemplate("M_Members.xlsx"));
                PrintOut.Publish publ = new PrintOut.Publish(Folder.DefaultExcelTemplate(BookName));
                // Wakamatsu 20170301
                // Excelファイル出力
                // Wakamatsu 20170301
                //textBoxMsg.AppendText(publ.ExcelFile("M_Members",dt,FormatSet));
                textBoxMsg.AppendText(publ.ExcelFile(masterName, SheetName, dt, FormatSet));
                // Wakamatsu 20170301
                break;

            case "buttonEnd":
                this.Close();
                break;

            default:
                break;
            }
        }
Beispiel #6
0
        private void button_Click(object sender, EventArgs e)
        {
            if (initProc)
            {
                return;
            }

            Button btn = (Button)sender;

            switch (btn.Name)
            {
            case "buttonOpen":
                // Wakamatsu 20170301
                //fileName = Files.Open("M_Cost.xlsx", Folder.MyDocuments(), "xlsx");
                fileName = Files.Open(BookName, Folder.MyDocuments(), "xlsx");
                // Wakamatsu 20170301
                if (fileName == null)
                {
                    textBoxMsg.AppendText("× " + fileName + "は不適切なファイルです。処理続行不可能です。\r\n");
                }
                else
                {
                    textBoxMsg.AppendText("☆ " + fileName + "の内容を原価情報マスタに書き込みます。\r\n");
                }
                break;

            case "buttonCancel":
                // Wakamatsu 20170323
                fileName        = null;
                textBoxMsg.Text = "";
                break;

            case "buttonStart":
                if (fileName == null)
                {
                    // Wakamatsu 20170323
                    textBoxMsg.AppendText("× 取り込むファイルを指定してください。\r\n");
                    return;
                }

                MasterMaintOp mmo = new MasterMaintOp();

                /*
                 * if (!mmo.AllMCost_Delete())
                 * {
                 *  labelMsg.Text += "旧データの削除に失敗しました処理を中断します。\r\n";
                 *  return;
                 * }
                 * mmo = new MasterMaintOp();
                 */
                int[] procCount = new int[] { 0, 0 };
                switch (System.IO.Path.GetExtension(fileName))
                {
                //case ".csv":
                //procCount = mmo.MaintCostByCSVData(fileName);
                //break;
                case ".xlsx":
                    // Wakamatsu 20170227
                    try
                    {
                        oWBook    = new XLWorkbook(fileName);
                        procCount = mmo.MaintCostByExcelData(oWBook.Worksheet(1));

                        // Wakamatsu 20170227
                        if (procCount[0] < 0)
                        {
                            textBoxMsg.AppendText("× " + fileName + "を処理できませんでした。\r\n");
                            return;
                        }
                        // Wakamatsu 20170227
                    }
                    // Wakamatsu 20170227
                    catch (Exception ex)
                    {
                        textBoxMsg.AppendText(ex.Message + "\r\n");
                        textBoxMsg.AppendText("× " + fileName + "を処理できませんでした。\r\n");
                        return;
                    }
                    // Wakamatsu 20170227
                    break;

                default:
                    textBoxMsg.AppendText("× " + fileName + "は処理できないファイルです。\r\n");
                    break;
                }

                if (procCount[0] < 0)
                {
                    return;
                }
                textBoxMsg.AppendText("〇 " + fileName + "を処理しました。\r\n");
                textBoxMsg.AppendText(procCount[0] + "件のデータを登録しました。\r\n");
                textBoxMsg.AppendText(procCount[1] + "件のデータを更新しました。\r\n");
                break;

            // Wakamatsu
            case "buttonExport":
                textBoxMsg.AppendText("☆ 処理を開始しました。\r\n");
                string SetSQL = "";

                // Wakamatsu 20170303
                SqlHandling sqlh = new SqlHandling();                   // SQL実行クラス

                SetSQL += "OfficeCode, OfficeName ";
                SetSQL += "FROM M_Office ";
                SetSQL += "ORDER BY OfficeID";

                DataTable dt = sqlh.SelectFullDescription(SetSQL);
                if (dt == null)
                {
                    textBoxMsg.AppendText("× Excel出力ができませんでした。\r\n");
                    return;
                }

                PrintOut.Publish.FormatSet[] FormatSet = null;                  // フォーマット設定用構造体
                PrintOut.Publish             publ      = null;                  // Excel出力クラス

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    SetSQL  = "";
                    SetSQL += "CostCode, Item, ItemDetail, Unit, Cost, ";
                    SetSQL += "OfficeCode, MemberCode ";
                    SetSQL += "FROM M_Cost ";
                    SetSQL += "WHERE OfficeCode = '" + Convert.ToString(dt.Rows[i][0]) + "' ";
                    SetSQL += "ORDER BY CostCode";

                    DataTable dt1 = sqlh.SelectFullDescription(SetSQL);
                    if (dt1 != null)
                    {
                        FormatSet = new PrintOut.Publish.FormatSet[dt1.Columns.Count];
                        // フォーマット設定
                        FormatSetting(ref FormatSet);

                        publ = new PrintOut.Publish(Folder.DefaultExcelTemplate(BookName));
                        // Excelファイル出力
                        textBoxMsg.AppendText(publ.ExcelFile(masterName + "(" + Convert.ToString(dt.Rows[i][1]) + ")", SheetName, dt1, FormatSet));
                    }
                }
                //SetSQL += "CST.CostCode, CST.Item, CST.ItemDetail, CST.Unit, CST.Cost, ";
                //SetSQL += "CST.OfficeCode, CST.MemberCode ";
                //SetSQL += "FROM M_Cost AS CST ";
                //SetSQL += "LEFT JOIN M_Office AS OFC ";
                //SetSQL += "ON CST.OfficeCode = OFC.OfficeCode ";
                //SetSQL += "ORDER BY OFC.OfficeID, CST.CostCode";

                //SqlHandling sqlh = new SqlHandling();               // SQL実行クラス
                //// レコードを取得する
                //DataTable dt = sqlh.SelectFullDescription(SetSQL);
                //if (dt == null)
                //{
                //    textBoxMsg.AppendText("× Excel出力ができませんでした。\r\n");
                //    return;
                //}

                //// フォーマット設定用構造体
                //PrintOut.Publish.FormatSet[] FormatSet = new PrintOut.Publish.FormatSet[dt.Columns.Count];
                //// フォーマット設定
                //FormatSetting(ref FormatSet);

                //// Excel出力クラス
                //// Wakamatsu 20170301
                ////PrintOut.Publish publ = new PrintOut.Publish(Folder.DefaultExcelTemplate("M_Cost.xlsx"));
                //PrintOut.Publish publ = new PrintOut.Publish(Folder.DefaultExcelTemplate(BookName));
                //// Wakamatsu 20170301
                //// Excelファイル出力
                //// Wakamatsu 20170301
                ////textBoxMsg.AppendText(publ.ExcelFile("M_Cost", dt, FormatSet));
                //textBoxMsg.AppendText(publ.ExcelFile(masterName, SheetName, dt, FormatSet));
                //// Wakamatsu 20170301
                // Wakamatsu 20170303
                break;

            // Wakamatsu
            case "buttonEnd":
                this.Close();
                break;

            default:
                break;
            }
        }
Beispiel #7
0
        private void button_Click(object sender, EventArgs e)
        {
            if (initProc)
            {
                return;
            }

            Button btn = (Button)sender;

            switch (btn.Name)
            {
            case "buttonOpen":
                // Wakamatsu 20170301
                //fileName = Files.Open("M_Office.xlsx", Folder.MyDocuments(), "xlsx");
                fileName = Files.Open(BookName, Folder.MyDocuments(), "xlsx");
                // Wakamatsu 20170301
                if (fileName == null)
                {
                    textBoxMsg.AppendText("× " + fileName + "は不適切なファイルです。処理続行不可能です。\r\n");
                }
                else
                {
                    textBoxMsg.AppendText("☆ " + fileName + "の内容で事業所マスタを登録・更新します。\r\n");
                }
                break;

            case "buttonCancel":
                // Wakamatsu 20170323
                fileName        = null;
                textBoxMsg.Text = "";
                break;

            case "buttonStart":
                if (fileName == null)
                {
                    // Wakamatsu 20170323
                    textBoxMsg.AppendText("× 取り込むファイルを指定してください。\r\n");
                    return;
                }

                MasterMaintOp mmo       = new MasterMaintOp();
                int[]         procArray = new int[] { 0, 0 };
                switch (System.IO.Path.GetExtension(fileName))
                {
                case ".xlsx":
                    // Wakamatsu 20170227
                    try
                    {
                        oWBook    = new XLWorkbook(fileName);
                        procArray = mmo.MaintOfficeByExcelData(oWBook.Worksheet(1));

                        // Wakamatsu 20170227
                        if (procArray[0] < 0)
                        {
                            textBoxMsg.AppendText("× " + fileName + "を処理できませんでした。\r\n");
                            return;
                        }
                        // Wakamatsu 20170227
                    }
                    // Wakamatsu 20170227
                    catch (Exception ex)
                    {
                        textBoxMsg.AppendText(ex.Message + "\r\n");
                        textBoxMsg.AppendText("× " + fileName + "を処理できませんでした。\r\n");
                        return;
                    }
                    // Wakamatsu 20170227
                    break;

                default:
                    procArray[0] = -1;
                    textBoxMsg.AppendText("× " + fileName + "は処理できないファイルです。\r\n");
                    break;
                }

                if (procArray[0] < 0)
                {
                    return;
                }
                textBoxMsg.AppendText("〇 " + fileName + "を処理しました。\r\n");
                textBoxMsg.AppendText(procArray[0] + "件のデータを登録しました。\r\n");
                textBoxMsg.AppendText(procArray[1] + "件のデータを更新しました。\r\n");
                break;

            case "buttonEnd":
                this.Close();
                break;

            case "buttonExport":
                textBoxMsg.AppendText("☆ 処理を開始しました。\r\n");
                string SetSQL = "";

                SetSQL += "OfficeCode, OfficeName, MemberCode, MemberName, ";
                SetSQL += "Title, PostCode, Address, TelNo, FaxNo, OrderSeqNo, ";
                SetSQL += "OrderLastNo, PurchaseSeqNo ";
                SetSQL += "FROM M_Office ";
                SetSQL += "ORDER BY OfficeID";

                SqlHandling sqlh = new SqlHandling();                   // SQL実行クラス
                // レコードを取得する
                DataTable dt = sqlh.SelectFullDescription(SetSQL);
                if (dt == null)
                {
                    textBoxMsg.AppendText("× Excel出力ができませんでした。\r\n");
                    return;
                }

                // フォーマット設定用構造体
                PrintOut.Publish.FormatSet[] FormatSet = new PrintOut.Publish.FormatSet[dt.Columns.Count];
                // フォーマット設定
                FormatSetting(ref FormatSet);

                // Excel出力クラス
                // Wakamatsu 20170301
                //PrintOut.Publish publ = new PrintOut.Publish(Folder.DefaultExcelTemplate("M_Office.xlsx"));
                PrintOut.Publish publ = new PrintOut.Publish(Folder.DefaultExcelTemplate(BookName));
                // Wakamatsu 20170301
                // Excelファイル出力
                // Wakamatsu 20170301
                //textBoxMsg.AppendText(publ.ExcelFile("M_Office", dt, FormatSet));
                textBoxMsg.AppendText(publ.ExcelFile(masterName, SheetName, dt, FormatSet));
                // Wakamatsu 20170301
                break;

            default:
                break;
            }
        }