Beispiel #1
0
 public W30222(string programID, string programName) : base(programID, programName)
 {
     InitializeComponent();
     this.Text = _ProgramID + "─" + _ProgramName;
     GridHelper.SetCommonGrid(gvMain);
     dao30222 = new D30222();
     dao30203 = new D30203();
     dao30221 = new D30221();
 }
        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);
        }