示例#1
0
        /// <summary>
        /// 檢查壓力測試設定
        /// </summary>
        private bool checkPresTest()
        {
            DataTable dtPresTest = (DataTable)gcPresTest.DataSource;

            if (!checkComplete(dtPresTest, LabPressTest.Text.Replace(":", "")))
            {
                return(false);
            }

            foreach (DataRow r in dtPresTest.Rows)
            {
                if (r.RowState != DataRowState.Deleted)
                {
                    if (r["span_param_type"].AsString() == "2")
                    {
                        switch (r["span_param_value"].AsString())
                        {
                        case "1":
                        case "2":
                        case "3":
                        case "4": {//最大漲跌停
                            break;
                        }

                        default: {
                            MessageDisplay.Info("設定方式選漲跌停價格, 則設定值請選擇1, 2, 3或最大漲跌停");
                            return(false);
                        }
                        }
                    }
                }
            }

            return(true);
        }
示例#2
0
        /// <summary>
        /// 小型美元兌人民幣選擇權(RTO)20大行情表
        /// </summary>
        /// <param name="ws"></param>
        protected bool wf30053rtoTop20(Worksheet ws)
        {
            string rptName = "小型美元兌人民幣選擇權(RTO)20大行情表", rptId = "30053";

            ShowMsg(rptId + '-' + rptName + " 轉檔中...");

            //讀取資料
            DataTable dt30053RtoTop20 = dao30053.d_30053_c_top20(txtSDate.Text, "RTO");

            if (dt30053RtoTop20.Rows.Count == 0)
            {
                MessageDisplay.Info(txtSDate.Text + "," + rptId + '-' + rptName + ",無任何資料!");
                lblProcessing.Visible = false;
                return(false);
            }
            //填資料
            Range range = ws.Range["F1:H1"];

            range.NumberFormat   = "@";
            ws.Cells[0, 5].Value = date;
            ws.Import(dt30053RtoTop20, false, 2, 0);
            ws.ScrollToRow(0);
            flag++;
            return(true);
        }
示例#3
0
        /// <summary>
        /// 檢查交易帳號 (期貨商代號欄位必須為7碼,末3碼不為999)
        /// </summary>
        private bool checkExAccount()
        {
            DataTable dtExAccount = (DataTable)gcExAccount.DataSource;

            if (!checkComplete(dtExAccount, LabEXAccount.Text.Replace(":", "")))
            {
                return(false);
            }

            foreach (DataRow r in dtExAccount.Rows)
            {
                if (r.RowState != DataRowState.Deleted)
                {
                    //期貨商代號欄位必須為7碼,末3碼不為999
                    if (r["SPAN_ACCT_FCM_NO"].AsString().SubStr(4, 3) == "999" ||
                        r["SPAN_ACCT_FCM_NO"].AsString().Length != 7)
                    {
                        MessageDisplay.Info("期貨商代號欄位必須為7碼,末3碼不為999");
                        return(false);
                    }

                    //交易人代號欄位必須為7碼
                    if (r["SPAN_ACCT_ACC_NO"].AsString().Length != 7)
                    {
                        MessageDisplay.Info("交易人代號欄位必須為7碼");
                        return(false);
                    }
                }
            }
            return(true);
        }
示例#4
0
        /// <summary>
        /// 股票期貨Top10檔(For經濟日報)
        /// </summary>
        /// <param name="ws"></param>
        protected bool wf30053stfTop10(Worksheet ws)
        {
            string rptName = "股票期貨Top10檔_經濟", rptId = "30053";

            ShowMsg(rptId + '-' + rptName + " 轉檔中...");

            //讀取資料
            DataTable dt30053StfTop40 = dao30053.d_30053_c_stf_top40(txtSDate.Text);

            if (dt30053StfTop40.Rows.Count == 0)
            {
                MessageDisplay.Info(txtSDate.Text + "," + rptId + '-' + rptName + ",無任何資料!");
                lblProcessing.Visible = false;
                return(false);
            }
            //填資料
            Range range = ws.Range["E1:G1"];

            range.NumberFormat   = "@";
            ws.Cells[0, 4].Value = date;
            ws.Import(dt30053StfTop40, false, 2, 0);
            ws.ScrollToRow(0);
            flag++;
            return(true);
        }
