Пример #1
0
        protected override ResultStatus Save(PokeBall pokeBall)
        {
            try {
                #region ue_save_before
                gvMain.CloseEditor();
                gvMain.UpdateCurrentRow();

                string   stockID, ymd, kindID, adjTypeName, opType, dbname, stockIDCk;
                string   issueBeginYmd, tradeYmd, mocfYmd, nextYmd, level, currencyType;
                int      currRow, found, count, row, col, prodSeq;
                decimal  ldblRate;
                DateTime ldtWTIME = DateTime.Now;

                DataTable dtGrid = (DataTable)gcMain.DataSource;
                found = dtGrid.Rows.IndexOf(dtGrid.Select("OP_TYPE <> ' '").FirstOrDefault());
                if (found + dtDel.Rows.Count == -1)
                {
                    MessageDisplay.Warning("沒有變更資料,不需要存檔!");
                    return(ResultStatus.FailButNext);
                }
                DataTable dtMGD2;                             //ids_mgd2
                DataTable dtMGD2Log = dao40071.d_40071_log(); //ids_old
                dtMGD2Log.Clear();                            //只取schema

                this.ymd      = txtSDate.DateTimeValue.ToString("yyyyMMdd");
                issueBeginYmd = this.ymd;
                dtMGD2        = dao40071.d_40071(this.ymd, isAdjType);

                foreach (DataRow dr in dtGrid.Rows)
                {
                    if (dr.RowState == DataRowState.Deleted)
                    {
                        continue;
                    }
                    opType  = dr["OP_TYPE"].ToString();
                    stockID = dr["STOCK_ID"].AsString();
                    kindID  = dr["KIND_ID"].AsString();
                    level   = dr["M_LEVEL"].AsString();

                    //檢查調整後級距為從其高且商品類別為選擇權時,是否有輸入保證金B值
                    if (level == "Z" && dr["PROD_TYPE"].AsString() == "O")
                    {
                        if (dr["CM_B"] == DBNull.Value || dr["MM_B"] == DBNull.Value || dr["IM_B"] == DBNull.Value)
                        {
                            MessageDisplay.Error(stockID + "," + kindID + "的保證金B值未輸入完成");
                            return(ResultStatus.FailButNext);
                        }
                    }

                    //檢查有異動的資料
                    if (opType != " ")
                    {
                        //資料修改,將修改前舊資料寫入log
                        if (opType == "U")
                        {
                            dtMGD2.Filter("mgd2_kind_id = '" + kindID + "'");
                            foreach (DataRow drU in dtMGD2.Rows)
                            {
                                currRow = dtMGD2Log.Rows.Count;
                                dtMGD2Log.Rows.Add();
                                for (col = 0; col < dtMGD2.Columns.Count; col++)
                                {
                                    //先取欄位名稱,因為兩張table欄位順序不一致
                                    dbname = dtMGD2.Columns[col].ColumnName;
                                    if (dbname == "CPSORT")
                                    {
                                        continue;            //這個欄位是拿來排序用的,故無需複製
                                    }
                                    dtMGD2Log.Rows[currRow][dbname] = drU[col];
                                }
                                dtMGD2Log.Rows[currRow]["MGD2_L_TYPE"]    = "U";
                                dtMGD2Log.Rows[currRow]["MGD2_L_USER_ID"] = GlobalInfo.USER_ID;
                                dtMGD2Log.Rows[currRow]["MGD2_L_TIME"]    = ldtWTIME;
                            }
                        }

                        /*******************************************
                        *  檢查商品與類別是否符合
                        *******************************************/
                        prodSeq = dao40074.getProd(kindID, dr["PROD_SUBTYPE"].AsString());
                        if (prodSeq != dr["PROD_SEQ_NO"].AsInt())
                        {
                            MessageDisplay.Error(kindID + "與商品類別不符,請確認");
                            return(ResultStatus.FailButNext);
                        }

                        /*****************************************
                         * 檢查商品代號是否存在及相關資料是否正確
                         ******************************************/
                        DataTable dtCheck = dao40074.checkProd(kindID);
                        if (dtCheck.Rows.Count == 0)
                        {
                            MessageDisplay.Error(kindID + "不存在,請重新設定商品代號");
                            return(ResultStatus.FailButNext);
                        }
                        count        = dtCheck.Rows[0]["LI_COUNT"].AsInt();
                        currencyType = dtCheck.Rows[0]["LS_CURRENCY_TYPE"].AsString();
                        stockIDCk    = dtCheck.Rows[0]["LS_STOCK_ID_CK"].AsString();

                        if (count == 0)
                        {
                            MessageDisplay.Error(kindID + "不存在,請重新設定商品代號");
                            return(ResultStatus.FailButNext);
                        }
                        else
                        {
                            if (dr["CURRENCY_TYPE"].AsString() != currencyType)
                            {
                                MessageDisplay.Error(kindID + "的幣別設定錯誤,請重新設定填寫");
                                return(ResultStatus.FailButNext);
                            }
                            if (dr["prod_subtype"].AsString() == "S" && stockID != stockIDCk)
                            {
                                MessageDisplay.Error(kindID + "的股票代號設定錯誤,請重新設定填寫");
                                return(ResultStatus.FailButNext);
                            }
                        }

                        /******************************************
                        *  確認商品是否在同一交易日不同情境下設定過
                        ******************************************/
                        DataTable dtSet = dao40071.IsSetOnSameDay(kindID, this.ymd, isAdjType);
                        if (dtSet.Rows.Count == 0)
                        {
                            MessageDisplay.Info("MGD2 " + kindID + " 無任何資料!");
                            return(ResultStatus.FailButNext);
                        }
                        count       = dtSet.Rows[0]["LI_COUNT"].AsInt();
                        adjTypeName = dtSet.Rows[0]["LS_ADJ_TYPE_NAME"].AsString();
                        if (count > 0)
                        {
                            MessageDisplay.Error(kindID + ",交易日(" + this.ymd + ")在" + adjTypeName + "已有資料");
                            return(ResultStatus.FailButNext);
                        }

                        /*********************************
                         * 確認商品是否在同一生效日區間設定過
                         * 生效起日若與生效迄日相同,不重疊
                         * ex: 10/11的至10/31一般交易時段結束止,10/30的從10/31一般交易時段結束後始>>應不重疊
                         *************************************/
                        dtSet       = dao40071.IsSetInSameSession(kindID, this.ymd, issueBeginYmd);
                        count       = dtSet.Rows[0]["LI_COUNT"].AsInt();
                        adjTypeName = dtSet.Rows[0]["LS_ADJ_TYPE_NAME"].AsString();
                        tradeYmd    = dtSet.Rows[0]["LS_TRADE_YMD"].AsString();
                        if (count > 0)
                        {
                            MessageDisplay.Error(kindID + "," + adjTypeName + ",交易日(" + tradeYmd + ")在同一生效日區間內已有資料");
                            return(ResultStatus.FailButNext);
                        }
                    } //if (ls_op_type != " ")
                }     //foreach (DataRow dr in dtGrid.Rows)

                //把刪除的資料寫進log
                foreach (DataRow drDel in dtDel.Rows)
                {
                    kindID = drDel["KIND_ID"].AsString();
                    dtMGD2.Filter("mgd2_kind_id = '" + kindID + "'");
                    foreach (DataRow drD in dtMGD2.Rows)
                    {
                        currRow = dtMGD2Log.Rows.Count;
                        dtMGD2Log.Rows.Add();
                        for (col = 0; col < dtMGD2.Columns.Count; col++)
                        {
                            //先取欄位名稱,因為兩張table欄位順序不一致
                            dbname = dtMGD2.Columns[col].ColumnName;
                            if (dbname == "CPSORT")
                            {
                                continue;              //這個欄位是拿來排序用的,故無需複製
                            }
                            dtMGD2Log.Rows[currRow][dbname] = drD[col];
                        }
                        dtMGD2Log.Rows[currRow]["MGD2_L_TYPE"]    = "D";
                        dtMGD2Log.Rows[currRow]["MGD2_L_USER_ID"] = GlobalInfo.USER_ID;
                        dtMGD2Log.Rows[currRow]["MGD2_L_TIME"]    = ldtWTIME;
                    }
                }
                #endregion

                string    prodType;
                DataTable dtTemp = dao40072.d_40072(); //ids_tmp

                foreach (DataRow dr in dtGrid.Rows)
                {
                    if (dr.RowState == DataRowState.Deleted)
                    {
                        continue;
                    }
                    opType = dr["OP_TYPE"].ToString();
                    //只更新有異動的資料
                    if (opType != " ")
                    {
                        kindID = dr["KIND_ID"].AsString();
                        //stockID = dr["KIND_ID"].AsString();
                        stockID = dr["STOCK_ID"].ToString();

                        //刪除已存在資料
                        if (daoMGD2.DeleteMGD2(this.ymd, isAdjType, stockID, kindID) < 0)
                        {
                            MessageDisplay.Error("MGD2資料刪除失敗");
                            return(ResultStatus.FailButNext);
                        }

                        currRow  = dtTemp.Rows.Count;
                        prodType = dr["PROD_TYPE"].AsString();
                        dtTemp.Rows.Add();
                        dtTemp.Rows[currRow]["MGD2_YMD"]       = this.ymd;
                        dtTemp.Rows[currRow]["MGD2_PROD_TYPE"] = prodType;
                        dtTemp.Rows[currRow]["MGD2_KIND_ID"]   = kindID;
                        dtTemp.Rows[currRow]["MGD2_STOCK_ID"]  = stockID;
                        dtTemp.Rows[currRow]["MGD2_ADJ_TYPE"]  = isAdjType;

                        dtTemp.Rows[currRow]["MGD2_ADJ_CODE"]        = dr["ADJ_CODE"];
                        dtTemp.Rows[currRow]["MGD2_PUB_YMD"]         = dr["PUB_YMD"];
                        dtTemp.Rows[currRow]["MGD2_ISSUE_BEGIN_YMD"] = issueBeginYmd;
                        dtTemp.Rows[currRow]["MGD2_PROD_SUBTYPE"]    = dr["PROD_SUBTYPE"].AsString();
                        dtTemp.Rows[currRow]["MGD2_PARAM_KEY"]       = dr["PARAM_KEY"];

                        dtTemp.Rows[currRow]["MGD2_CUR_CM"]    = 0;
                        dtTemp.Rows[currRow]["MGD2_CUR_MM"]    = 0;
                        dtTemp.Rows[currRow]["MGD2_CUR_IM"]    = 0;
                        dtTemp.Rows[currRow]["MGD2_CUR_LEVEL"] = 0;
                        dtTemp.Rows[currRow]["MGD2_CM"]        = dr["CM_A"];

                        dtTemp.Rows[currRow]["MGD2_MM"]            = dr["MM_A"];
                        dtTemp.Rows[currRow]["MGD2_IM"]            = dr["IM_A"];
                        dtTemp.Rows[currRow]["MGD2_LEVEL"]         = dr["M_LEVEL"];
                        dtTemp.Rows[currRow]["MGD2_CURRENCY_TYPE"] = dr["CURRENCY_TYPE"];
                        dtTemp.Rows[currRow]["MGD2_SEQ_NO"]        = dr["SEQ_NO"];

                        dtTemp.Rows[currRow]["MGD2_OSW_GRP"]   = dr["OSW_GRP"];
                        dtTemp.Rows[currRow]["MGD2_AMT_TYPE"]  = dr["AMT_TYPE"];
                        dtTemp.Rows[currRow]["MGD2_W_TIME"]    = ldtWTIME;
                        dtTemp.Rows[currRow]["MGD2_W_USER_ID"] = GlobalInfo.USER_ID;

                        /******************************
                         *    AB TYTPE:	-期貨
                         *                A選擇權A值
                         *                B選擇權B值
                         *******************************/
                        if (prodType == "F")
                        {
                            dtTemp.Rows[currRow]["MGD2_AB_TYPE"] = "-";
                        }
                        else
                        {
                            dtTemp.Rows[currRow]["MGD2_AB_TYPE"] = "A";
                            //複製一筆一樣的,AB Type分開存
                            dtTemp.ImportRow(dtTemp.Rows[currRow]);
                            //dtTemp.Rows.Add(dtTemp.Rows[ii_curr_row]);//會跳錯
                            currRow = dtTemp.Rows.Count - 1;
                            dtTemp.Rows[currRow]["MGD2_AB_TYPE"] = "B";
                            dtTemp.Rows[currRow]["MGD2_CM"]      = dr["CM_B"];
                            dtTemp.Rows[currRow]["MGD2_MM"]      = dr["MM_B"];
                            dtTemp.Rows[currRow]["MGD2_IM"]      = dr["IM_B"];
                        }
                    } //if (ls_op_type != " ")
                }     //foreach (DataRow dr in dtGrid.Rows)

                //刪除資料
                foreach (DataRow drDel in dtDel.Rows)
                {
                    kindID  = drDel["KIND_ID"].AsString();
                    stockID = drDel["STOCK_ID"].ToString();
                    if (daoMGD2.DeleteMGD2(this.ymd, isAdjType, stockID, kindID) < 0)
                    {
                        MessageDisplay.Error("MGD2資料刪除失敗");
                        return(ResultStatus.FailButNext);
                    }
                }

                //Update DB
                //ids_tmp.update()
                if (dtTemp.Rows.Count > 0)
                {
                    ResultData myResultData = daoMGD2.UpdateMGD2(dtTemp);
                    if (myResultData.Status == ResultStatus.Fail)
                    {
                        MessageDisplay.Error("更新資料庫MGD2錯誤! ");
                        return(ResultStatus.FailButNext);
                    }
                }
                //ids_old.update()
                if (dtMGD2Log.Rows.Count > 0)
                {
                    ResultData myResultData = daoMGD2L.UpdateMGD2L(dtMGD2Log);
                    if (myResultData.Status == ResultStatus.Fail)
                    {
                        MessageDisplay.Error("更新資料庫MGD2L錯誤! ");
                        return(ResultStatus.FailButNext);
                    }
                }
                //Write LOGF
                WriteLog("變更資料 ", "Info", "I");
                //報表儲存pdf
                ReportHelper            _ReportHelper   = new ReportHelper(gcMain, _ProgramID, this.Text);
                CommonReportLandscapeA3 reportLandscape = new CommonReportLandscapeA3();//設定為橫向列印
                reportLandscape.printableComponentContainerMain.PrintableComponent = gcMain;
                reportLandscape.IsHandlePersonVisible = false;
                reportLandscape.IsManagerVisible      = false;
                _ReportHelper.Create(reportLandscape);
                _ReportHelper.Export(FileType.PDF, _ReportHelper.FilePath);
                MessageDisplay.Info("報表儲存完成!");
            } catch (Exception ex) {
                SetSaveFlagValue();
                MessageDisplay.Error("儲存錯誤");
                throw ex;
            }
            SetSaveFlagValue();
            return(ResultStatus.Success);
        }
