Example #1
0
        protected override ResultStatus Export()
        {
            if (txtStartDate.DateTimeValue > txtEndDate.DateTimeValue)
            {
                MessageDisplay.Error("起始日期不得大於結束日期!");
                return(ResultStatus.Fail);
            }

            ExportShow.Text = "轉檔中...";
            ExportShow.Show();

            try
            {
                base.Export();

                string excelDestinationPath = PbFunc.wf_copy_file(_ProgramID, _ProgramID); //CopyExcelTemplateFile(_ProgramID, FileType.XLS);

                return(ManipulateExcel(excelDestinationPath));
            }
            catch (Exception ex)
            {
                ExportShow.Text = "轉檔失敗";
                WriteLog(ex);
                return(ResultStatus.Fail);
            }
        }
Example #2
0
        protected override ResultStatus Export()
        {
            if (!StartExport())
            {
                return(ResultStatus.Fail);
            }
            string msg;
            string saveFilePath = PbFunc.wf_copy_file(_ProgramID, "30580");

            try {
                b30580 = new B30580(saveFilePath, emMonth.Text);
                ShowMsg("30581-國內股票期貨及黃金期貨交易概況表 轉檔中...");
                msg = b30580.Wf30581();
                OutputShowMessage = msg;
            }
            catch (Exception ex) {
                WriteLog(ex);
                return(ResultStatus.Fail);
            }
            finally {
                EndExport();
            }

            if (msg != MessageDisplay.MSG_OK)
            {
                File.Delete(saveFilePath);
                return(ResultStatus.Fail);
            }
            return(ResultStatus.Success);
        }
Example #3
0
      protected override ResultStatus Export() {

         string saveFilePath = PbFunc.wf_copy_file(_ProgramID , _ProgramID);
         try {
            if (!StartExport()) {
               return ResultStatus.Fail;
            }
            b40042 = new B40042(saveFilePath , DateLabel.Text , GlobalInfo.USER_ID);
            MessageDisplay message = new MessageDisplay();

            ShowMsg($"{_ProgramID}_mg1-股票期貨保證金狀況表-標的證券為受益憑證 轉檔中...");
            message.OutputShowMessage = b40042.Wf40042();
            ShowMsg($"{_ProgramID}_40011_1-保證金狀況表 轉檔中...");
            message.OutputShowMessage = b40042.Wf40011Fut();
            ShowMsg($"{_ProgramID}_40011_2-保證金狀況表 轉檔中...");
            message.OutputShowMessage = b40042.Wf40011Opt();
            ShowMsg($"{_ProgramID}_40012_1-保證金狀況表 轉檔中...");
            message.OutputShowMessage = b40042.Wf40012Fut();
            ShowMsg($"{_ProgramID}_40012_2-保證金狀況表 轉檔中...");
            message.OutputShowMessage = b40042.Wf40012Opt();
            ShowMsg($"{_ProgramID}_40013_1-保證金狀況表 轉檔中...");
            message.OutputShowMessage = b40042.Wf40013Fut();
         } catch (Exception ex) {
            if (File.Exists(saveFilePath))
               File.Delete(saveFilePath);
            WriteLog(ex);
            return ResultStatus.Fail;
         } finally {
            EndExport();
         }

         return ResultStatus.Success;
      }
Example #4
0
        protected override ResultStatus Export()
        {
            try {
                this.Cursor = Cursors.WaitCursor;
                this.Refresh();
                Thread.Sleep(5);
                lblProcessing.Visible = true;
                ShowMsg("開始轉檔...");
                dao30100 = new D30100();

                string   rptId, file, rptName;
                DateTime sYmd = txtSDate.DateTimeValue;
                DateTime eYmd = txtEDate.DateTimeValue;
                int      rowNum;
                rptId   = "30100";
                rptName = "Kill Switch使用紀錄查詢";
                ShowMsg(rptId + "-" + rptName + " 轉檔中...");

                //讀取資料
                DataTable dt30100 = dao30100.d_30100(sYmd, eYmd,
                                                     dwFcmKs.EditValue.AsString() + "%", dwFcmIn.EditValue.AsString() + "%",
                                                     rdgMarketCode.EditValue.AsString());
                if (dt30100.Rows.Count == 0)
                {
                    MessageDisplay.Info(txtSDate.Text + "~" + txtEDate.Text + "," + rptId + '-' + rptName + ",無任何資料!");
                    lblProcessing.Visible = false;
                    return(ResultStatus.Fail);
                }

                //複製檔案
                file = PbFunc.wf_copy_file(rptId, rptId);
                if (file == "")
                {
                    return(ResultStatus.Fail);
                }

                //開啟檔案
                Workbook workbook = new Workbook();
                workbook.LoadDocument(file);

                //切換Sheet
                Worksheet ws30100 = workbook.Worksheets[0];
                //身份碼總列數隱藏於A2
                rowNum = 1;
                ws30100.Import(dt30100, false, rowNum, 0);

                //存檔
                ws30100.ScrollToRow(0);
                workbook.SaveDocument(file);
                lblProcessing.Text = "轉檔成功";
            } catch (Exception ex) {
                MessageDisplay.Error("輸出錯誤");
                throw ex;
            } finally {
                this.Cursor = Cursors.Arrow;
                this.Refresh();
                Thread.Sleep(5);
            }
            return(ResultStatus.Success);
        }
Example #5
0
        protected override ResultStatus Export()
        {
            if (!StartExport())
            {
                return(ResultStatus.Fail);
            }

            string lsFile = PbFunc.wf_copy_file(_ProgramID, "30396");

            Workbook workbook = new Workbook();

            //載入Excel
            workbook.LoadDocument(lsFile);
            try {
                b30396 = new B30396(workbook, emMonth.Text);

                ShowMsg("30396-「BRF」期貨契約價量資料 轉檔中...");
                OutputShowMessage = b30396.Wf30396();
                ShowMsg("30398abc-「BRF」期貨契約價量資料(買賣方比重) 轉檔中...");
                OutputShowMessage = b30396.Wf30396abc();
            }
            catch (Exception ex) {
                File.Delete(lsFile);
                WriteLog(ex);
                return(ResultStatus.Fail);
            }
            finally {
                //存檔
                workbook.SaveDocument(lsFile);
                EndExport();
            }
            return(ResultStatus.Success);
        }