示例#5
0
        /// <summary>
        /// 股票期貨(For工商時報)
        /// </summary>
        /// <param name="ws30053stfNear"></param>
        protected bool wf30053stfNear(Worksheet ws)
        {
            string rptName = "股票期貨(For工商時報)", rptId = "30053";

            ShowMsg(rptId + '-' + rptName + " 轉檔中...");

            //讀取資料
            DataTable dt30053stfNear = dao30053.d_30053_c_stf_near40(txtSDate.Text, "F", "40");

            if (dt30053stfNear.Rows.Count == 0)
            {
                MessageDisplay.Info(txtSDate.Text + "," + rptId + '-' + rptName + ",無任何資料!");
                lblProcessing.Visible = false;
                return(false);
            }
            //填資料
            Range range = ws.Range["J1:L1"];

            range.NumberFormat   = "@";
            ws.Cells[0, 9].Value = date;
            ws.Import(dt30053stfNear, false, 2, 0);
            ws.ScrollToRow(0);
            flag++;
            return(true);
        }
示例#6
0
        protected ResultStatus wf_30681_d_new()
        {
            try {
                string reportId             = "30681_d_new";
                string excelDestinationPath = Path.Combine(GlobalInfo.DEFAULT_REPORT_DIRECTORY_PATH,
                                                           string.Format("{0}_{1}.csv", reportId, DateTime.Now.ToString("yyyy.MM.dd-HH.mm.ss")));

                //1.get dataTable
                DataTable dtTarget = dao30681.d_30681_d_new(txtStartDate.DateTimeValue, txtEndDate.DateTimeValue, ddlScCode.EditValue.AsString(),
                                                            txtKind1.Text, txtKind2.Text, Mth1, Mth2,
                                                            ddlOsfOrderType.EditValue.AsString(), ddlOsfOrderCond.EditValue.AsString(), DetailLevelList, IsLevelNull);
                if (dtTarget.Rows.Count <= 0)
                {
                    MessageDisplay.Info(string.Format("{0},{1}-{2},無任何資料!", txtStartDate.DateTimeValue.ToString("yyyyMM"), reportId, ReportName), GlobalInfo.ResultText);
                    return(ResultStatus.Fail);
                }

                //2.Export Csv
                ExportCsv(dtTarget, excelDestinationPath);

                return(ResultStatus.Success);
            } catch (Exception ex) {
                WriteLog(ex);
                return(ResultStatus.Fail);
            }
        }
示例#7
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);
        }
示例#8
0
        protected override ResultStatus Retrieve()
        {
            DataTable returnTable = new DataTable();

            _cpYMD      = emDate.Text.Replace("/", "");
            returnTable = dao20231.List20231(_cpYMD);

            if (returnTable.Rows.Count <= 0)
            {
                gcMain.Visible = false;
                MessageDisplay.Info(MessageDisplay.MSG_NO_DATA);
                return(ResultStatus.Success);
            }
            if (!string.IsNullOrEmpty(returnTable.Rows[0]["PLS4_PDK_YMD"].AsString()))
            {
                _IsPdkYMD       = returnTable.Rows[0]["PLS4_PDK_YMD"].AsString();
                emProdDate.Text = _IsPdkYMD.AsDateTime("yyyyMMdd").ToString("yyyy/MM/dd");
            }
            _ToolBtnInsert.Enabled = true;
            _ToolBtnSave.Enabled   = true;
            _ToolBtnDel.Enabled    = true;

            gcMain.Visible = true;

            base.Retrieve(gcMain);
            //流水號欄寬
            gvMain.IndicatorWidth = 60;

            returnTable.Columns.Add("Is_NewRow", typeof(string));
            gcMain.DataSource = returnTable;

            gcMain.Focus();
            this.gvMain.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(this.gvMain_CustomDrawRowIndicator);
            return(ResultStatus.Success);
        }
