/// <summary>
        /// 顯示選取條件
        /// </summary>
        /// <returns></returns>
        private string ConditionText()
        {
            string lsText;

            /*******************
            *  顯示條件
            *******************/
            if (gbMarket.EditValue.Equals("rb_market_1"))
            {
                lsText = "盤後交易時段";
            }
            else
            {
                lsText = "一般交易時段";
            }
            if (!string.IsNullOrEmpty(_D500Xx.Sbrkno) || !string.IsNullOrEmpty(_D500Xx.Ebrkno))
            {
                lsText = lsText + ",造市者:";

                if (_D500Xx.Sbrkno == _D500Xx.Ebrkno)
                {
                    lsText = lsText + _D500Xx.Sbrkno + " ";
                }
                else
                {
                    lsText = lsText + _D500Xx.Sbrkno + "~" + _D500Xx.Ebrkno + " ";
                }
            }

            if (!string.IsNullOrEmpty(_D500Xx.ProdCategory))
            {
                lsText = lsText + ",商品群組:" + _D500Xx.ProdCategory;
            }
            if (!string.IsNullOrEmpty(_D500Xx.ProdKindIdSto))
            {
                lsText = lsText + ",2碼商品(個股):" + _D500Xx.ProdKindIdSto;
            }
            if (!string.IsNullOrEmpty(_D500Xx.ProdKindId))
            {
                lsText = lsText + ",造市商品:" + _D500Xx.ProdKindId;
            }
            if (PbFunc.Left(lsText, 1) == ",")
            {
                lsText = PbFunc.Mid(lsText, 1, 50);
            }
            if (!string.IsNullOrEmpty(lsText))
            {
                lsText = "報表條件:" + lsText;
            }
            return(lsText);
        }
        /// <summary>
        /// 顯示選取條件
        /// </summary>
        /// <returns></returns>
        private string ConditionText()
        {
            string lsText;

            /*******************
            *  顯示條件
            *******************/
            lsText = "一般交易時段";
            if (!string.IsNullOrEmpty(_D500Xx.Sbrkno) || !string.IsNullOrEmpty(_D500Xx.Ebrkno))
            {
                lsText = lsText + ",造市者:";

                if (_D500Xx.Sbrkno == _D500Xx.Ebrkno)
                {
                    lsText = lsText + _D500Xx.Sbrkno + " ";
                }
                else
                {
                    lsText = lsText + _D500Xx.Sbrkno + "~" + _D500Xx.Ebrkno + " ";
                }
            }

            if (!string.IsNullOrEmpty(_D500Xx.ProdCategory))
            {
                lsText = lsText + ",商品群組:" + _D500Xx.ProdCategory;
            }
            if (!string.IsNullOrEmpty(_D500Xx.ProdKindIdSto))
            {
                lsText = lsText + ",2碼商品(個股):" + _D500Xx.ProdKindIdSto;
            }
            if (!string.IsNullOrEmpty(_D500Xx.ProdKindId))
            {
                lsText = lsText + ",造市商品:" + _D500Xx.ProdKindId;
            }
            if (PbFunc.Left(lsText, 1) == ",")
            {
                lsText = PbFunc.Mid(lsText, 1, 50);
            }
            if (!string.IsNullOrEmpty(lsText))
            {
                lsText = "報表條件:" + lsText;
            }

            lsText = lsText == "" ? $"報表條件:連續{SleCMth.Text}個月不符造市規定" : lsText + $",連續{SleCMth.Text}個月不符造市規定";
            return(lsText);
        }
