protected override ResultStatus Save(PokeBall pokeBall)
        {
            //PB不管資料有無異動都會存檔

            #region ue_save_before
            if (gvMain.RowCount == 0)
            {
                MessageDisplay.Error("下方視窗無資料無法進行存檔,請先執行「讀取/預覽」!");
                return(ResultStatus.Fail);
            }

            //0. 先結束編輯
            gvGBF.CloseEditor();
            gvMain.CloseEditor();

            string showMsg = "";
            //1. 寫LOG到ci.PLLOG
            try {
                showMsg = "異動紀錄(PLLOG)更新資料庫錯誤! ";
                DataTable dtPLLOG     = dao30203.d_30203_pllog();
                DataTable dtPL1Insert = dao30203.d_30203_PL1Insert(txtDate.Text.Replace("/", "").AsString());

                int    i;
                int    PL1NewRowCount = 0;
                string ls_prod_type, ls_prod_subtype, ls_kind_id;
                for (i = 0; i < gvMain.RowCount; i++)
                {
                    if (gvMain.GetRowCellValue(i, "Is_NewRow").AsString() == "1")
                    {
                        ls_kind_id = gvMain.GetRowCellValue(i, "PL1_KIND_ID").AsString();
                        DataTable dtProdType = dao30203.ProdType(ls_kind_id);
                        if (dtProdType.Rows.Count == 0)
                        {
                            MessageDisplay.Error("商品 " + ls_kind_id + " 無商品基本資料,無法新增!");
                            return(ResultStatus.Fail);
                        }
                        ls_prod_type    = dtProdType.Rows[0]["PROD_TYPE"].AsString();
                        ls_prod_subtype = dtProdType.Rows[0]["PROD_SUBTYPE"].AsString();

                        gvMain.SetRowCellValue(i, "PL1_YMD", txtDate.Text.Replace("/", "").AsString());
                        gvMain.SetRowCellValue(i, "PL1_PROD_TYPE", ls_prod_type);
                        gvMain.SetRowCellValue(i, "PL1_PROD_SUBTYPE", ls_prod_subtype);
                        gvMain.SetRowCellValue(i, "PL1_999", gvMain.GetRowCellValue(i, "PL1_LEGAL").AsDecimal() * 3);
                        gvMain.SetRowCellValue(i, "PL1_CUR_NATURE", 0);
                        gvMain.SetRowCellValue(i, "PL1_CUR_LEGAL", 0);
                        gvMain.SetRowCellValue(i, "PL1_CUR_999", gvMain.GetRowCellValue(i, "PL1_CUR_LEGAL").AsDecimal() * 3);
                        gvMain.SetRowCellValue(i, "PL1_PREV_AVG_QNTY", 0);
                        gvMain.SetRowCellValue(i, "PL1_PREV_AVG_OI", 0);
                        gvMain.SetRowCellValue(i, "PL1_AVG_QNTY", 0);
                        gvMain.SetRowCellValue(i, "PL1_AVG_OI", 0);
                        gvMain.SetRowCellValue(i, "PL1_CHANGE_RANGE", 0);
                        gvMain.SetRowCellValue(i, "PL1_CP_999", gvMain.GetRowCellValue(i, "PL1_CP_LEGAL").AsDecimal() * 3);
                        gvMain.SetRowCellValue(i, "PL1_999_ADJ", "+");
                        gvMain.SetRowCellValue(i, "PL1_UPD_TIME", DateTime.Now);
                        gvMain.SetRowCellValue(i, "PL1_UPD_USER_ID", GlobalInfo.USER_ID);
                        if (gvMain.GetRowCellValue(i, "PL1_NATURE_ADJ").AsString().Equals(""))
                        {
                            gvMain.SetRowCellValue(i, "PL1_NATURE_ADJ", " ");
                        }
                        else
                        {
                            gvMain.SetRowCellValue(i, "PL1_NATURE_ADJ", gvMain.GetRowCellValue(i, "PL1_NATURE_ADJ").AsString());
                        }
                        if (gvMain.GetRowCellValue(i, "PL1_LEGAL_ADJ").AsString().Equals(""))
                        {
                            gvMain.SetRowCellValue(i, "PL1_LEGAL_ADJ", " ");
                        }
                        else
                        {
                            gvMain.SetRowCellValue(i, "PL1_LEGAL_ADJ", gvMain.GetRowCellValue(i, "PL1_LEGAL_ADJ").AsString());
                        }

                        //下列add by Tom
                        PL1NewRowCount++;
                        dtPL1Insert.Rows.Add();
                        dtPL1Insert.Rows[dtPL1Insert.Rows.Count - 1]["PL1_KIND_ID"]       = ls_kind_id;
                        dtPL1Insert.Rows[dtPL1Insert.Rows.Count - 1]["PL1_YMD"]           = txtDate.Text.Replace("/", "").AsString();
                        dtPL1Insert.Rows[dtPL1Insert.Rows.Count - 1]["PL1_PROD_TYPE"]     = ls_prod_type;
                        dtPL1Insert.Rows[dtPL1Insert.Rows.Count - 1]["PL1_PROD_SUBTYPE"]  = ls_prod_subtype;
                        dtPL1Insert.Rows[dtPL1Insert.Rows.Count - 1]["PL1_999"]           = gvMain.GetRowCellValue(i, "PL1_999").AsDecimal();
                        dtPL1Insert.Rows[dtPL1Insert.Rows.Count - 1]["PL1_CUR_NATURE"]    = 0;
                        dtPL1Insert.Rows[dtPL1Insert.Rows.Count - 1]["PL1_CUR_LEGAL"]     = 0;
                        dtPL1Insert.Rows[dtPL1Insert.Rows.Count - 1]["PL1_CUR_999"]       = gvMain.GetRowCellValue(i, "PL1_CUR_999").AsDecimal();
                        dtPL1Insert.Rows[dtPL1Insert.Rows.Count - 1]["PL1_PREV_AVG_QNTY"] = 0;
                        dtPL1Insert.Rows[dtPL1Insert.Rows.Count - 1]["PL1_PREV_AVG_OI"]   = 0;
                        dtPL1Insert.Rows[dtPL1Insert.Rows.Count - 1]["PL1_AVG_QNTY"]      = 0;
                        dtPL1Insert.Rows[dtPL1Insert.Rows.Count - 1]["PL1_AVG_OI"]        = 0;
                        dtPL1Insert.Rows[dtPL1Insert.Rows.Count - 1]["PL1_CHANGE_RANGE"]  = 0;
                        dtPL1Insert.Rows[dtPL1Insert.Rows.Count - 1]["PL1_CP_999"]        = gvMain.GetRowCellValue(i, "PL1_CP_999").AsDecimal();
                        dtPL1Insert.Rows[dtPL1Insert.Rows.Count - 1]["PL1_UPD_TIME"]      = gvMain.GetRowCellValue(i, "PL1_UPD_TIME");
                        dtPL1Insert.Rows[dtPL1Insert.Rows.Count - 1]["PL1_UPD_USER_ID"]   = gvMain.GetRowCellValue(i, "PL1_UPD_USER_ID");
                        dtPL1Insert.Rows[dtPL1Insert.Rows.Count - 1]["PL1_999_ADJ"]       = "+";
                        dtPL1Insert.Rows[dtPL1Insert.Rows.Count - 1]["PL1_NATURE_ADJ"]    = gvMain.GetRowCellValue(i, "PL1_NATURE_ADJ");
                        dtPL1Insert.Rows[dtPL1Insert.Rows.Count - 1]["PL1_LEGAL_ADJ"]     = gvMain.GetRowCellValue(i, "PL1_LEGAL_ADJ");
                        dtPL1Insert.Rows[dtPL1Insert.Rows.Count - 1]["PL1_NATURE"]        = gvMain.GetRowCellValue(i, "PL1_NATURE").AsDecimal();
                        dtPL1Insert.Rows[dtPL1Insert.Rows.Count - 1]["PL1_CP_NATURE"]     = gvMain.GetRowCellValue(i, "PL1_CP_NATURE").AsDecimal();
                        dtPL1Insert.Rows[dtPL1Insert.Rows.Count - 1]["PL1_CP_LEGAL"]      = gvMain.GetRowCellValue(i, "PL1_CP_LEGAL").AsDecimal();
                        dtPL1Insert.Rows[dtPL1Insert.Rows.Count - 1]["PL1_LEGAL"]         = gvMain.GetRowCellValue(i, "PL1_LEGAL").AsDecimal();
                    }
                    if (gvMain.GetRowCellValue(i, "PL1_NATURE").AsDecimal() == gvMain.GetRowCellValue(i, "PL1_NATURE_ORG").AsDecimal() &&
                        gvMain.GetRowCellValue(i, "PL1_LEGAL").AsDecimal() == gvMain.GetRowCellValue(i, "PL1_LEGAL_ORG").AsDecimal())
                    {
                        continue;
                    }
                    if (gvMain.GetRowCellValue(i, "PL1_NATURE").AsDecimal() != gvMain.GetRowCellValue(i, "PL1_NATURE_ORG").AsDecimal())
                    {
                        dtPLLOG.Rows.Add();
                        //dtPLLOG.Rows[dtPLLOG.Rows.Count - 1]["PLLOG_YMD"] = gvMain.GetRowCellValue(i, "PL1_YMD").AsString();
                        dtPLLOG.Rows[dtPLLOG.Rows.Count - 1]["PLLOG_YMD"]       = txtDate.Text.Replace("/", "").AsString();
                        dtPLLOG.Rows[dtPLLOG.Rows.Count - 1]["PLLOG_KIND_ID"]   = gvMain.GetRowCellValue(i, "PL1_KIND_ID").AsString();
                        dtPLLOG.Rows[dtPLLOG.Rows.Count - 1]["PLLOG_DATA_TYPE"] = "N";
                        dtPLLOG.Rows[dtPLLOG.Rows.Count - 1]["PLLOG_ORG_VALUE"] = gvMain.GetRowCellValue(i, "PL1_NATURE_ORG").AsDecimal().AsString();
                        dtPLLOG.Rows[dtPLLOG.Rows.Count - 1]["PLLOG_UPD_VALUE"] = gvMain.GetRowCellValue(i, "PL1_NATURE").AsDecimal().AsString();
                        dtPLLOG.Rows[dtPLLOG.Rows.Count - 1]["PLLOG_W_TIME"]    = DateTime.Now;
                        dtPLLOG.Rows[dtPLLOG.Rows.Count - 1]["PLLOG_W_USER_ID"] = GlobalInfo.USER_ID;
                    }
                    if (gvMain.GetRowCellValue(i, "PL1_LEGAL").AsDecimal() != gvMain.GetRowCellValue(i, "PL1_LEGAL_ORG").AsDecimal())
                    {
                        dtPLLOG.Rows.Add();
                        //dtPLLOG.Rows[dtPLLOG.Rows.Count - 1]["PLLOG_YMD"] = gvMain.GetRowCellValue(i, "PL1_YMD").AsString();
                        dtPLLOG.Rows[dtPLLOG.Rows.Count - 1]["PLLOG_YMD"]       = txtDate.Text.Replace("/", "").AsString();
                        dtPLLOG.Rows[dtPLLOG.Rows.Count - 1]["PLLOG_KIND_ID"]   = gvMain.GetRowCellValue(i, "PL1_KIND_ID").AsString();
                        dtPLLOG.Rows[dtPLLOG.Rows.Count - 1]["PLLOG_DATA_TYPE"] = "E";
                        dtPLLOG.Rows[dtPLLOG.Rows.Count - 1]["PLLOG_ORG_VALUE"] = gvMain.GetRowCellValue(i, "PL1_LEGAL_ORG").AsDecimal().AsString();
                        dtPLLOG.Rows[dtPLLOG.Rows.Count - 1]["PLLOG_UPD_VALUE"] = gvMain.GetRowCellValue(i, "PL1_LEGAL").AsDecimal().AsString();
                        dtPLLOG.Rows[dtPLLOG.Rows.Count - 1]["PLLOG_W_TIME"]    = DateTime.Now;
                        dtPLLOG.Rows[dtPLLOG.Rows.Count - 1]["PLLOG_W_USER_ID"] = GlobalInfo.USER_ID;

                        gvMain.SetRowCellValue(i, "PL1_999", gvMain.GetRowCellValue(i, "PL1_LEGAL").AsDecimal() * 3);
                        dtPL1Insert.Rows[dtPL1Insert.Rows.Count - 1]["PL1_999"] = gvMain.GetRowCellValue(i, "PL1_999").AsDecimal();
                    }
                }
                // 寫入DB
                ResultData myResultData = dao30203.updatePLLOG(dtPLLOG);
                #endregion

                string ls_ymd, ls_eff_ymd, ls_eff_ymd_lower;
                bool   delResult = false;
                ls_ymd           = txtDate.Text.Replace("/", "");
                ls_eff_ymd       = txtEffDate.Text.Replace("/", "");
                ls_eff_ymd_lower = txtEffDateLower.Text.Replace("/", "");
                //2. 刪除資料 PL2,PL2B
                showMsg   = "PL2刪除失敗";
                delResult = dao30203.DeletePL2ByDate(ls_ymd);
                if (!delResult)
                {
                    MessageDisplay.Error(showMsg);
                    return(ResultStatus.Fail);
                }
                showMsg   = "PL2B刪除失敗";
                delResult = dao30203.DeletePL2BByDate(ls_ymd);
                if (!delResult)
                {
                    MessageDisplay.Error(showMsg);
                    return(ResultStatus.Fail);
                }

                //3. 新增 PL2
                showMsg = "確認資料(PL2)更新資料庫錯誤! ";
                DataTable dtInsertPL2 = dao30203.d_30203_pl2(ls_ymd);
                for (i = 0; i < gvMain.RowCount; i++)
                {
                    dtInsertPL2.Rows.Add();
                    if (gvMain.GetRowCellValue(i, "PL1_NATURE_ADJ").AsString() == "-")
                    {
                        dtInsertPL2.Rows[dtInsertPL2.Rows.Count - 1]["PL2_EFFECTIVE_YMD"] = ls_eff_ymd_lower;
                    }
                    else
                    {
                        dtInsertPL2.Rows[dtInsertPL2.Rows.Count - 1]["PL2_EFFECTIVE_YMD"] = ls_eff_ymd;
                    }
                    //dtInsertPL2.Rows[dtInsertPL2.Rows.Count - 1]["PL2_YMD"] = gvMain.GetRowCellValue(i, "PL1_YMD").AsString();
                    dtInsertPL2.Rows[dtInsertPL2.Rows.Count - 1]["PL2_YMD"]         = txtDate.Text.Replace("/", "").AsString();
                    dtInsertPL2.Rows[dtInsertPL2.Rows.Count - 1]["PL2_KIND_ID"]     = gvMain.GetRowCellValue(i, "PL1_KIND_ID").ToString();
                    dtInsertPL2.Rows[dtInsertPL2.Rows.Count - 1]["PL2_NATURE"]      = gvMain.GetRowCellValue(i, "PL1_NATURE").AsInt();
                    dtInsertPL2.Rows[dtInsertPL2.Rows.Count - 1]["PL2_LEGAL"]       = gvMain.GetRowCellValue(i, "PL1_LEGAL").AsInt();
                    dtInsertPL2.Rows[dtInsertPL2.Rows.Count - 1]["PL2_999"]         = gvMain.GetRowCellValue(i, "PL1_999").AsInt();
                    dtInsertPL2.Rows[dtInsertPL2.Rows.Count - 1]["PL2_NATURE_ADJ"]  = gvMain.GetRowCellValue(i, "PL1_NATURE_ADJ").ToString();
                    dtInsertPL2.Rows[dtInsertPL2.Rows.Count - 1]["PL2_LEGAL_ADJ"]   = gvMain.GetRowCellValue(i, "PL1_LEGAL_ADJ").ToString();
                    dtInsertPL2.Rows[dtInsertPL2.Rows.Count - 1]["PL2_999_ADJ"]     = gvMain.GetRowCellValue(i, "PL1_999_ADJ").ToString();
                    dtInsertPL2.Rows[dtInsertPL2.Rows.Count - 1]["PL2_PREV_NATURE"] = gvMain.GetRowCellValue(i, "PL1_CUR_NATURE").AsInt();
                    dtInsertPL2.Rows[dtInsertPL2.Rows.Count - 1]["PL2_PREV_LEGAL"]  = gvMain.GetRowCellValue(i, "PL1_CUR_LEGAL").AsInt();
                    dtInsertPL2.Rows[dtInsertPL2.Rows.Count - 1]["PL2_PREV_999"]    = gvMain.GetRowCellValue(i, "PL1_CUR_999").AsInt();
                    dtInsertPL2.Rows[dtInsertPL2.Rows.Count - 1]["PL2_W_TIME"]      = DateTime.Now;
                    dtInsertPL2.Rows[dtInsertPL2.Rows.Count - 1]["PL2_W_USER_ID"]   = GlobalInfo.USER_ID;
                    if (gvMain.GetRowCellValue(i, "Is_NewRow").AsString() == "1")//add by tom
                    {
                        dtInsertPL2.Rows[dtInsertPL2.Rows.Count - 1]["PL2_999_ADJ"]    = "+";
                        dtInsertPL2.Rows[dtInsertPL2.Rows.Count - 1]["PL2_NATURE_ADJ"] = gvMain.GetRowCellValue(i, "PL1_NATURE_ADJ");
                        dtInsertPL2.Rows[dtInsertPL2.Rows.Count - 1]["PL2_LEGAL_ADJ"]  = gvMain.GetRowCellValue(i, "PL1_LEGAL_ADJ");
                    }
                }
                // 寫入DB
                myResultData = dao30203.updatePL2(dtInsertPL2);

                //4. 新增 PL2B
                showMsg = "確認資料(PL2B)更新資料庫錯誤! ";
                DataTable dtInsertPL2B = dao30203.d_30203_pl2b(ls_ymd);
                for (i = 0; i < gvGBF.RowCount; i++)
                {
                    dtInsertPL2B.Rows.Add();
                    dtInsertPL2B.Rows[dtInsertPL2B.Rows.Count - 1]["PL2B_EFFECTIVE_YMD"]         = ls_eff_ymd;
                    dtInsertPL2B.Rows[dtInsertPL2B.Rows.Count - 1]["PL2B_YMD"]                   = ls_ymd;
                    dtInsertPL2B.Rows[dtInsertPL2B.Rows.Count - 1]["PL2B_PROD_TYPE"]             = gvGBF.GetRowCellValue(i, "PL1B_PROD_TYPE");
                    dtInsertPL2B.Rows[dtInsertPL2B.Rows.Count - 1]["PL2B_PROD_SUBTYPE"]          = gvGBF.GetRowCellValue(i, "PL1B_PROD_SUBTYPE");
                    dtInsertPL2B.Rows[dtInsertPL2B.Rows.Count - 1]["PL2B_KIND_ID"]               = gvGBF.GetRowCellValue(i, "PL1B_KIND_ID");
                    dtInsertPL2B.Rows[dtInsertPL2B.Rows.Count - 1]["PL2B_NATURE_LEGAL_MTH"]      = gvGBF.GetRowCellValue(i, "PL1B_NATURE_LEGAL_MTH");
                    dtInsertPL2B.Rows[dtInsertPL2B.Rows.Count - 1]["PL2B_NATURE_LEGAL_TOT"]      = gvGBF.GetRowCellValue(i, "PL1B_NATURE_LEGAL_TOT");
                    dtInsertPL2B.Rows[dtInsertPL2B.Rows.Count - 1]["PL2B_999_MTH"]               = gvGBF.GetRowCellValue(i, "PL1B_999_MTH");
                    dtInsertPL2B.Rows[dtInsertPL2B.Rows.Count - 1]["PL2B_999_NEARBY_MTH"]        = gvGBF.GetRowCellValue(i, "PL1B_999_NEARBY_MTH");
                    dtInsertPL2B.Rows[dtInsertPL2B.Rows.Count - 1]["PL2B_999_TOT"]               = gvGBF.GetRowCellValue(i, "PL1B_999_TOT");
                    dtInsertPL2B.Rows[dtInsertPL2B.Rows.Count - 1]["PL2B_PREV_NATURE_LEGAL_MTH"] = gvGBF.GetRowCellValue(i, "PL1B_PREV_NATURE_LEGAL_MTH");
                    dtInsertPL2B.Rows[dtInsertPL2B.Rows.Count - 1]["PL2B_PREV_NATURE_LEGAL_TOT"] = gvGBF.GetRowCellValue(i, "PL1B_PREV_NATURE_LEGAL_TOT");
                    dtInsertPL2B.Rows[dtInsertPL2B.Rows.Count - 1]["PL2B_PREV_999_MTH"]          = gvGBF.GetRowCellValue(i, "PL1B_PREV_999_MTH");
                    dtInsertPL2B.Rows[dtInsertPL2B.Rows.Count - 1]["PL2B_PREV_999_NEARBY_MTH"]   = gvGBF.GetRowCellValue(i, "PL1B_PREV_999_NEARBY_MTH");
                    dtInsertPL2B.Rows[dtInsertPL2B.Rows.Count - 1]["PL2B_PREV_999_TOT"]          = gvGBF.GetRowCellValue(i, "PL1B_PREV_999_TOT");
                    dtInsertPL2B.Rows[dtInsertPL2B.Rows.Count - 1]["PL2B_ADJ"]                   = gvGBF.GetRowCellValue(i, "PL1B_ADJ");
                    dtInsertPL2B.Rows[dtInsertPL2B.Rows.Count - 1]["PL2B_W_TIME"]                = DateTime.Now;
                    dtInsertPL2B.Rows[dtInsertPL2B.Rows.Count - 1]["PL2B_W_USER_ID"]             = GlobalInfo.USER_ID;
                }
                // 寫入DB
                myResultData = dao30203.updatePL2B(dtInsertPL2B);

                //5. 更新 PL1 (gvMain資料,gvGBF不需寫入DB)
                showMsg = "確認資料(PL1)更新資料庫錯誤! ";
                DataTable dtPL1 = gcMain.DataSource as DataTable;
                if (PL1NewRowCount > 0)
                {
                    for (int x = 0; x < PL1NewRowCount; x++)
                    {
                        dtPL1.Rows[dtPL1.Rows.Count - 1].Delete();
                    }
                }
                myResultData = dao30203.updatePL1(dtPL1);
                //add by Tom
                if (PL1NewRowCount > 0)
                {
                    showMsg      = "確認資料(PL1)更新資料庫錯誤(Insert)! ";
                    myResultData = dao30203.updatePL1(dtPL1Insert);
                }
                //end add by Tom
            } catch (Exception ex) {
                MessageDisplay.Error(showMsg);
                WriteLog(ex);
            }
            return(ResultStatus.Success);
        }
        protected override ResultStatus Retrieve()
        {
            try {
                gcMain.DataSource = null;

                dao30203 = new D30203();
                string lsYmd;
                int    found;
                lsYmd = txtDate.Text.Replace("/", "");

                DataTable dt30203 = dao30203.d_30203(lsYmd);
                if (dt30203.Rows.Count == 0)
                {
                    MessageDisplay.Info("PL1無任何資料!");
                }
                else
                {
                    dt30203.Columns.Add("Is_NewRow", typeof(string));
                    gcMain.DataSource = dt30203;
                    gcMain.Visible    = true;
                    gcMain.Focus();
                }

                DataTable dt30203gbf = dao30203.d_30203_gbf();
                if (dt30203gbf.Rows.Count == 0)
                {
                    MessageDisplay.Info("PL1B無任何資料!");
                    return(ResultStatus.Fail);
                }
                gcGBF.DataSource = dt30203gbf;

                //公告日期
                DataTable dtPostDate = dao30203.PostDate(lsYmd);
                if (dtPostDate.Rows.Count == 0)
                {
                    MessageDisplay.Info("公告日期無任何資料!");
                    return(ResultStatus.Fail);
                }
                if (dtPostDate.Rows[0]["RAISE_YMD"].AsDateTime("yyyyMMdd") != default(DateTime))
                {
                    txtEffDate.DateTimeValue      = dtPostDate.Rows[0]["RAISE_YMD"].AsDateTime("yyyyMMdd");
                    txtEffDateLower.DateTimeValue = dtPostDate.Rows[0]["LOWER_YMD"].AsDateTime("yyyyMMdd");
                    lblEff.Text = "(已確認)";
                }
                else
                {
                    lblEff.Text = "";
                }

                DataTable dt30203PL2 = dao30203.d_30203_pl2(lsYmd);
                if (dt30203PL2.Rows.Count == 0)
                {
                    MessageDisplay.Info("PL2無任何資料!");
                    return(ResultStatus.Fail);
                }

                if (dtPostDate.Rows[0]["LI_COUNT"].AsInt() <= 0)
                {
                    return(ResultStatus.Fail);
                }
                DialogResult result = MessageDisplay.Choose("已確認資料,按「是」讀取已存檔資料,按「否」為重新產製資料");
                if (result == DialogResult.No)
                {
                    return(ResultStatus.Fail);
                }

                foreach (DataRow dr in dt30203PL2.Rows)
                {
                    //此時gridview的資料還沒被動過,原本要在gridview中查找(datawindow.find)的資料直接在datasource查找即可
                    DataRow[] find = dt30203.Select("PL1_KIND_ID='" + dr["PL2_KIND_ID"].ToString() + "'");
                    if (find.Length > 0)
                    {
                        found = dt30203.Rows.IndexOf(find[0]);
                    }
                    else
                    {
                        found = -1;
                    }
                    if (found == -1)
                    {
                        InsertRow();
                        found = gvMain.RowCount;
                    }

                    if (dr["PL2_EFFECTIVE_YMD"].AsString() == dtPostDate.Rows[0]["LOWER_YMD"].AsString())
                    {
                        gvMain.SetRowCellValue(found, "PL1_NATURE_ADJ", "-");
                    }
                    gvMain.SetRowCellValue(found, "PL1_YMD", dr["PL2_YMD"].AsString());
                    gvMain.SetRowCellValue(found, "PL1_KIND_ID", dr["PL2_KIND_ID"].ToString());
                    gvMain.SetRowCellValue(found, "PL1_NATURE", dr["PL2_NATURE"]);
                    gvMain.SetRowCellValue(found, "PL1_LEGAL", dr["PL2_LEGAL"]);
                    gvMain.SetRowCellValue(found, "PL1_999", dr["PL2_999"]);
                    gvMain.SetRowCellValue(found, "PL1_NATURE_ADJ", dr["PL2_NATURE_ADJ"].ToString());
                    gvMain.SetRowCellValue(found, "PL1_LEGAL_ADJ", dr["PL2_LEGAL_ADJ"].ToString());
                    gvMain.SetRowCellValue(found, "PL1_999_ADJ", dr["PL2_999_ADJ"].ToString());
                    gvMain.SetRowCellValue(found, "PL1_CUR_NATURE", dr["PL2_PREV_NATURE"]);
                    gvMain.SetRowCellValue(found, "PL1_CUR_LEGAL", dr["PL2_PREV_LEGAL"]);
                    gvMain.SetRowCellValue(found, "PL1_CUR_999", dr["PL2_PREV_999"]);
                }

                DataTable dt30203PL2B = dao30203.d_30203_pl2b(lsYmd);
                if (dt30203PL2B.Rows.Count == 0)
                {
                    MessageDisplay.Info("PL2B無任何資料!");
                    return(ResultStatus.Fail);
                }
                foreach (DataRow dr in dt30203PL2B.Rows)
                {
                    //此時gridview的資料還沒被動過,原本要在gridview中查找(datawindow.find)的資料直接在datasource查找即可
                    DataRow[] find = dt30203gbf.Select("PL1B_KIND_ID='" + dr["PL2B_KIND_ID"].ToString() + "'");
                    if (find.Length > 0)
                    {
                        found = dt30203gbf.Rows.IndexOf(find[0]);
                        gvGBF.SetRowCellValue(found, "PL1B_PROD_TYPE", dr["PL2B_PROD_TYPE"].AsString());
                        gvGBF.SetRowCellValue(found, "PL1B_PROD_SUBTYPE", dr["PL2B_PROD_SUBTYPE"].AsString());
                        gvGBF.SetRowCellValue(found, "PL1B_KIND_ID", dr["PL2B_KIND_ID"].ToString());
                        gvGBF.SetRowCellValue(found, "PL1B_NATURE_LEGAL_MTH", dr["PL2B_NATURE_LEGAL_MTH"].AsInt());
                        gvGBF.SetRowCellValue(found, "PL1B_NATURE_LEGAL_TOT", dr["PL2B_NATURE_LEGAL_TOT"].AsInt());
                        gvGBF.SetRowCellValue(found, "PL1B_999_MTH", dr["PL2B_999_MTH"].AsInt());
                        gvGBF.SetRowCellValue(found, "PL1B_999_NEARBY_MTH", dr["PL2B_999_NEARBY_MTH"].AsInt());
                        gvGBF.SetRowCellValue(found, "PL1B_999_TOT", dr["PL2B_999_TOT"].AsInt());
                        gvGBF.SetRowCellValue(found, "PL1B_PREV_NATURE_LEGAL_MTH", dr["PL2B_PREV_NATURE_LEGAL_MTH"].AsInt());
                        gvGBF.SetRowCellValue(found, "PL1B_PREV_NATURE_LEGAL_TOT", dr["PL2B_PREV_NATURE_LEGAL_TOT"].AsInt());
                        gvGBF.SetRowCellValue(found, "PL1B_PREV_999_MTH", dr["PL2B_PREV_999_MTH"].AsInt());
                        gvGBF.SetRowCellValue(found, "PL1B_PREV_999_NEARBY_MTH", dr["PL2B_PREV_999_NEARBY_MTH"].AsInt());
                        gvGBF.SetRowCellValue(found, "PL1B_PREV_999_TOT", dr["PL2B_PREV_999_TOT"].AsInt());
                        gvGBF.SetRowCellValue(found, "PL1B_ADJ", dr["PL2B_ADJ"].ToString());
                    }
                }
            } catch (Exception ex) {
                WriteLog(ex);
            }

            return(ResultStatus.Success);
        }