示例#9
0
        protected override ResultStatus Export()
        {
            ExportShow.Text = "轉檔中...";
            ExportShow.Show();
            try {
                object[]           args    = { new D40xxx(), TxtDate, AdjType, _ProgramID };
                IExport40xxxData   xmlData = CreateXmlData(GetType(), "ExportXml" + AdjType, args);
                ReturnMessageClass msg     = xmlData.GetData();

                //無資料時不產檔
                if (msg.Status != ResultStatus.Success)
                {
                    ExportShow.Text = MessageDisplay.MSG_IMPORT_FAIL;
                    MessageDisplay.Info($"{txtDate.DateTimeValue.ToShortDateString()},{_ProgramID}-{ddlAdjType.Properties.GetDisplayText(AdjType)},{MessageDisplay.MSG_NO_DATA}");
                    return(msg.Status);
                }

                msg = xmlData.Export();

                if (msg.Status != ResultStatus.Success)
                {
                    ExportShow.Text = MessageDisplay.MSG_IMPORT_FAIL;
                    MessageDisplay.Info(MessageDisplay.MSG_IMPORT_FAIL);
                    return(msg.Status);
                }
            } catch (Exception ex) {
                ExportShow.Text = MessageDisplay.MSG_IMPORT_FAIL;
                WriteLog(ex);
                return(ResultStatus.Fail);
            }
            ExportShow.Text = "轉檔成功!";
            return(ResultStatus.Success);
        }
示例#10
0
        protected ResultStatus wf_30681_s_new()
        {
            try
            {
                string reportId             = "30681_s_new";
                string excelDestinationPath = Path.Combine(GlobalInfo.DEFAULT_REPORT_DIRECTORY_PATH,
                                                           string.Format("{0}_{1}.csv", reportId, DateTime.Now.ToString("yyyy.MM.dd-HH.mm.ss")));

                //1.get dataTable
                DataTable dtTarget = dao30681.d_30681_s_new(StartDate.DateTimeValue, EndDate.DateTimeValue, DDLScCode, Kind1, Kind2, Mth1, Mth2, IsProcOriTab);
                if (dtTarget.Rows.Count <= 0)
                {
                    MessageDisplay.Info(string.Format("{0},{1}-{2},無任何資料!", StartDate.DateTimeValue.ToString("yyyyMM"), reportId, ReportName), GlobalInfo.ResultText);
                    return(ResultStatus.Fail);
                }

                //2.Export Csv
                ExportCsv(dtTarget, excelDestinationPath);

                return(ResultStatus.Success);
            }
            catch (Exception ex)
            {
                WriteLog(ex);
                return(ResultStatus.Fail);
            }
        }
示例#11
0
        /// <summary>
        /// wf_30670_amt (讀取資料:本周名目本金)
        /// </summary>
        /// <param name="kindName">XXX%</param>
        /// <param name="worksheet"></param>
        private void wf_30670_amt(string kindName, Worksheet worksheet)
        {
            int       cellCol, cellRow;
            DataTable dtMoney = dao30670.d30670_AA2_AMT(StartDate, EndDate, kindName);

            if (dtMoney.Rows.Count <= 0)
            {
                labMsg.Text = string.Format("{0}-{1}", StartDate, EndDate) + "," + rptFileName + '-' + rptFuncName + "(amt),無任何資料!";
                MessageDisplay.Info(string.Format("{0}-{1},{2}-{3}(amt),無任何資料!", txtStartYMD.Text, txtEndYMD.Text, rptFileName, rptFuncName), GlobalInfo.ResultText);
                return;
            }

            //資料寫入
            for (int w = 0; w < dtMoney.Rows.Count; w++)
            {
                cellRow = dtMoney.Rows[w]["RPT_ROW"].AsInt() - 1;

                cellCol = dtMoney.Rows[w]["RPT_COL"].AsInt() - 1;
                worksheet.Cells[cellRow, cellCol].Value = dtMoney.Rows[w]["SUM_AMT_ORG"].AsDecimal();

                if (kindName == "RHF%")
                {
                    cellRow += 2;
                    worksheet.Cells[cellRow, cellCol].Value = dtMoney.Rows[w]["SUM_AMT_USD"].AsDecimal();
                }
            }
        }