Example #6
0
        protected override ResultStatus Export()
        {
            if (!StartExport())
            {
                return(ResultStatus.Fail);
            }
            string lsFile = PbFunc.wf_copy_file(_ProgramID, "30390");

            try {
                b30390 = new B30390(lsFile, emMonth.Text);
                //wf_30391()
                ShowMsg($"30390-「台灣五十」期貨契約價量資料 轉檔中...");
                OutputShowMessage = b30390.Wf30391();
            }
            catch (Exception ex) {
                File.Delete(lsFile);
                WriteLog(ex);
                return(ResultStatus.Fail);
            }
            finally {
                EndExport();
            }

            return(ResultStatus.Success);
        }
Example #7
0
            public override ReturnMessageClass Export()
            {
                ReturnMessageClass msg = new ReturnMessageClass();

                msg.Status = ResultStatus.Fail;

                try {
                    FilePath = PbFunc.wf_copy_file(ProgramId, $"{ProgramId}_{AdjType}");

                    base.OpenFileAndSetYear();

                    string prepoStr = Dt.AsEnumerable().Any(d => d.Field <string>("prod_type") == "F") ? "期貨契約保證金及" : "";
                    foreach (DataRow dr in Dt.Rows)
                    {
                        string abbrName      = dr["KIND_ABBR_NAME"].AsString();
                        string abbrName_Desc = dr["rule_full_name"].AsString() + "交易規則";

                        base.GenKindNameList(dr, prepoStr, abbrName, abbrName_Desc);
                    }

                    string beginDate = Dt.Rows[0]["issue_begin_ymd"].AsDateTime("yyyyMMdd").AsTaiwanDateTime("{0}年{1}月{2}日", 3);
                    ReplaceElementWord(GenArrayTxt(KindNameList), beginDate, GenArrayTxt(KindNameList_Desc), GenArrayTxt(KindNameList));

                    Doc.Save(FilePath);
                    msg.Status = ResultStatus.Success;
                    return(msg);
                } catch (Exception ex) {
                    base.ErrorHandle(ex, msg);
                    return(msg);
                }
            }
Example #8
0
        protected override ResultStatus Export()
        {
            ExportShow.Text = "轉檔中...";
            ExportShow.Show();

            string excelDestinationPath = "";

            try
            {
                base.Export();

                excelDestinationPath = PbFunc.wf_copy_file(_ProgramID, _ProgramID);

                flag = 0;

                ManipulateExcel(excelDestinationPath);

                if (flag == 0)
                {
                    File.Delete(excelDestinationPath);
                    ExportShow.Text = "轉檔失敗";
                    return(ResultStatus.Fail);
                }
            }
            catch (Exception ex)
            {
                File.Delete(excelDestinationPath);
                ExportShow.Text = "轉檔失敗";
                WriteLog(ex);
                return(ResultStatus.Fail);
            }
            ExportShow.Text = "轉檔成功!";

            return(ResultStatus.Success);
        }
Example #9
0
        protected override ResultStatus Export()
        {
            if (!StartExport())
            {
                return(ResultStatus.Fail);
            }

            string         lsFile  = PbFunc.wf_copy_file(_ProgramID, _ProgramID);
            MessageDisplay message = new MessageDisplay();

            try {
                b30720 = new B30720(lsFile, emMonth.Text, sleYear.Text, rgDate.EditValue.ToString(), rgTime.EditValue.ToString());

                ShowMsg("30720-月份交易量彙總表 轉檔中...");
                message.OutputShowMessage = b30720.WF30720();

                if (string.IsNullOrEmpty(message.OutputShowMessage))
                {
                    return(ResultStatus.Fail);
                }
            }
            catch (Exception ex) {
                if (File.Exists(lsFile))
                {
                    File.Delete(lsFile);
                }
                WriteLog(ex);
                return(ResultStatus.Fail);
            }
            finally {
                EndExport();
            }

            return(ResultStatus.Success);
        }
Example #10
0
        protected override ResultStatus Export()
        {
            string saveFilePath = PbFunc.wf_copy_file(_ProgramID, "30503");

            if (!StartExport())
            {
                return(ResultStatus.Fail);
            }
            string msg;

            try {
                //轉報表
                b30503 = new B30503(GlobalInfo.DEFAULT_REPORT_DIRECTORY_PATH, saveFilePath, emStartMth.Text, emEndMth.Text);
                ShowMsg("30503-股票期貨最近月份契約買賣價差月資料統計表 轉檔中...");
                msg = b30503.WF30503();
                OutputShowMessage = msg;
                ShowMsg("30504-股票期貨最近月份契約買賣價差日資料 轉檔中...");
                OutputShowMessage = b30503.WF30504();
            }
            catch (Exception ex) {
                File.Delete(saveFilePath);
                WriteLog(ex);
                return(ResultStatus.Fail);
            }
            finally {
                EndExport();
            }

            if (msg != MessageDisplay.MSG_OK)
            {
                File.Delete(saveFilePath);
                return(ResultStatus.Fail);
            }
            return(ResultStatus.Success);
        }