Beispiel #3
0
        protected override ResultStatus Export()
        {
            base.Export();
            string ls_rpt_name = "造市者報表";
            string ls_rpt_id   = _ProgramID;

            StartExport(ls_rpt_id, ls_rpt_name);

            StartRetrieve("0000000", "Z999999");
            _D500Xx.Filename = Path.Combine(GlobalInfo.DEFAULT_REPORT_DIRECTORY_PATH, _ProgramID + "_" + DateTime.Now.ToString("yyyy.MM.dd") + "-" + DateTime.Now.ToString("HH.mm.ss") + ".csv");
            try {
                /* 商品群組 */
                string isKey = dwProdCt.SelectedText.Trim() + "%";
                if (string.IsNullOrEmpty(isKey) || dwProdCt.Enabled == false)
                {
                    isKey = "%";
                }
                /* 商品 */
                string kindID2 = dwProdKdSto.SelectedText.Trim() + "%";
                if (string.IsNullOrEmpty(kindID2) || dwProdKdSto.Enabled == false)
                {
                    kindID2 = "%";
                }

                /*******************
                *  統計子類別
                *******************/
                string prodSubtype = "%";
                string sumSubtype  = "";
                if (gbGroup.EditValue.Equals("rb_gparam"))
                {
                    sumSubtype = "3";
                }
                else if (gbGroup.EditValue.Equals("rb_s"))
                {
                    sumSubtype = "S";

                    prodSubtype = "S";
                }
                else if (gbGroup.EditValue.Equals("rb_gkind2"))
                {
                    sumSubtype = "4";
                }

                /*******************
                *  交易時段
                *******************/
                int marketCode = 0;
                if (gbMarket.EditValue.Equals("rb_market_1"))
                {
                    marketCode = 1;
                }

                if (gbMarket.EditValue.Equals("rb_market_0"))
                {
                    marketCode = 0;
                }

                /*******************
                *  報表內容
                *******************/
                string detailType = "";
                if (gbDetial.EditValue.Equals("rb_gdate"))
                {
                    detailType = "D";
                }

                if (gbDetial.EditValue.Equals("rb_gnodate"))
                {
                    detailType = "N";
                }

                /*******************
                *  顯示條件
                *******************/
                string lsText = "";
                if (gbMarket.EditValue.Equals("rb_market_1"))
                {
                    lsText = "盤後交易時段";
                }
                else
                {
                    lsText = "一般交易時段";
                }
                if (!string.IsNullOrEmpty(_D500Xx.Sdate))
                {
                    lsText = lsText + "(" + _D500Xx.Sdate;
                }
                if (!string.IsNullOrEmpty(_D500Xx.Edate))
                {
                    lsText = lsText + "~" + _D500Xx.Edate + ")";
                }
                if (_D500Xx.Sbrkno != "%" || _D500Xx.Ebrkno != "%")
                {
                    lsText = lsText + ",造市者:";
                    if (_D500Xx.Sbrkno == _D500Xx.Ebrkno)
                    {
                        lsText = lsText + _D500Xx.Sbrkno + " ";
                    }
                    else
                    {
                        lsText = lsText + _D500Xx.Sbrkno + "~" + _D500Xx.Ebrkno + " ";
                    }
                }

                if (isKey != "%")
                {
                    lsText = lsText + ",商品群組:" + isKey;
                }
                if (kindID2 != "%")
                {
                    lsText = lsText + ",2碼商品(個股):" + kindID2;
                }

                if (PbFunc.Left(lsText, 1) == ",")
                {
                    lsText = PbFunc.Mid(lsText, 1, 50);
                }
                if (lsText != "")
                {
                    lsText = "報表條件:" + lsText;
                }

                /******************
                *  讀取資料
                ******************/
                /* 報表內容 */
                _Data = dao50031.ListD50031
                            (marketCode, sumSubtype, detailType, _D500Xx.Sdate, _D500Xx.Edate,
                            _D500Xx.Sbrkno, _D500Xx.Ebrkno, isKey, prodSubtype, kindID2, lsText);
                if (_Data.Rows.Count <= 0)
                {
                    MessageDisplay.Info(MessageDisplay.MSG_NO_DATA);
                    return(ResultStatus.Fail);
                }

                /******************
                *  開啟檔案
                ******************/
                Workbook workbook = new Workbook();
                //判斷檔案是否存在,不存在就開一個新檔案
                if (!File.Exists(_D500Xx.Filename))
                {
                    File.Create(_D500Xx.Filename).Close();
                }

                workbook.LoadDocument(_D500Xx.Filename);

                /******************
                *  切換Sheet
                ******************/
                Worksheet worksheet = workbook.Worksheets[0];
                workbook.Options.Export.Csv.WritePreamble = true; //不加這段中文會是亂碼
                                                                  //將DataTable中的數據導入Excel中
                worksheet.Import(_Data, false, 0, 0);
                workbook.SaveDocument(_D500Xx.Filename, DocumentFormat.Csv);
            }
            catch (Exception ex) {
                WfRunError();
                WriteLog(ex);
            }
            finally {
                EndExport();
            }
            return(ResultStatus.Success);
        }