示例#12
0
        protected override ResultStatus Save(PokeBall poke)
        {
            DataTable dtCurrent = (DataTable)gcMain.DataSource;

            gvMain.CloseEditor();
            gvMain.UpdateCurrentRow();

            DataTable dtChange      = dtCurrent.GetChanges();
            DataTable dtForAdd      = dtCurrent.GetChanges(DataRowState.Added);
            DataTable dtForModified = dtCurrent.GetChanges(DataRowState.Modified);
            DataTable dtForDeleted  = dtCurrent.GetChanges(DataRowState.Deleted);

            if (dtChange == null)
            {
                MessageDisplay.Info("沒有變更資料,不需要存檔!");
                return(ResultStatus.Fail);
            }
            if (dtChange.Rows.Count == 0)
            {
                MessageDisplay.Info("沒有變更資料,不需要存檔!");
                return(ResultStatus.Fail);
            }

            dtChange = dtCurrent.GetChanges();
            ResultData result = dao.UpdateData(dtChange);

            if (result.Status == ResultStatus.Fail)
            {
                return(ResultStatus.Fail);
            }

            return(ResultStatus.Success);
        }
示例#13
0
        /// <summary>
        /// lds_insert.RowsCopy(1,lds_insert.rowcount(), primary!, dw_1, 1, primary!)
        /// </summary>
        /// <param name="isYMD"></param>
        private void RowsCopy(string isYMD)
        {
            DataTable insertData = b30290.ListInsertGridData(emDate.Text, isYMD);

            if (insertData.Rows.Count <= 0)
            {
                _ToolBtnSave.Enabled   = false;
                _ToolBtnDel.Enabled    = false;
                _ToolBtnExport.Enabled = false;
                MessageDisplay.Info(MessageDisplay.MSG_NO_DATA);
            }
            DataTable data = b30290.List30290GridData(isYMD).Clone();//dw_1.reset()

            //新增與insertData對應的行數
            foreach (DataRow item in insertData.Rows)
            {
                data.Rows.InsertAt(data.NewRow(), 0);
            }
            //InsertData寫入List30290Data
            for (int k = 0; k < insertData.Rows.Count; k++)
            {
                for (int j = 0; j < insertData.Columns.Count; j++)
                {
                    data.Rows[k][j] = insertData.Rows[k][j];
                }
            }
            gcMain.DataSource = data;
        }
示例#14
0
        private ResultStatus ManipulateExcel()
        {
            string excelDestinationPath = "";

            Workbook workbook = new Workbook();


            DataTable dtContent = dao60330.ListData(txtStartMonth.FormatValue, txtEndMonth.FormatValue);

            var cpDayCnt = dtContent.AsEnumerable().GroupBy(t => new { })
                           .Select(g => new
            {
                CP_DAY_CNT = g.Max(s => s.Field <decimal>("AI2_DAY_COUNT"))
            }).FirstOrDefault();

            if (dtContent.Rows.Count == 0)
            {
                MessageDisplay.Info(string.Format("{0},{1},無任何資料!", txtStartMonth.Text, this.Text));
                ExportShow.Text = "轉檔失敗";
                return(ResultStatus.Fail);
            }
            else
            {
                #region 明細
                workbook.LoadDocument(excelDestinationPath);

                Worksheet worksheet = workbook.Worksheets[0];

                worksheet.Cells[2, 0].Value = txtStartMonth.Text + "~" + txtEndMonth.Text + worksheet.Cells[2, 0].Value;
                worksheet.Cells[2, 8].Value = cpDayCnt.CP_DAY_CNT.AsString();

                int rowIndex = 4;
                foreach (DataRow row in dtContent.Rows)
                {
                    worksheet.Cells[rowIndex, 0].Value = row["AI2_PARAM_KEY"].AsString();
                    worksheet.Cells[rowIndex, 1].Value = row["PARAM_NAME"].AsString();
                    worksheet.Cells[rowIndex, 2].SetValue(row["AI2_M_QNTY"]);
                    worksheet.Cells[rowIndex, 3].SetValue(row["AM2_QNTY1"]);
                    worksheet.Cells[rowIndex, 4].SetValue(row["AM2_QNTY2"]);
                    worksheet.Cells[rowIndex, 5].SetValue(row["AM2_QNTY3"]);
                    worksheet.Cells[rowIndex, 6].SetValue(row["AM2_QNTY4"]);
                    worksheet.Cells[rowIndex, 7].SetValue(row["AM2_QNTY5"]);
                    worksheet.Cells[rowIndex, 8].SetValue(row["TAX"]);

                    rowIndex++;
                }

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

                ExportShow.Text = "轉檔成功!";
                return(ResultStatus.Success);

                #endregion 明細
            }
        }
