protected override ResultStatus Retrieve()
        {
            DataTable dt    = dao40080.GetData(txtTradeDate.DateTimeValue);
            DataTable dtSp2 = dao40080.GetSP2Data(txtTradeDate.DateTimeValue);

            #region 設定生效日期
            int ll_found = 0;;
            //Group1
            if (dt.Select("sp1_osw_grp='1' and sp2_value_date is not null").Length != 0)                    //有找到
            {
                ll_found = dt.Rows.IndexOf(dt.Select("sp1_osw_grp='1' and sp2_value_date is not null")[0]); //ll_found = 找到的列數(從0開始)
            }
            else
            {
                ll_found = -1;
            }

            if (ll_found >= 0) //有找到
            {
                string sp2ValueDate = dt.Rows[ll_found]["sp2_value_date"].AsDateTime().ToString("yyyy/MM/dd");
                txtDate1.Text = sp2ValueDate;
            }
            else  //沒找到
            {
                string tmpDate = PbFunc.f_get_ocf_next_n_day(txtTradeDate.DateTimeValue, 1).ToString("yyyy/MM/dd");
                txtDate1.Text = tmpDate;
            }

            //Group2
            if (dt.Select("sp1_osw_grp='5' and sp2_value_date is not null").Length != 0)
            {
                ll_found = dt.Rows.IndexOf(dt.Select("sp1_osw_grp='5' and sp2_value_date is not null")[0]);
            }
            else
            {
                ll_found = -1;
            }

            if (ll_found >= 0)
            {
                string sp2ValueDate = dt.Rows[ll_found]["sp2_value_date"].AsDateTime().ToString("yyyy/MM/dd");
                txtDate2.Text = sp2ValueDate;
            }
            else
            {
                string tmpDate = PbFunc.f_get_ocf_next_n_day(txtTradeDate.DateTimeValue, 2).ToString("yyyy/MM/dd");
                txtDate2.Text = tmpDate;
            }
            #endregion

            gcMain.Visible    = true;
            gcMain.DataSource = dt;
            GridHelper.SetCommonGrid(gvMain);
            gvMain.OptionsBehavior.AllowFixedGroups = DefaultBoolean.True;

            gvMain.Columns["OSW_GRP"].Group();
            gvMain.Columns["SP1_CHANGE_RANGE"].DisplayFormat.FormatType   = FormatType.Numeric;
            gvMain.Columns["SP1_CHANGE_RANGE"].DisplayFormat.FormatString = "P";

            gvMain.AppearancePrint.HeaderPanel.Options.UseTextOptions = true;
            gvMain.ColumnPanelRowHeight               = 20;
            gvMain.AppearancePrint.HeaderPanel.Font   = new Font("Microsoft YaHei", gvMain.AppearancePrint.HeaderPanel.Font.Size);
            gvMain.AppearancePrint.Row.Font           = new Font("Microsoft YaHei", 12);
            gvMain.OptionsPrint.AllowMultilineHeaders = true;
            gvMain.AppearancePrint.GroupRow.Font      = new Font("Microsoft YaHei", 12);

            gvMain.BestFitColumns();
            gvMain.ExpandAllGroups();
            gcMain.Focus();

            return(ResultStatus.Success);
        }
        protected override ResultStatus Retrieve()
        {
            try {
                //清空Grid
                gcMain.DataSource = null;

                //讀取資料
                dao40070 = new D40070();
                DataTable dt40070 = dao40070.d_40070_scrn(txtSDate.DateTimeValue.ToString("yyyyMMdd"), ddlModel.EditValue.AsString());
                if (dt40070.Rows.Count == 0)
                {
                    MessageDisplay.Warning("無任何資料!");
                    return(ResultStatus.Fail);
                }
                //排序
                dt40070 = dt40070.Sort("OSW_GRP, SEQ_NO, PROD_TYPE, KIND_ID");
                //複製
                //dw_1.RowsCopy(1, dw_1.rowcount(), primary!, ids_tmp, 1, primary!)
                dtTemp = dt40070.Copy();
                //過濾
                DataView dv = dt40070.AsDataView();
                dv.RowFilter = " ab_type in ('-','A')";
                DataTable dtFiltered = dv.ToTable();

                gcMain.DataSource = dtFiltered;
                gcMain.Refresh();
                //預設展開群組
                gvMain.ExpandAllGroups();

                //設定三個Group的生效日期
                string validDateG1, validDateG5;
                int    found;
                //Group1
                found = dtFiltered.Rows.IndexOf(dtFiltered.Select("osw_grp='1' and issue_begin_ymd is not null ").FirstOrDefault());
                if (found > -1)
                {
                    txtDateG1.DateTimeValue = dtFiltered.Rows[found]["ISSUE_BEGIN_YMD"].AsDateTime("yyyyMMdd");
                }
                else
                {
                    txtDateG1.DateTimeValue = PbFunc.f_get_ocf_next_n_day(txtSDate.DateTimeValue, 1);
                }
                validDateG1 = txtDateG1.Text;
                //Group2
                found = dtFiltered.Rows.IndexOf(dtFiltered.Select("osw_grp='5' and issue_begin_ymd is not null ").FirstOrDefault());
                if (found > -1)
                {
                    txtDateG5.DateTimeValue = dtFiltered.Rows[found]["ISSUE_BEGIN_YMD"].AsDateTime("yyyyMMdd");
                }
                else
                {
                    txtDateG5.DateTimeValue = PbFunc.f_get_ocf_next_n_day(txtSDate.DateTimeValue, 2);
                }
                validDateG5 = txtDateG5.Text;
                //Group3
                //found = dtFiltered.Rows.IndexOf(dtFiltered.Select("osw_grp='7' and issue_begin_ymd is not null ").FirstOrDefault());
                //if (found > -1) {
                //   txtDateG7.DateTimeValue = dtFiltered.Rows[found]["ISSUE_BEGIN_YMD"].AsDateTime("yyyyMMdd");
                //} else {
                //   txtDateG7.DateTimeValue = PbFunc.f_get_ocf_next_n_day(txtSDate.DateTimeValue , 2);
                //}
                //validDateG7 = txtDateG7.Text;
            } catch (Exception ex) {
                MessageDisplay.Error("讀取錯誤");
                throw ex;
            }

            return(ResultStatus.Success);
        }