Example #11
0
        protected override ResultStatus Export()
        {
            if (!StartExport())
            {
                return(ResultStatus.Fail);
            }
            string lsFile = PbFunc.wf_copy_file(_ProgramID, "30380");

            try {
                b30380 = new B30380(lsFile, emMonth.Text);
                //wf_30311()
                ShowMsg($"30310-當年每月日均量統計表 轉檔中...");
                OutputShowMessage = b30380.Wf30311();
                //wf_30381()
                ShowMsg($"30380-新加坡交易所(SGX)摩根臺股期貨市場概況表 轉檔中...");
                OutputShowMessage = b30380.Wf30381();
            }
            catch (Exception ex) {
                File.Delete(lsFile);
                WriteLog(ex);
                return(ResultStatus.Fail);
            }
            finally {
                EndExport();
            }
            return(ResultStatus.Success);
        }
Example #12
0
        protected override ResultStatus Export()
        {
            if (!StartExport())
            {
                return(ResultStatus.Fail);
            }
            string         lsFile  = PbFunc.wf_copy_file(_ProgramID, "30540");
            MessageDisplay message = new MessageDisplay();

            try {
                b30540 = new B30540(lsFile, emMonth.Text);
                ShowMsg("30541-國內股價指數選擇權交易概況表 轉檔中...");
                message.OutputShowMessage = b30540.Wf30541();
                if (string.IsNullOrEmpty(message.OutputShowMessage))
                {
                    if (File.Exists(lsFile))
                    {
                        File.Delete(lsFile);
                    }
                    return(ResultStatus.Fail);
                }
            }
            catch (Exception ex) {
                if (File.Exists(lsFile))
                {
                    File.Delete(lsFile);
                }
                WriteLog(ex);
                return(ResultStatus.Fail);
            }
            finally {
                EndExport();
            }
            return(ResultStatus.Success);
        }
Example #13
0
        protected override ResultStatus Export()
        {
            ExportShow.Text = "轉檔中...";
            ExportShow.Show();
            try
            {
                base.Export();

                List <DbParameterEx> listParams = new List <DbParameterEx>();
                DbParameterEx        dbParaEx   = new DbParameterEx("as_ym", txtMonth.FormatValue);
                listParams.Add(dbParaEx);

                //轉統計資料W_AM
                ResultData resultData = new ServiceCommon().ExecuteStoredProcedure("ci.sp_H_stt_W_AM", listParams, true);

                string excelDestinationPath = PbFunc.wf_copy_file(_ProgramID, _ProgramID); //CopyExcelTemplateFile(_ProgramID, FileType.XLS);

                ManipulateExcel(excelDestinationPath);
            }
            catch (Exception ex)
            {
                ExportShow.Text = "轉檔失敗";
                WriteLog(ex);
                throw;
            }

            ExportShow.Text = "轉檔成功!";
            return(ResultStatus.Success);
        }
Example #14
0
        private ResultStatus ManipulateExcel()
        {
            string   excelDestinationPath = "";
            Workbook workbook             = new Workbook();

            DataTable dtContent = dao60320.ListData(txtStartDate.FormatValue, txtEndDate.FormatValue);

            if (dtContent.Rows.Count == 0)
            {
                MessageDisplay.Info(string.Format("{0},{1},無任何資料!", txtStartDate.Text, this.Text));
                ExportShow.Text = "轉檔失敗";
                return(ResultStatus.Fail);
            }
            else
            {
                excelDestinationPath = PbFunc.wf_copy_file(_ProgramID, _ProgramID);

                workbook.LoadDocument(excelDestinationPath);

                Worksheet worksheet = workbook.Worksheets[0];

                #region 明細
                int rowIndex = 7;
                foreach (DataRow row in dtContent.Rows)
                {
                    worksheet.Cells[rowIndex, 0].Value = row["YMD"].AsDouble().ToString("0000/00/00");
                    worksheet.Cells[rowIndex, 1].Value = row["M_QNTY_I"].AsDouble();
                    worksheet.Cells[rowIndex, 2].Value = row["S_QNTY_I"].AsDouble() + row["M_QNTY_I"].AsDouble();
                    worksheet.Cells[rowIndex, 3].SetValue(row["T5_QNTY"]);
                    worksheet.Cells[rowIndex, 4].SetValue(row["T3_QNTY"]);
                    worksheet.Cells[rowIndex, 5].SetValue(row["M_AMT_T_I"]);
                    worksheet.Cells[rowIndex, 6].SetValue(row["M_AMT_I"]);
                    worksheet.Cells[rowIndex, 7].SetValue(row["M_QNTY_S"]);
                    worksheet.Cells[rowIndex, 8].SetValue(row["S_QNTY_S"].AsDouble() + row["M_QNTY_S"].AsDouble());
                    worksheet.Cells[rowIndex, 9].SetValue(row["M_AMT_T_S"]);
                    worksheet.Cells[rowIndex, 10].SetValue(row["M_AMT_S"]);
                    worksheet.Cells[rowIndex, 11].SetValue(row["S_QNTY_I"].AsDouble() + row["M_QNTY_I"].AsDouble() + row["S_QNTY_S"].AsDouble() + row["M_QNTY_S"].AsDouble());
                    worksheet.Cells[rowIndex, 12].SetValue(Math.Round(row["ACCU_QNTY"].AsDouble() / row["DAY_COUNT"].AsDouble(), 0));
                    worksheet.Cells[rowIndex, 13].SetValue(row["M_AMT_I"].AsDouble() + row["M_AMT_S"].AsDouble());
                    worksheet.Cells[rowIndex, 14].SetValue(row["STWD_QNTY"]);
                    worksheet.Cells[rowIndex, 15].SetValue(row["STWD_AMT"]);
                    worksheet.Cells[rowIndex, 16].SetValue(row["AMIF_SUM_AMT"]);

                    rowIndex++;
                }
                if (rowIndex < 307)
                {
                    worksheet.Rows.Remove(rowIndex, 306 - rowIndex + 1);
                }
                worksheet.Range["A1"].Select();
                workbook.SaveDocument(excelDestinationPath);

                ExportShow.Text = "轉檔成功!";

                return(ResultStatus.Success);

                #endregion 明細
            }
        }