示例#15
0
        protected virtual ResultStatus Save_Override(DataTable dt, string tableName, DBName dBName = DBName.CI)
        {
            DataGate DG = new DataGate();

            MessageDisplay.Info("Save_Override has been remove");
            return(ResultStatus.Fail);
        }
示例#16
0
        protected override ResultStatus Export()
        {
            //讀取資料
            defaultTable = dao50050.ListAll(brkNo, accNo, time1, time2, prodKindId,
                                            settleDate, pcCode, li_p_seq_no1, li_p_seq_no2, dbName, "Y");
            if (defaultTable.Rows.Count <= 0)
            {
                MessageDisplay.Info(string.Format("{0},{1},無任何資料!", txtStartDate.Text, this.Text), GlobalInfo.ResultText);
                return(ResultStatus.Fail);
            }
            this.Cursor = Cursors.WaitCursor;

            foreach (DataRow dr in defaultTable.Rows)
            {
                dr["ammd_date"] += " 00:00:00";
            }

            //存CSV
            string etfFileName = "50050_" + DateTime.Now.ToString("yyyy.MM.dd-HH.mm.ss") + ".csv";

            etfFileName = Path.Combine(GlobalInfo.DEFAULT_REPORT_DIRECTORY_PATH, etfFileName);
            ExportOptions csvref = new ExportOptions();

            csvref.HasHeader = true;
            csvref.Encoding  = System.Text.Encoding.GetEncoding(950);//ASCII
            Common.Helper.ExportHelper.ToCsv(defaultTable, etfFileName, csvref);

            this.Cursor = Cursors.Arrow;
            return(ResultStatus.Success);
        }
示例#17
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            if (((DataTable)gcMain.DataSource).Rows.Count > 0)
            {
                GridControl gridControlPrint = GridHelper.CloneGrid(gcMain);

                string originReportTitle = this.Text;

                ReportHelper reportHelper;

                DataTable dt = ((DataView)gvMain.DataSource).ToTable().Clone();
                dt.ImportRow(((DataRowView)gvMain.GetFocusedRow()).Row);
                reportHelper = PrintOrExportSetting();
                reportHelper.IsHandlePersonVisible = true;
                reportHelper.IsManagerVisible      = true;
                gridControlPrint.DataSource        = dt;
                reportHelper.ReportTitle           = originReportTitle;

                reportHelper.Create(GenerateReport(gridControlPrint));

                Print(reportHelper);
                Export(reportHelper);
            }
            else
            {
                MessageDisplay.Info("無補印資料");
            }
        }
示例#18
0
        protected override ResultStatus Save(PokeBall pokeBall)
        {
            base.Save(gcMain);
            _IsPreventFlowPrint  = true;
            _IsPreventFlowExport = true;

            string fileName = "使用者權限查詢_{0}.txt";

            fileName = string.Format(fileName, DateTime.Now.ToString("yyyyMMdd"));

            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter           = "txt files (*.txt)|*.txt";
            saveFileDialog.FileName         = fileName;
            saveFileDialog.InitialDirectory = GlobalInfo.DEFAULT_REPORT_DIRECTORY_PATH;

            Stream stream;

            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                if ((stream = saveFileDialog.OpenFile()) != null)
                {
                    DataTable     dtMain        = (DataTable)gcMain.DataSource;
                    ExportOptions exportOptions = new ExportOptions();
                    exportOptions.HasHeader = true;
                    ExportHelper.ToText(dtMain, stream, exportOptions);
                    MessageDisplay.Info("存檔完成!");
                }
            }

            return(ResultStatus.Success);
        }
示例#19
0
        /// <summary>
        /// 3.1 現貨data
        /// </summary>
        /// <param name="workbook"></param>
        /// <param name="is_symd">yyyyMMdd</param>
        /// <param name="is_eymd">yyyyMMdd</param>
        /// <param name="is_code"></param>
        /// <param name="TotalDayCount"></param>
        /// <returns></returns>
        protected ResultStatus wf_40210_3(Workbook workbook, string is_symd, string is_eymd, List <string> is_code, int TotalDayCount)
        {
            try {
                string reportId   = "40210_3";
                string reportName = "現貨data";
                ShowMsg(reportId + '-' + reportName + " 轉檔中...");
                //1.get dataTable
                DataTable dtTarget = dao40210.d_40210_3(is_symd, is_eymd, is_code);

                if (dtTarget.Rows.Count <= 0)
                {
                    MessageDisplay.Info(string.Format("{0}-{1},{2}-{3},讀取無任何資料!", is_symd, is_eymd, reportId, reportName), GlobalInfo.ResultText);
                    return(ResultStatus.Fail);
                }

                Worksheet worksheet = workbook.Worksheets[reportName];

                //1.1 write data
                worksheet.Import(dtTarget, false, 1, 0);

                worksheet.ScrollTo(0, 0);
                flag++;
                return(ResultStatus.Success);
            } catch (Exception ex) {
                WriteLog(ex);
                return(ResultStatus.Fail);
            }
        }