Пример #2
0
        protected override ResultStatus Save(PokeBall pokeBall)
        {
            try
            {
                if (gvDetail.RowCount == 0)
                {
                    MessageDisplay.Info("沒有變更資料,不需要存檔!");
                    return(ResultStatus.Fail);
                }
                #region ue_save_before
                gvMain.CloseEditor();
                gvMain.UpdateCurrentRow();
                gvDetail.CloseEditor();
                gvDetail.UpdateCurrentRow();

                string   stockID, ymd, kindID, adjTypeName, opType, dbname, flag;
                string   issueBeginYmd, issueEndYmd, implBeginYmd, implEndYmd, pubYmd, tradeYmd, mocfYmd, nextYmd;
                int      found, count, row, col, currRow;
                decimal  ldblRate;
                DateTime ldtWTIME = DateTime.Now;

                DataTable dtGrid = (DataTable)gcDetail.DataSource;
                found = dtGrid.Rows.IndexOf(dtGrid.Select("OP_TYPE <> ' '").FirstOrDefault());
                if (found == -1)
                {
                    MessageDisplay.Warning("沒有變更資料,不需要存檔!");
                    return(ResultStatus.Fail);
                }

                if (dtGrid.Rows.Count == 0)
                {
                    MessageDisplay.Warning("無明細資料,請重新產生明細");
                    return(ResultStatus.FailButNext);
                }

                DataTable dtMGD2;                             //ids_mgd2
                DataTable dtMGD2Log = dao40071.d_40071_log(); //ids_old
                dtMGD2Log.Clear();                            //只取schema

                for (int f = 0; f < dtGrid.Rows.Count; f++)
                {
                    if (dtGrid.Rows[f].RowState == DataRowState.Deleted)
                    {
                        continue;
                    }
                    DataRow dr = dtGrid.Rows[f];
                    opType  = dr["OP_TYPE"].ToString();
                    flag    = dr["DATA_FLAG"].AsString();
                    stockID = dr["STOCK_ID"].AsString();

                    //檢查同一標的的級距是否一致
                    if ((f + 1) < dtGrid.Rows.Count)
                    {
                        if (stockID == dtGrid.Rows[f + 1]["STOCK_ID"].AsString() &&
                            dr["M_CUR_LEVEL"].AsString() != dtGrid.Rows[f + 1]["M_CUR_LEVEL"].AsString())
                        {
                            MessageDisplay.Error(stockID + "的級距不一致");
                            return(ResultStatus.FailButNext);
                        }
                    }

                    //檢查有異動的資料
                    if (opType != " ")
                    {
                        kindID        = dr["KIND_ID"].AsString();
                        ymd           = dr["YMD"].ToString();
                        issueBeginYmd = dr["ISSUE_BEGIN_YMD"].ToString();
                        //issueEndYmd = dr["ISSUE_END_YMD"].ToString(); by tom
                        //implBeginYmd = dr["IMPL_BEGIN_YMD"].ToString();
                        //implEndYmd = dr["IMPL_END_YMD"].ToString();
                        //pubYmd = dr["PUB_YMD"].ToString();
                        issueEndYmd  = dr["ISSUE_END_YMD"].AsString().Replace("/", "");
                        implBeginYmd = dr["IMPL_BEGIN_YMD"].AsString().Replace("/", "");
                        implEndYmd   = dr["IMPL_END_YMD"].AsString().Replace("/", "");
                        pubYmd       = dr["PUB_YMD"].AsString().Replace("/", "");

                        if (ymd != implBeginYmd)
                        {
                            DialogResult result = MessageDisplay.Choose(stockID + "," + kindID + "交易日不等於處置起日,請問是否更新");
                            if (result == DialogResult.No)
                            {
                                return(ResultStatus.FailButNext);
                            }
                        }
                        if (issueEndYmd != implEndYmd)
                        {
                            DialogResult result = MessageDisplay.Choose(stockID + "," + kindID + "生效迄日不等於處置迄日,請問是否更新");
                            if (result == DialogResult.No)
                            {
                                return(ResultStatus.FailButNext);
                            }
                        }

                        //處置期間首日+1個月
                        mocfYmd = PbFunc.relativedate(implBeginYmd.AsDateTime("yyyyMMdd"), 30).ToString("yyyyMMdd");

                        /*次一營業日*/
                        nextYmd = daoMOCF.GetNextTradeDay(implBeginYmd, mocfYmd);
                        if (issueBeginYmd != nextYmd)
                        {
                            DialogResult result = MessageDisplay.Choose(stockID + "," + kindID + "生效起日不等於處置起日之次一營業日,請問是否更新");
                            if (result == DialogResult.No)
                            {
                                return(ResultStatus.FailButNext);
                            }
                        }

                        dtMGD2 = dao40072.d_40072(ymd, isAdjType, stockID);

                        //資料修改,將修改前舊資料寫入log
                        if (opType == "U")
                        {
                            dtMGD2.Filter("mgd2_kind_id = '" + kindID + "'");
                            foreach (DataRow drU in dtMGD2.Rows)
                            {
                                currRow = dtMGD2Log.Rows.Count;
                                dtMGD2Log.Rows.Add();
                                for (col = 0; col < dtMGD2.Columns.Count; col++)
                                {
                                    //先取欄位名稱,因為兩張table欄位順序不一致
                                    dbname = dtMGD2.Columns[col].ColumnName;
                                    if (dbname == "CPSORT")
                                    {
                                        continue;                     //這個欄位是拿來排序用的,故無需複製
                                    }
                                    dtMGD2Log.Rows[currRow][dbname] = drU[col];
                                }
                                if (flag == "Y")
                                {
                                    dtMGD2Log.Rows[currRow]["MGD2_L_TYPE"] = "U";
                                }
                                if (flag == "N")
                                {
                                    dtMGD2Log.Rows[currRow]["MGD2_L_TYPE"] = "D";
                                }
                                dtMGD2Log.Rows[currRow]["MGD2_L_USER_ID"] = GlobalInfo.USER_ID;
                                dtMGD2Log.Rows[currRow]["MGD2_L_TIME"]    = ldtWTIME;
                            }
                        }

                        /******************************************
                        *  確認商品是否在同一交易日不同情境下設定過
                        ******************************************/
                        DataTable dtSet = dao40071.IsSetOnSameDay(kindID, ymd, isAdjType);
                        if (dtSet.Rows.Count == 0)
                        {
                            MessageDisplay.Info("MGD2 " + kindID + " 無任何資料!");
                            return(ResultStatus.FailButNext);
                        }
                        count       = dtSet.Rows[0]["LI_COUNT"].AsInt();
                        adjTypeName = dtSet.Rows[0]["LS_ADJ_TYPE_NAME"].AsString();
                        if (count > 0)
                        {
                            MessageDisplay.Error(kindID + ",交易日(" + ymd + ")在" + adjTypeName + "已有資料");
                            return(ResultStatus.FailButNext);
                        }

                        /*********************************
                         * 確認商品是否在同一生效日區間設定過
                         * 生效起日若與生效迄日相同,不重疊
                         * ex: 10/11的至10/31一般交易時段結束止,10/30的從10/31一般交易時段結束後始>>應不重疊
                         *************************************/
                        dtSet       = dao40071.IsSetInSameSession(kindID, ymd, issueBeginYmd, issueEndYmd);
                        count       = dtSet.Rows[0]["LI_COUNT"].AsInt();
                        adjTypeName = dtSet.Rows[0]["LS_ADJ_TYPE_NAME"].AsString();
                        tradeYmd    = dtSet.Rows[0]["LS_TRADE_YMD"].AsString();
                        if (count > 0)
                        {
                            MessageDisplay.Error(kindID + "," + adjTypeName + ",交易日(" + tradeYmd + ")在同一生效日區間內已有資料");
                            return(ResultStatus.FailButNext);
                        }

                        //判斷調整幅度是否為0
                        //ldblRate = dr["ADJ_RATE"].AsDecimal(); by tom
                        ldblRate = dr["ADJ_RATE"].AsDecimal() - 1;
                        if (ldblRate == 0)
                        {
                            MessageDisplay.Error("商品調整幅度不可為0");
                            return(ResultStatus.FailButNext);
                        }
                    } //if (ls_op_type != " ")
                }     //for (int f = 0; f < dtGrid.Rows.Count; f++)
                #endregion
                string prodType;

                DataTable dtTemp = dao40072.d_40072(); //ids_tmp
                foreach (DataRow dr in dtGrid.Rows)
                {
                    if (dr.RowState == DataRowState.Deleted)
                    {
                        continue;
                    }
                    opType = dr["OP_TYPE"].ToString();
                    //只更新有異動的資料
                    if (opType != " ")
                    {
                        kindID        = dr["KIND_ID"].AsString();
                        stockID       = dr["STOCK_ID"].AsString();
                        issueBeginYmd = dr["ISSUE_BEGIN_YMD"].ToString();
                        //issueEndYmd = dr["ISSUE_END_YMD"].ToString(); by tom
                        //implBeginYmd = dr["IMPL_BEGIN_YMD"].ToString();
                        //implEndYmd = dr["IMPL_END_YMD"].ToString();
                        //pubYmd = dr["PUB_YMD"].ToString();
                        issueEndYmd  = dr["ISSUE_END_YMD"].AsString().Replace("/", "");
                        implBeginYmd = dr["IMPL_BEGIN_YMD"].AsString().Replace("/", "");
                        implEndYmd   = dr["IMPL_END_YMD"].AsString().Replace("/", "");
                        pubYmd       = dr["PUB_YMD"].AsString().Replace("/", "");
                        ymd          = dr["YMD"].ToString();
                        //ldblRate = dr["ADJ_RATE"].AsDecimal();
                        ldblRate = dr["ADJ_RATE"].AsDecimal() - 1;

                        //刪除已存在資料
                        if (daoMGD2.DeleteMGD2(ymd, isAdjType, stockID, kindID) < 0)
                        {
                            MessageDisplay.Error("MGD2資料刪除失敗");
                            return(ResultStatus.FailButNext);
                        }

                        if (dr["DATA_FLAG"].AsString() == "Y")
                        {
                            currRow  = dtTemp.Rows.Count;
                            prodType = dr["PROD_TYPE"].AsString();
                            dtTemp.Rows.Add();
                            dtTemp.Rows[currRow]["MGD2_YMD"]       = ymd;
                            dtTemp.Rows[currRow]["MGD2_PROD_TYPE"] = prodType;
                            dtTemp.Rows[currRow]["MGD2_KIND_ID"]   = kindID;
                            dtTemp.Rows[currRow]["MGD2_STOCK_ID"]  = stockID;
                            dtTemp.Rows[currRow]["MGD2_ADJ_TYPE"]  = isAdjType;

                            dtTemp.Rows[currRow]["MGD2_ADJ_RATE"]        = ldblRate;
                            dtTemp.Rows[currRow]["MGD2_ADJ_CODE"]        = "Y";
                            dtTemp.Rows[currRow]["MGD2_ISSUE_BEGIN_YMD"] = issueBeginYmd;
                            dtTemp.Rows[currRow]["MGD2_ISSUE_END_YMD"]   = issueEndYmd;
                            dtTemp.Rows[currRow]["MGD2_IMPL_BEGIN_YMD"]  = implBeginYmd;

                            dtTemp.Rows[currRow]["MGD2_IMPL_END_YMD"] = implEndYmd;
                            dtTemp.Rows[currRow]["MGD2_PUB_YMD"]      = pubYmd;
                            dtTemp.Rows[currRow]["MGD2_PROD_SUBTYPE"] = dr["PROD_SUBTYPE"];
                            dtTemp.Rows[currRow]["MGD2_PARAM_KEY"]    = dr["PARAM_KEY"];
                            dtTemp.Rows[currRow]["MGD2_CUR_CM"]       = dr["CM_CUR_A"];

                            dtTemp.Rows[currRow]["MGD2_CUR_MM"]    = dr["MM_CUR_A"];
                            dtTemp.Rows[currRow]["MGD2_CUR_IM"]    = dr["IM_CUR_A"];
                            dtTemp.Rows[currRow]["MGD2_CUR_LEVEL"] = dr["M_CUR_LEVEL"];
                            dtTemp.Rows[currRow]["MGD2_CM"]        = dr["CM_A"];
                            dtTemp.Rows[currRow]["MGD2_MM"]        = dr["MM_A"];

                            dtTemp.Rows[currRow]["MGD2_IM"]            = dr["IM_A"];
                            dtTemp.Rows[currRow]["MGD2_CURRENCY_TYPE"] = dr["CURRENCY_TYPE"];
                            dtTemp.Rows[currRow]["MGD2_SEQ_NO"]        = dr["SEQ_NO"];
                            dtTemp.Rows[currRow]["MGD2_OSW_GRP"]       = dr["OSW_GRP"];
                            dtTemp.Rows[currRow]["MGD2_AMT_TYPE"]      = dr["AMT_TYPE"];

                            dtTemp.Rows[currRow]["MGD2_W_TIME"]    = ldtWTIME;
                            dtTemp.Rows[currRow]["MGD2_W_USER_ID"] = GlobalInfo.USER_ID;

                            /******************************
                             *    AB TYTPE:	-期貨
                             *                A選擇權A值
                             *                B選擇權B值
                             *******************************/
                            if (prodType == "F")
                            {
                                dtTemp.Rows[currRow]["MGD2_AB_TYPE"] = "-";
                            }
                            else
                            {
                                dtTemp.Rows[currRow]["MGD2_AB_TYPE"] = "A";
                                //複製一筆一樣的,AB Type分開存
                                dtTemp.ImportRow(dtTemp.Rows[currRow]);
                                //dtTemp.Rows.Add(dtTemp.Rows[ii_curr_row]);//會跳錯
                                currRow = dtTemp.Rows.Count - 1;
                                dtTemp.Rows[currRow]["MGD2_AB_TYPE"] = "B";
                                dtTemp.Rows[currRow]["MGD2_CUR_CM"]  = dr["CM_CUR_B"];
                                dtTemp.Rows[currRow]["MGD2_CUR_MM"]  = dr["MM_CUR_B"];
                                dtTemp.Rows[currRow]["MGD2_CUR_IM"]  = dr["IM_CUR_B"];
                                dtTemp.Rows[currRow]["MGD2_CM"]      = dr["CM_B"];

                                dtTemp.Rows[currRow]["MGD2_MM"] = dr["MM_B"];
                                dtTemp.Rows[currRow]["MGD2_IM"] = dr["IM_B"];
                            }
                        } //if (dr["DATA_FLAG"].AsString()=="Y")
                    }     //if (ls_op_type != " ")
                }         //foreach (DataRow dr in dtGrid.Rows)

                //Update DB
                //ids_tmp.update()
                if (dtTemp.Rows.Count > 0)
                {
                    ResultData myResultData = daoMGD2.UpdateMGD2(dtTemp);
                    if (myResultData.Status == ResultStatus.Fail)
                    {
                        MessageDisplay.Error("更新資料庫MGD2錯誤! ");
                        return(ResultStatus.FailButNext);
                    }
                }
                //ids_old.update()
                if (dtMGD2Log.Rows.Count > 0)
                {
                    ResultData myResultData = daoMGD2L.UpdateMGD2L(dtMGD2Log);
                    if (myResultData.Status == ResultStatus.Fail)
                    {
                        MessageDisplay.Error("更新資料庫MGD2L錯誤! ");
                        return(ResultStatus.FailButNext);
                    }
                }
                //Write LOGF
                WriteLog("變更資料 ", "Info", "I");
                //報表儲存pdf
                ReportHelper            _ReportHelper   = new ReportHelper(gcDetail, _ProgramID, this.Text);
                CommonReportLandscapeA3 reportLandscape = new CommonReportLandscapeA3();//設定為橫向列印
                reportLandscape.printableComponentContainerMain.PrintableComponent = gcDetail;
                reportLandscape.IsHandlePersonVisible = false;
                reportLandscape.IsManagerVisible      = false;
                _ReportHelper.Create(reportLandscape);
                _ReportHelper.Export(FileType.PDF, _ReportHelper.FilePath);
                MessageDisplay.Info("報表儲存完成!");
            }
            catch (Exception ex)
            {
                MessageDisplay.Error("儲存錯誤");
                throw ex;
            }
            return(ResultStatus.Success);
        }