Example #15
0
        protected override ResultStatus Export()
        {
            try {
                //1.開始轉出資料
                panFilter.Enabled = false;
                labMsg.Visible    = true;
                labMsg.Text       = "開始轉檔...";
                this.Cursor       = Cursors.WaitCursor;
                this.Refresh();
                Thread.Sleep(5);

                //1.1 copy template xls to target path
                string   excelDestinationPath = PbFunc.wf_copy_file(_ProgramID, _ProgramID);
                Workbook workbook             = new Workbook();
                workbook.LoadDocument(excelDestinationPath);

                //2.匯出資料
                //共同的參數一起設定,init param = { D30395 dao, string startMonth }
                Object[] args = { dao30395, txtStartMonth.Text };

                int         pos = 0;
                IReportData GDF = CreateReport(GetType(), "GDF", args);
                pos += GDF.Export(workbook);

                //IReportData GDF_Detail = CreateReport(GetType(), "GDF_Detail", args);
                //GDF_Detail.Export(workbook);

                IReportData TGF = CreateReport(GetType(), "TGF", args);
                pos += TGF.Export(workbook);

                //IReportData TGF_Detail = CreateReport(GetType(), "TGF_Detail", args);
                //TGF_Detail.Export(workbook);

                if (pos <= 0)
                {
                    File.Delete(excelDestinationPath);
                    MessageDisplay.Info(MessageDisplay.MSG_NO_DATA, GlobalInfo.ResultText);
                    return(ResultStatus.Fail);
                }

                //存檔
                workbook.SaveDocument(excelDestinationPath);

                if (FlagAdmin)
                {
                    System.Diagnostics.Process.Start(excelDestinationPath);
                }

                return(ResultStatus.Success);
            } catch (Exception ex) {
                WriteLog(ex);
            } finally {
                panFilter.Enabled = true;
                labMsg.Text       = "";
                labMsg.Visible    = false;
                this.Cursor       = Cursors.Arrow;
            }
            return(ResultStatus.Fail);
        }
Example #16
0
        protected override ResultStatus Export()
        {
            if (!StartExport())
            {
                return(ResultStatus.Fail);
            }
            string lsFile = PbFunc.wf_copy_file(_ProgramID, "30360");
            //message.OutputShowMessage只會儲存ok的狀態,如沒有任何一個ok代表全部function都沒有資料
            MessageDisplay message = new MessageDisplay();

            try {
                b30360 = new B30360(lsFile, emMonth.Text);
                //wf_30361()
                ShowMsg($"30361-股票選擇權交易概況表 轉檔中...");
                message.OutputShowMessage = b30360.Wf30361();
                //wf_30362()
                ShowMsg($"30362-股票選擇權交易概況表 轉檔中...");
                message.OutputShowMessage = b30360.Wf30362();
                //wf_30363()
                ShowMsg($"30363-股票選擇權交易概況表 轉檔中...");
                message.OutputShowMessage = b30360.Wf30363();

                int stcCount = new D30360().ApdkSTCcount();
                if (stcCount > 0)
                {
                    //wf_30366()
                    ShowMsg($"30366-股票選擇權交易概況表 轉檔中...");
                    message.OutputShowMessage = b30360.Wf30366();
                    //wf_30367()
                    ShowMsg($"30367-股票選擇權交易概況表 轉檔中...");
                    message.OutputShowMessage = b30360.Wf30367();
                    //wf_30368()
                    ShowMsg($"30368-股票選擇權交易概況表 轉檔中...");
                    message.OutputShowMessage = b30360.Wf30368();
                }

                //連續跳3 or 6次無資料刪除檔案
                if (string.IsNullOrEmpty(message.OutputShowMessage))
                {
                    if (File.Exists(lsFile))
                    {
                        File.Delete(lsFile);
                    }
                    return(ResultStatus.Fail);
                }
            }
            catch (Exception ex) {
                if (File.Exists(lsFile))
                {
                    File.Delete(lsFile);
                }
                WriteLog(ex);
                return(ResultStatus.Fail);
            }
            finally {
                EndExport();
            }
            return(ResultStatus.Success);
        }
Example #17
0
        protected override ResultStatus Export()
        {
            if (!StartExport())
            {
                return(ResultStatus.Fail);
            }
            string saveFilePath = string.Empty;

            try {
                //資料來源
                DataTable dt = new D40050().GetData(emDate.Text.AsDateTime(), (emYear.Text + "/01/01").AsDateTime(), $"{oswGrpLookItem.EditValue.AsString()}%", $"{chgKind.EditValue.AsString()}%");
                if (dt.Rows.Count <= 0)
                {
                    MessageDisplay.Info(emDate.Text + ",讀取「保證金歷次調整紀錄」無任何資料!");
                    return(ResultStatus.Fail);
                }
                //複製template
                saveFilePath = PbFunc.wf_copy_file(_ProgramID, "40050");
                //呼叫邏輯類別
                b40050 = new B40050(saveFilePath, dt, emCount.Text.AsInt());
                MessageDisplay message = new MessageDisplay();
                /* Sheet:期貨data */
                ShowMsg("40051-期貨資料 轉檔中...");
                message.OutputShowMessage = b40050.Wf40051();
                /* Sheet:選擇權data */
                ShowMsg("40052-選擇權資料 轉檔中...");
                message.OutputShowMessage = b40050.Wf40052();
                /* Sheet:期貨股票類data */
                ShowMsg("40053-期貨股票類資料 轉檔中...");
                message.OutputShowMessage = b40050.Wf40053();
                /* Sheet:選擇權股票類data */
                ShowMsg("40054-選擇權股票類資料 轉檔中...");
                message.OutputShowMessage = b40050.Wf40054();

                //全部查無資料刪除檔案
                if (string.IsNullOrEmpty(message.OutputShowMessage))
                {
                    if (File.Exists(saveFilePath))
                    {
                        File.Delete(saveFilePath);
                    }
                    return(ResultStatus.Fail);
                }
            }
            catch (Exception ex) {
                if (File.Exists(saveFilePath))
                {
                    File.Delete(saveFilePath);
                }
                WriteLog(ex);
                return(ResultStatus.Fail);
            }
            finally {
                EndExport();
            }

            return(ResultStatus.Success);
        }