示例#20
0
        protected override ResultStatus Save(PokeBall pokeBall)
        {
            base.Save(gcMain);
            _IsPreventFlowPrint  = true;
            _IsPreventFlowExport = true;

            string fileName = "Z9999_{0}.csv";

            fileName = string.Format(fileName, DateTime.Now.ToString("yyyyMMdd"));

            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter           = "CSV|*.csv";
            saveFileDialog.FileName         = fileName;
            saveFileDialog.InitialDirectory = GlobalInfo.DEFAULT_REPORT_DIRECTORY_PATH;

            Stream stream;

            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                if ((stream = saveFileDialog.OpenFile()) != null)
                {
                    DataTable     dtMain        = (DataTable)gcMain.DataSource;
                    ExportOptions exportOptions = new ExportOptions();
                    exportOptions.HasHeader = true;
                    ExportHelper.ToCsv(dtMain, stream, exportOptions);
                    MessageDisplay.Info("存檔完成!");
                    SingletonLogger.Instance.Info(GlobalInfo.USER_ID, _ProgramID, "轉出檔案" + saveFileDialog.FileName, "E");
                }
            }

            return(ResultStatus.Success);
        }
示例#21
0
        /// <summary>
        /// wf_30670_ymd (讀取資料:日期)
        /// </summary>
        /// <param name="kindName">XXX%</param>
        /// <param name="worksheet"></param>
        private void wf_30670_ymd(string kindName, Worksheet worksheet)
        {
            int       cellCol, cellRow;
            DataTable dtDate = dao30670.d30670_AI2_YMD(StartDate, EndDate, kindName);

            if (dtDate.Rows.Count <= 0)
            {
                labMsg.Text = string.Format("{0}-{1}", StartDate, EndDate) + "," + rptFileName + '-' + rptFuncName + "(日期),無任何資料!";
                MessageDisplay.Info(string.Format("{0}-{1},{2}-{3}(日期),無任何資料!", txtStartYMD.Text, txtEndYMD.Text, rptFileName, rptFuncName), GlobalInfo.ResultText);
                return;
            }

            //資料寫入
            for (int w = 0; w < dtDate.Rows.Count; w++)
            {
                cellRow = dtDate.Rows[w]["RPT_ROW"].AsInt() + dtDate.Rows[w]["DAY_SEQ_NO"].AsInt() - 2;
                string tmp = dtDate.Rows[w]["AI2_YMD"].AsString();
                worksheet.Cells[cellRow, 0].Value = tmp.AsDateTime("yyyyMMdd");
                //worksheet.Cells[cellRow , 0].Value = tmp.SubStr(0 , 4) + "/" + tmp.SubStr(4 , 2) + "/" + tmp.SubStr(6 , 2);
                //worksheet.Cells[cellRow , 0].Value = string.Format("yyyy/MM/dd",dtDate.Rows[w]["AI2_YMD"]);

                cellCol = dtDate.Rows[w]["RPT_M_COL"].AsInt() - 1;
                worksheet.Cells[cellRow, cellCol].Value = dtDate.Rows[w]["SUM_QNTY"].AsDecimal();

                cellCol = dtDate.Rows[w]["RPT_OI_COL"].AsInt() - 1;
                worksheet.Cells[cellRow, cellCol].Value = dtDate.Rows[w]["SUM_OI"].AsDecimal();
            }
        }
示例#22
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);
        }