Example #18
0
        protected override ResultStatus Export()
        {
            if (!StartExport())
            {
                return(ResultStatus.Fail);
            }
            Workbook workbook = new Workbook();
            string   lsFile   = PbFunc.wf_copy_file(_ProgramID, "30393");

            //載入Excel
            workbook.LoadDocument(lsFile);
            try {
                b30393 = new B30393(workbook, emMonth.Text);
                //前月倒數2天交易日
                DateTime StartDate = PbFunc.f_get_last_day("AI3", "RHF", emMonth.Text, 2);
                //抓當月最後交易日
                DateTime EndDate = PbFunc.f_get_end_day("AI3", "RHF", emMonth.Text);

                //RHF
                ShowMsg("30393-「RHF」期貨契約價量資料 轉檔中...");
                OutputShowMessage = b30393.Wf30393(StartDate, EndDate, "RHF", "30393_1(RHF)");
                ShowMsg("30397-「黃金」期貨契約價量資料(買賣方比重) 轉檔中...");
                OutputShowMessage = b30393.Wf30393abc("RHF", "data_30393_1abc");

                //RTF
                b30393 = new B30393(workbook, emMonth.Text);
                ShowMsg("30393-「RTF」期貨契約價量資料 轉檔中...");
                OutputShowMessage = b30393.Wf30393(StartDate, EndDate, "RTF", "30393_2(RTF)");
                ShowMsg("30397-「黃金」期貨契約價量資料(買賣方比重) 轉檔中...");
                OutputShowMessage = b30393.Wf30393abc("RTF", "data_30393_2abc");

                //XEF
                b30393 = new B30393(workbook, emMonth.Text);
                ShowMsg("30393-「XEF」期貨契約價量資料 轉檔中...");
                OutputShowMessage = b30393.Wf30393(StartDate, EndDate, "XEF", "30393_3(XEF)");
                ShowMsg("30397-「黃金」期貨契約價量資料(買賣方比重) 轉檔中...");
                OutputShowMessage = b30393.Wf30393abc("XEF", "data_30393_3abc");

                //XJF
                b30393 = new B30393(workbook, emMonth.Text);
                ShowMsg("30393-「XJF」期貨契約價量資料 轉檔中...");
                OutputShowMessage = b30393.Wf30393(StartDate, EndDate, "XJF", "30393_4(XJF)");
                ShowMsg("30397-「黃金」期貨契約價量資料(買賣方比重) 轉檔中...");
                OutputShowMessage = b30393.Wf30393abc("XJF", "data_30393_4abc");
            }
            catch (Exception ex) {
                File.Delete(lsFile);
                WriteLog(ex);
                return(ResultStatus.Fail);
            }
            finally {
                //存檔
                workbook.SaveDocument(lsFile);
                workbook.Dispose();
                EndExport();
            }
            return(ResultStatus.Success);
        }
Example #19
0
        protected override ResultStatus Export()
        {
            try {
                #region 日期檢核
                if (string.Compare(txtStartMonth.Text, txtEndMonth.Text) > 0)
                {
                    MessageDisplay.Error("月份起始年月不可小於迄止年月!", GlobalInfo.ErrorText);
                    return(ResultStatus.Fail);
                }
                #endregion

                //0. ready
                panFilter.Enabled = false;
                labMsg.Visible    = true;
                labMsg.Text       = "開始轉檔...";
                this.Cursor       = Cursors.WaitCursor;
                this.Refresh();
                Thread.Sleep(5);

                //1. copy template xls to target path
                string   excelDestinationPath = PbFunc.wf_copy_file(_ProgramID, _ProgramID);
                Workbook workbook             = new Workbook();
                workbook.LoadDocument(excelDestinationPath);
                Worksheet worksheet = workbook.Worksheets[0];
                Range     range     = worksheet.Range["A7:Q7"];
                range.Alignment.WrapText = true;

                //2.填資料
                bool result = false;
                result = wf_Export(workbook, worksheet, txtStartMonth.Text.Replace("/", ""), txtEndMonth.Text.Replace("/", ""));

                if (!result)
                {
                    try {
                        workbook = null;
                        System.IO.File.Delete(excelDestinationPath);
                    } catch (Exception) {
                        //
                    }
                    return(ResultStatus.Fail);
                }

                //存檔
                workbook.SaveDocument(excelDestinationPath);
                labMsg.Visible = false;
                return(ResultStatus.Success);
            } catch (Exception ex) {
                WriteLog(ex);
            } finally {
                panFilter.Enabled = true;
                labMsg.Text       = "";
                labMsg.Visible    = false;
                this.Cursor       = Cursors.Arrow;
            }

            return(ResultStatus.Fail);
        }
Example #20
0
        /// <summary>
        /// 複製40010template並改變檔名
        /// </summary>
        /// <param name="kindID"></param>
        /// <returns></returns>
        private static string CopyWemaTemplateFile(string kindID)
        {
            string filepath;
            string tmpDate1         = DateTime.Now.ToString("yyyy.MM.dd-HH.mm.ss");
            string targetFileName   = $"40010_{ kindID}_{tmpDate1}.xlsm";
            string newExcelFileName = PbFunc.wf_copy_file("40010", "40010", targetFileName);

            filepath = Path.Combine(GlobalInfo.DEFAULT_REPORT_DIRECTORY_PATH, newExcelFileName);
            return(filepath);
        }