示例#23
0
        /// <summary>
        /// wf_30403 (sheet3 data)
        /// </summary>
        /// <param name="workbook"></param>
        /// <param name="sheetNo">SheetNo.tradeSum</param>
        /// <param name="row"> 0 </param>
        /// <returns></returns>
        protected int wf_30403(Workbook workbook, SheetNo sheetNo, int rowNum)
        {
            string rptName = "股票期貨交易概況表";

            ShowMsg("30403-" + rptName + " 轉檔中...");

            try {
                //1. 抓當月最後交易日
                string strMon        = txtMon.Text.Replace("/", "");
                string lastTradeDate = dao30400.GetThisMonLastTradeData(strMon); //當月最後交易日(yyyyMMdd)
                string sDate         = strMon + "01";                            //當月第一天

                //2. 讀取資料
                DataTable dt30403 = dao30400.Get30403Data(sDate, lastTradeDate);
                if (dt30403.Rows.Count <= 0)
                {
                    DateTime startDate = DateTime.ParseExact(sDate, "yyyyMMdd", null);
                    MessageDisplay.Info(String.Format("{0}~,30403 - {1},無任何資料!", startDate.ToString("yyyy/MM/dd"), rptName), GlobalInfo.ResultText);
                    return(0);
                } //if (dt30401.Rows.Count <= 0)

                //3. 切換Sheet
                Worksheet ws3 = workbook.Worksheets[(int)sheetNo];

                //4. 處理資料
                string kindId = "";
                foreach (DataRow dr in dt30403.Rows)
                {
                    string kindId2 = dr["ai2_kind_id_2"].AsString();
                    string pdkName = dr["pdk_name"].AsString();

                    if (kindId != kindId2)
                    {
                        kindId = kindId2;
                        rowNum++;
                        ws3.Cells[rowNum, 0].Value = kindId;
                        ws3.Cells[rowNum, 1].Value = pdkName;
                    }

                    int colNum = dr["seq_no"].AsInt();
                    if (colNum > 0)
                    {
                        string  ymd    = dr["ai2_ymd"].AsString();
                        string  tmpYmd = DateTime.ParseExact(ymd, "yyyyMMdd", null).ToString("yyyy/MM/dd");
                        decimal mQnty  = dr["ai2_m_qnty"].AsDecimal();
                        ws3.Cells[0, colNum + 1].Value      = tmpYmd;
                        ws3.Cells[rowNum, colNum + 1].Value = mQnty;
                    }
                }//foreach (DataRow dr in dt30403.Rows)

                ws3.Range["A1"].Select();
                ws3.ScrollToRow(0);

                return(1);
            } catch (Exception ex) {
                WriteLog(ex);
                return(0);
            }
        }
示例#24
0
        protected override ResultStatus Save(PokeBall pokeBall)
        {
            try {
                DataTable dt       = (DataTable)gcMain.DataSource;
                DataTable dtChange = dt.GetChanges();

                if (dtChange == null)
                {
                    MessageBox.Show("沒有變更資料,不需要存檔!", "注意", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return(ResultStatus.Fail);
                }
                if (dtChange.Rows.Count == 0)
                {
                    MessageBox.Show("沒有變更資料,不需要存檔!", "注意", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return(ResultStatus.Fail);
                }

                DataTable dtForAdd = dt.GetChanges(DataRowState.Added);
                if (dtForAdd != null)
                {
                    //檢查重複key值
                    if (!checkDuplicate(dt.GetChanges(DataRowState.Added)))
                    {
                        return(ResultStatus.FailButNext);
                    }
                }

                //更新主要Table
                foreach (DataRow dr in dtChange.Rows)
                {
                    if (dr.RowState == DataRowState.Added || dr.RowState == DataRowState.Modified)
                    {
                        if (string.IsNullOrEmpty(dr["PLT1_QNTY_MIN"].AsString()) || string.IsNullOrEmpty(dr["PLT1_QNTY_MAX"].AsString()) ||
                            string.IsNullOrEmpty(dr["PLT1_MULTIPLE"].AsString()))
                        {
                            MessageDisplay.Info("資料尚未填寫完成!");
                            return(ResultStatus.FailButNext);
                        }
                        else
                        {
                            ResultData myResultData = dao20220.updatePLT1(dt);
                            if (myResultData.Status == ResultStatus.Fail)
                            {
                                return(ResultStatus.Fail);
                            }
                            else
                            {
                                _IsPreventFlowPrint = false; //若有update成功才會跳列印PDF視窗
                            }
                        }
                    }
                }
            } catch (Exception ex) {
                MessageDisplay.Error("存檔失敗");
                WriteLog(ex);
                return(ResultStatus.FailButNext);
            }
            return(ResultStatus.Success);
        }
示例#25
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 明細
            }
        }