Example #21
0
        protected override ResultStatus Export()
        {
            if (!StartExport())
            {
                return(ResultStatus.Fail);
            }
            string saveFilePath = string.Empty;

            try {
                //資料來源
                DataTable dt = new D40060().GetData(emDate.Text.AsDateTime(), emYear.Text, $"{oswGrpLookItem.EditValue.AsString()}%");
                if (dt.Rows.Count <= 0)
                {
                    MessageDisplay.Info(emDate.Text + ",讀取「Span歷次調整紀錄」無任何資料!");
                    return(ResultStatus.Fail);
                }
                //複製template
                saveFilePath = PbFunc.wf_copy_file(_ProgramID, "40060");
                //呼叫邏輯類別
                b40060 = new B40060(saveFilePath, dt, emCount.Text.AsInt());
                MessageDisplay message = new MessageDisplay();
                /* Sheet:VSR */
                ShowMsg("40061-VSR 轉檔中...");
                message.OutputShowMessage = b40060.Wf40061();
                /* Sheet:Spread Credit */
                ShowMsg("40062-Spread Credit 轉檔中...");
                message.OutputShowMessage = b40060.Wf40062();
                /* Sheet:Delta Per Spread Ratio */
                ShowMsg("40063-Delta Per Spread Ratio 轉檔中...");
                message.OutputShowMessage = b40060.Wf40063();

                //全部查無資料刪除檔案
                if (string.IsNullOrEmpty(message.OutputShowMessage))
                {
                    if (File.Exists(saveFilePath))
                    {
                        File.Delete(saveFilePath);
                    }
                    return(ResultStatus.Fail);
                }
            }
            catch (Exception ex) {
                if (File.Exists(saveFilePath))
                {
                    File.Delete(saveFilePath);
                }
                WriteLog(ex);
                return(ResultStatus.Fail);
            }
            finally {
                EndExport();
            }

            return(ResultStatus.Success);
        }
Example #22
0
        protected override ResultStatus Export()
        {
            try {
                #region 輸入&日期檢核
                if (string.Compare(txtStartMonth.Text, txtEndMonth.Text) > 0)
                {
                    MessageDisplay.Error("月份起始年月不可小於迄止年月!", GlobalInfo.ErrorText);
                    return(ResultStatus.Fail);
                }
                #endregion

                //0. ready
                panFilter.Enabled = false;
                labMsg.Visible    = true;
                labMsg.Text       = "開始轉檔...";
                this.Cursor       = Cursors.WaitCursor;
                this.Refresh();
                Thread.Sleep(5);

                DateTime as_symd = DateTime.ParseExact((txtStartMonth.Text + "/01"), "yyyy/MM/dd", null);
                DateTime as_eymd = PbFunc.f_get_end_day("AI2", "TXF", txtEndMonth.Text); //抓當月最後交易日

                //1.複製檔案 & 開啟檔案 (因為三張報表都輸出到同一份excel,所以提出來)
                string   excelDestinationPath = PbFunc.wf_copy_file(_ProgramID, _ProgramID);
                Workbook workbook             = new Workbook();
                workbook.LoadDocument(excelDestinationPath);
                Worksheet worksheet = workbook.Worksheets[0];

                //2.填資料
                ii_ole_row = 3;
                bool sheet1 = wf_Export_30621(workbook, worksheet, as_symd, as_eymd);
                ii_ole_row += 5;
                bool sheet2 = wf_Export_30622(workbook, worksheet, as_symd, as_eymd);

                //存檔
                workbook.SaveDocument(excelDestinationPath);
                if (!sheet1 && !sheet2)
                {
                    File.Delete(excelDestinationPath);
                    return(ResultStatus.Fail);
                }
                return(ResultStatus.Success);
            } catch (Exception ex) {
                WriteLog(ex);
            } finally {
                panFilter.Enabled = true;
                labMsg.Text       = "";
                labMsg.Visible    = false;
                this.Cursor       = Cursors.Arrow;
            }
            return(ResultStatus.Fail);
        }
Example #23
0
        protected override ResultStatus Export()
        {
            ExportShow.Text = "轉檔中...";
            ExportShow.Show();

            try {
                Workbook  workbook = new Workbook();
                DataTable dtSP4    = new DataTable();
                DataTable dtSP5    = new DataTable();

                dtSP4 = daoS0020.GetSP4Data(txtDate.DateTimeValue.ToString("yyyy/MM/dd"));
                dtSP5 = daoS0020.GetSP5Data(txtDate.DateTimeValue.ToString("yyyy/MM/dd"));

                if (dtSP4.Rows.Count <= 0)
                {
                    ExportShow.Hide();
                    MessageDisplay.Info("無任何資料");
                    return(ResultStatus.Fail);
                }

                string destinationFilePath = PbFunc.wf_copy_file(_ProgramID, _ProgramID);

                workbook.LoadDocument(destinationFilePath);

                //將SP4資料放入Excel
                Worksheet worksheet = workbook.Worksheets[0];
                worksheet.Cells[0, 3].Value = txtDate.DateTimeValue.ToString("yyyy/MM/dd");
                for (int i = 0; i < dtSP4.Rows.Count; i++)
                {
                    int row = dtSP4.Rows[i]["SP4_TYPE"].AsInt();
                    worksheet.Cells[row + 7, 1].Value = dtSP4.Rows[i]["sp4_span_cnt"].AsInt();
                    worksheet.Cells[row + 7, 2].Value = dtSP4.Rows[i]["sp4_mkt_cnt"].AsInt();
                }

                //將SP5資料放入Excel(◎尚未申報者:)
                if (dtSP5.Rows.Count > 0)
                {
                    //從Excel 第40列開始塞資料
                    for (int i = 39; i < dtSP5.Rows.Count + 39; i++)
                    {
                        worksheet.Cells[i, 0].Value = dtSP5.Rows[i - 39]["sp5_brk_no"].AsString() + '-' +
                                                      dtSP5.Rows[i - 39]["sp5_brk_abbr_name"].AsString();
                    }
                }
                workbook.SaveDocument(destinationFilePath);
            } catch (Exception ex) {
                throw ex;
            }
            ExportShow.Text = "轉檔成功!";
            return(ResultStatus.Success);
        }
Example #24
0
        protected override ResultStatus Export()
        {
            ExportShow.Text = "轉檔中...";
            ExportShow.Show();

            Workbook  workbook = new Workbook();
            DataTable dt       = new DataTable();

            string   destinationFilePath = PbFunc.wf_copy_file(_ProgramID, _ProgramID);//Path.Combine(GlobalInfo.DEFAULT_REPORT_DIRECTORY_PATH, ls_filename);
            DateTime date = txtDate.DateTimeValue;
            int      rowStart = 4, colStart = 0;

            if (txt.EditValue == null)
            {
                MessageDisplay.Info("請輸入季度資訊 ! ");
                ExportShow.Hide();
                return(ResultStatus.FailButNext);
            }

            string yearQ = txt.EditValue.ToString();

            try {
                workbook.LoadDocument(destinationFilePath);
                Worksheet worksheet = workbook.Worksheets[0];

                worksheet.Cells[2, 0].Select();
                worksheet.Cells[2, 0].Value = yearQ;

                dt = dao35030.GetData(yearQ, date, date);
                if (dt.Rows.Count <= 0)
                {
                    ExportShow.Text = date.ToShortDateString() + "," + _ProgramID + '-' + _ProgramName + ",無任何資料!";
                    return(ResultStatus.Fail);
                }
                worksheet.Import(dt, false, rowStart, colStart);

                //刪除空白列
                Range ra = worksheet.Range[(dt.Rows.Count + rowStart + 1).ToString() + ":1004"];
                ra.Delete(DeleteMode.EntireRow);

                workbook.SaveDocument(destinationFilePath);
            }
            catch (Exception ex) {
                ExportShow.Text = "轉檔失敗";
                throw ex;
            }
            ExportShow.Text = "轉檔成功!";
            return(ResultStatus.Success);
        }
Example #25
0
        protected override ResultStatus Export()
        {
            //1.檢查日期欄位是否為正常日期


            lblProcessing.Visible = true;

            //2.複製檔案 & 開啟檔案 (因為三張報表都輸出到同一份excel,所以提出來)
            string   excelDestinationPath = PbFunc.wf_copy_file(_ProgramID, _ProgramID);
            Workbook workbook             = new Workbook();

            workbook.LoadDocument(excelDestinationPath);

            //3.export data (獨立,最多輸出三個sheet)
            bool result1 = false, result2 = false, result3 = false;

            if (chkMon.Checked)
            {
                result1 = wf_Export(workbook, SheetNo.mon, ReportType.mon,
                                    "月計總表", 1000, 3, txtStartMth.DateTimeValue, txtEndMth.DateTimeValue);
            }

            if (chkFcm.Checked)
            {
                result2 = wf_Export(workbook, SheetNo.date, ReportType.date,
                                    "日計明細表_by期貨商", 1000, 3, txtStartDate.DateTimeValue, txtEndDate.DateTimeValue);
            }

            if (chkAcc.Checked)
            {
                result3 = wf_Export(workbook, SheetNo.detail, ReportType.detail,
                                    "日計明細表_by交易人帳號", 1000, 4, txtStartDate.DateTimeValue, txtEndDate.DateTimeValue);
            }

            if (!result1 && !result2 && !result3)
            {
                try {
                    workbook = null;
                    System.IO.File.Delete(excelDestinationPath);
                } catch (Exception) {
                    //
                }
                return(ResultStatus.Fail);
            }

            //4.存檔並關閉
            workbook.SaveDocument(excelDestinationPath);
            return(ResultStatus.Success);
        }
Example #26
0
        protected override ResultStatus Export()
        {
            try {
                //1. ready
                panFilter.Enabled = false;
                labMsg.Visible    = true;
                labMsg.Text       = "開始轉檔...";
                this.Cursor       = Cursors.WaitCursor;
                this.Refresh();
                Thread.Sleep(5);

                //2. copy template xls to target path
                string   excelDestinationPath = PbFunc.wf_copy_file(_ProgramID, _ProgramID);
                Workbook workbook             = new Workbook();
                workbook.LoadDocument(excelDestinationPath);

                //3. write data
                bool   result1 = false, result2 = false;
                string tmpDate = txtDate.DateTimeValue.ToString("yyyy/MM/dd");
                result1 = wf_export(workbook, SheetNo.cm, "依結算會員", 206, 6, tmpDate);
                result2 = wf_export(workbook, SheetNo.fcm, "依期貨商", 206, 6, tmpDate);

                if (!result1 && !result2)
                {
                    try {
                        workbook = null;
                        System.IO.File.Delete(excelDestinationPath);
                    } catch (Exception) {
                        //
                    }
                    return(ResultStatus.Fail);
                }

                //4.存檔並關閉
                workbook.SaveDocument(excelDestinationPath);
                labMsg.Visible = false;

                return(ResultStatus.Success);
            } catch (Exception ex) {
                WriteLog(ex);
            } finally {
                panFilter.Enabled = true;
                labMsg.Text       = "";
                labMsg.Visible    = false;
                this.Cursor       = Cursors.Arrow;
            }
            return(ResultStatus.Fail);
        }