示例#26
0
        protected virtual ResultStatus ExportAfter(string startTime)
        {
            string finishTime = DateTime.Now.ToString("HH:mm:ss");

            MessageDisplay.Info("轉檔完成!", "處理結果" + " " + startTime + " ~ " + finishTime);

            return(ResultStatus.Success);
        }
示例#27
0
        protected override ResultStatus COMPLETE()
        {
            MessageDisplay.Info("密碼變更完成!");

            this.Close();

            return(ResultStatus.Success);
        }
示例#28
0
        protected override ResultStatus COMPLETE()
        {
            MessageDisplay.Info(MessageDisplay.MSG_OK);

            Retrieve();

            return(ResultStatus.Success);
        }
示例#29
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);
        }
示例#30
0
        /// <summary>
        /// wf_30417 (sheet1 data)
        /// </summary>
        /// <param name="workbook"></param>
        /// <param name="sheetNo">SheetNo.tradeSum</param>
        /// <param name="rowNum"> 2 </param>
        /// <returns></returns>
        protected bool wf_30417(Workbook workbook, SheetNo sheetNo, int rowNum, DataTable dtYmd)
        {
            string rptName = "股票期貨每週交概況統計表"; //報表標題名稱

            labMsg.Text = _ProgramID + "-" + rptName + " 轉檔中...";

            try {
                //1. 切換Sheet
                Worksheet ws30417 = workbook.Worksheets[(int)sheetNo];

                //2. 讀取資料
                DataTable dt = new D30417().ListData(StartDate, EndDate);
                if (dt.Rows.Count <= 0)
                {
                    MessageDisplay.Info(String.Format("{0}~{1},{2} - {3},無任何資料!", StartDate, EndDate, _ProgramID, rptName), GlobalInfo.ResultText);
                    return(false);
                } //if (dt.Rows.Count <= 0 )

                //3. 日期
                int pos = 0;
                foreach (DataRow dr in dtYmd.Rows)
                {
                    pos++;
                    //將週日期區間數量相加
                    string    ai2Ymd = dr["startDate"].AsString().Replace("/", "");
                    string    ymdEnd = dr["endDate"].AsString().Replace("/", "");
                    DataTable dtTmp  = dt.Filter(string.Format("ai2_ymd>='{0}' and ai2_ymd<='{1}'", ai2Ymd, ymdEnd));

                    if (dtTmp.Rows.Count > 0)
                    {
                        int     tmpRow      = pos + 1;
                        decimal sumDayCount = dtTmp.Compute("Sum(ai2_day_count)", "").AsDecimal();
                        decimal sumMQnty    = dtTmp.Compute("Sum(ai2_m_qnty)", "").AsDecimal();
                        decimal sumOi       = dtTmp.Compute("Sum(ai2_oi)", "").AsDecimal();
                        decimal sumCnt      = dtTmp.Compute("Sum(am10_cnt)", "").AsDecimal();
                        decimal sumAccCnt   = dtTmp.Compute("Sum(am9_acc_cnt)", "").AsDecimal();

                        string sDate = dr["startDate"].AsString().SubStr(0, 10);
                        string eDate = dr["endDate"].AsString().SubStr(0, 10);

                        ws30417.Cells[tmpRow, 0].Value = sumDayCount;
                        ws30417.Cells[tmpRow, 1].Value = string.Format("{0}~{1}", sDate, eDate);
                        ws30417.Cells[tmpRow, 2].Value = sumMQnty;
                        ws30417.Cells[tmpRow, 4].Value = sumOi;
                        ws30417.Cells[tmpRow, 6].Value = sumCnt;
                        ws30417.Cells[tmpRow, 9].Value = sumAccCnt;
                    } //if (dtTmp.Rows.Count > 0)
                }     //foreach (DataRow dr in dtYm.Rows)

                ws30417.Range["A1"].Select();
                ws30417.ScrollToRow(0);

                return(true);
            } catch (Exception ex) {
                WriteLog(ex);
                return(false);
            }
        }