Example #27
0
        /// <summary>
        /// Export return 1 txt & 1 excel
        /// </summary>
        /// <returns></returns>
        protected override ResultStatus Export()
        {
            try {
                //2. ready
                panFilter.Enabled = false;
                labMsg.Visible    = true;
                labMsg.Text       = "訊息:" + this.Text + "轉檔中...";
                this.Refresh();

                //2.1 copy template xls to target path
                string excelDestinationPath = PbFunc.wf_copy_file(_ProgramID, _ProgramID);

                //2.2 open xls
                Workbook workbook = new Workbook();
                workbook.LoadDocument(excelDestinationPath);

                //2.3 寫入資料
                bool res1 = false, res2 = false;
                res1 = wf_40150(workbook, SheetNo.DPSR);
                res2 = wf_40152(workbook, SheetNo.VSR);

                //2.3 關閉、儲存檔案
                if (!res1 && !res2)
                {
                    workbook = null;
                    File.Delete(excelDestinationPath);
                    labMsg.Visible = false;
                    return(ResultStatus.Fail);
                }
                workbook.SaveDocument(excelDestinationPath);
                labMsg.Visible = false;

                if (FlagAdmin)
                {
                    System.Diagnostics.Process.Start(excelDestinationPath);
                }

                return(ResultStatus.Success);
            } catch (Exception ex) {
                WriteLog(ex);
            } finally {
                panFilter.Enabled = true;
                labMsg.Text       = "";
                labMsg.Visible    = false;
            }
            return(ResultStatus.Fail);
        }
Example #28
0
        protected override ResultStatus Export()
        {
            if (!StartExport())
            {
                return(ResultStatus.Fail);
            }
            string lsFile = PbFunc.wf_copy_file(_ProgramID, "30790");

            try {
                b30790 = new B30790(lsFile, emStartDate.Text, emEndDate.Text, emTxStartDate.Text, emTxEndDate.Text);
                MessageDisplay message = new MessageDisplay();
                if (chkAvg.Checked)
                {
                    ShowMsg("30790-盤後交易時段分時交易量分布 轉檔中...");
                    message.OutputShowMessage = b30790.Wf30790();
                }
                //TX每日日盤及夜盤之振幅及收盤價
                if (chkTx.Checked)
                {
                    ShowMsg("30790_4-盤後交易時段分時交易量分布 轉檔中...");
                    message.OutputShowMessage = b30790.Wf30790four();
                }
                if (string.IsNullOrEmpty(message.OutputShowMessage))
                {
                    if (File.Exists(lsFile))
                    {
                        File.Delete(lsFile);
                    }
                    return(ResultStatus.Fail);
                }
            }
            catch (Exception ex) {
                WriteLog(ex);
                if (File.Exists(lsFile))
                {
                    File.Delete(lsFile);
                }
                return(ResultStatus.Fail);
            }
            finally {
                EndExport();
            }

            return(ResultStatus.Success);
        }
Example #29
0
        protected override ResultStatus Export()
        {
            if (!StartExport())
            {
                return(ResultStatus.Fail);
            }

            string         lsFile  = PbFunc.wf_copy_file(_ProgramID, "30310");
            MessageDisplay message = new MessageDisplay();

            try {
                //呼叫邏輯類別
                b30310 = new B30310(lsFile, emMonth.Text);
                ShowMsg("30310-我國臺股期貨契約價量資料30311_1 轉檔中...");
                message.OutputShowMessage = b30310.Wf30310one("TXF", "30311_1");
                ShowMsg("30310-我國臺股期貨契約價量資料30311_2(EXF) 轉檔中...");
                message.OutputShowMessage = b30310.Wf30310two("EXF", "30311_2(EXF)");
                ShowMsg("30310-我國臺股期貨契約價量資料30311_3(FXF) 轉檔中...");
                message.OutputShowMessage = b30310.Wf30310two("FXF", "30311_3(FXF)");
                ShowMsg("30313-當年每月日均量統計表 轉檔中...");
                message.OutputShowMessage = b30310.Wf30310four();

                //連續跳四次無資料刪除檔案
                if (string.IsNullOrEmpty(message.OutputShowMessage))
                {
                    if (File.Exists(lsFile))
                    {
                        File.Delete(lsFile);
                    }
                    return(ResultStatus.Fail);
                }
            }
            catch (Exception ex) {
                if (File.Exists(lsFile))
                {
                    File.Delete(lsFile);
                }
                WriteLog(ex);
                return(ResultStatus.Fail);
            }
            finally {
                EndExport();
            }
            return(ResultStatus.Success);
        }
Example #30
0
        protected override ResultStatus Export()
        {
            try {
                if (txtFromMonth.Text.SubStr(0, 4) != txtToMonth.Text.SubStr(0, 4))
                {
                    MessageBox.Show("不可跨年度查詢!", "注意", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    return(ResultStatus.Fail);
                }
                base.Export();
                this.Cursor = Cursors.WaitCursor;
                this.Refresh();
                Thread.Sleep(5);
                lblProcessing.Visible = true;
                ShowMsg("開始轉檔...");
                string excelDestinationPath        = PbFunc.wf_copy_file(_ProgramID, _ProgramID);
                string excelDestinationPath_Detail = PbFunc.wf_copy_file(_ProgramID, _ProgramID + "MM");
                ManipulateExcel(excelDestinationPath);
                ManipulateExcel_Detail(excelDestinationPath_Detail);

                /**********************
                *  轉檔後資訊
                **********************/
                string lsYM;
                lsYM = txtToMonth.Text.Replace("/", "");
                DataTable dt_55060_after_export = dao55060.d_55060_after_export(lsYM);
                if (dt_55060_after_export.Rows[0]["ld_disc_qnty"].AsString() == "0")
                {
                    MessageBox.Show(lsYM + "「結算手續費」的可折抵口數皆為0," + Environment.NewLine + "請確認結算手續費作業是否已完成!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    ShowMsg("轉檔成功");
                    return(ResultStatus.Success);
                }
                ShowMsg("轉檔成功");
            }
            catch (Exception ex) {
                MessageDisplay.Error("輸出錯誤");
                ShowMsg("轉檔錯誤");
                throw ex;
            }
            finally {
                this.Cursor = Cursors.Arrow;
                this.Refresh();
                Thread.Sleep(5);
            }
            return(ResultStatus.Success);
        }