public bool UpdateDisCRMRecord(
            DataTable dtDisMain, 
            DataTable dtDisItemNew, DataTable dtDisItemOld,
            DataTable dtDisStoreNew, DataTable dtDisStoreOld,
            string strDIS_NO,
            DbTransaction RootDBT)
        {
            #region

            bool bResult = false;
            bool IsRootTranscation = false;
            ArrayList ParameterList = new ArrayList();
            DataCompare dc = new DataCompare();
            DataTable dtDisMainDiff = null;

            DataTable dtDisItemDiff = null;
            DataTable dtDisItemAdd = null;
            DataTable dtDisItemDelete = null;

            DataTable dtDisStoreDiff = null;
            DataTable dtDisStoreAdd = null;
            DataTable dtDisStoreDelete = null;

            try
            {
                //判斷是否有傳入Root Transcation 
                IsRootTranscation = (RootDBT == null) ? true : false;


                #region 啟動交易或指定RootTranscation

                //4.1) 控制 Begin Transaction
                if (IsRootTranscation)
                {
                    //獨立呼叫啟動Transcation
                    Conn = USEDB.CreateConnection();
                    Conn.Open();
                    DBT = Conn.BeginTransaction();
                }
                else
                {
                    DBT = RootDBT;
                }

                #endregion

                #region biz logical


                #region 4.2) 更新配本主檔並記

                if (dtDisMain != null && dtDisMain.Rows.Count > 0)
                {
                    MaintainDisMain BCODisMain = new MaintainDisMain(ConnectionDB);
                    bResult = BCODisMain.UpdateDisMainFor111(dtDisMain, DBT);
                }
                else
                {
                    bResult = true;
                }

                if (!bResult)
                    throw new Exception(string.Format("MaintainDisCRMRecord.UpdateDisMainFor111:Step{0} 發生錯誤", "4.2"));
                #endregion

                #region 4.3) 更新配本商品與配本通路

                #region 比較新舊值
                dc.Clear();
                dc.CompareA = dtDisItemNew;
                dc.CompareB = dtDisItemOld;
                dc.CompareField.AddCompareFieldRow("DIS_NO", "", true);
                dc.CompareField.AddCompareFieldRow("ITEM", "", true);
                dc.CompareField.AddCompareFieldRow("PERIOD", "", true);
                dc.CompareField.AddCompareFieldRow("INCLUDE_NON_EFF", "", false);
                dc.CompareData();

                dtDisItemDiff = dc.ADiff;
                dtDisItemAdd = dc.AOnly;
                dtDisItemDelete = dc.BOnly;

                #endregion

                //處理新增  
                if (dtDisItemAdd != null && dtDisItemAdd.Rows.Count > 0)
                {
                    #region
                    MaintainDisItem BCODisItem = new MaintainDisItem(ConnectionDB);
                    MaintainDisChan BCODisChan = new MaintainDisChan(ConnectionDB);

                    bResult = BCODisItem.CreateDisItem(dtDisItemAdd, strDIS_NO, DBT);
                    if (!bResult)
                        throw new Exception(string.Format("MaintainDisItem.CreateDisItem:Step{0} 發生錯誤", "4.3"));


                    foreach (DataRow dr in dtDisItemAdd.Rows)
                    {
                        ParameterList.Clear();
                        ParameterList.Add(strDIS_NO);
                        ParameterList.Add(dr["ITEM"]);
                        ParameterList.Add(dr["PERIOD"]);
                        ParameterList.Add(dtDisMain.Rows[0]["RCHAN_NO"]);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(dr["CREATEDATE"]);
                        ParameterList.Add(dr["CREATEUID"]);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(dtDisMain.Rows[0]["ST_ACCEPT_DATE"]);
                        bResult = BCODisChan.CreateDisChan(ParameterList, DBT);

                        if (!bResult)
                            throw new Exception(string.Format("MaintainDisChan.CreateDisChan:Step{0} 發生錯誤", "4.3"));
                    }
                }
                else
                {
                    bResult = true;
                    #endregion
                }

                //處理更新  
                if (dtDisItemDiff != null && dtDisItemDiff.Rows.Count > 0)
                {
                    #region
                    MaintainDisItem BCODisItem = new MaintainDisItem(ConnectionDB);
                    MaintainDisChan BCODisChan = new MaintainDisChan(ConnectionDB);

                    bResult = BCODisItem.UpdateDisItemFor111(dtDisItemDiff, DBT);

                    if (!bResult)
                        throw new Exception(string.Format("MaintainDisItem.UpdateDisItemFor111:Step{0} 發生錯誤", "4.3"));


                    foreach (DataRow dr in dtDisItemDiff.Rows)
                    {
                        ParameterList.Clear();
                        //new
                        ParameterList.Add(dr["CODE", DataRowVersion.Current]);
                        ParameterList.Add(dr["UPDATEDATE", DataRowVersion.Current]);
                        ParameterList.Add(dr["UPDATEUID", DataRowVersion.Current]);
                        ParameterList.Add(dr["DIS_NO", DataRowVersion.Current]);
                        ParameterList.Add(dr["ITEM", DataRowVersion.Current]);
                        ParameterList.Add(dr["PERIOD", DataRowVersion.Current]);
                        ParameterList.Add(dr["CHAN_NO", DataRowVersion.Current]);
                        ParameterList.Add(dr["PLAN_RETURN_DATE", DataRowVersion.Current]);
                        ParameterList.Add(dr["DIS_TYPE", DataRowVersion.Current]);
                        ParameterList.Add(dr["PATTERN_NO", DataRowVersion.Current]);
                        ParameterList.Add(dr["DIS_BRATE", DataRowVersion.Current]);
                        ParameterList.Add(dr["DIS_STO_CQTY", DataRowVersion.Current]);
                        ParameterList.Add(dr["DIS_PRE_CQTY", DataRowVersion.Current]);
                        ParameterList.Add(dr["DIS_TOT_QTY", DataRowVersion.Current]);
                        ParameterList.Add(dr["DIS_TOT_OQTY", DataRowVersion.Current]);
                        ParameterList.Add(dr["DIS_TOT_PQTY", DataRowVersion.Current]);
                        ParameterList.Add(dr["IS_LOCK", DataRowVersion.Current]);
                        //old
                        ParameterList.Add(dr["ID", DataRowVersion.Original]);
                        ParameterList.Add(dr["CODE", DataRowVersion.Original]);
                        ParameterList.Add(dr["CREATEDATE", DataRowVersion.Original]);
                        ParameterList.Add(dr["CREATEUID", DataRowVersion.Original]);
                        ParameterList.Add(dr["UPDATEDATE", DataRowVersion.Original]);
                        ParameterList.Add(dr["UPDATEUID", DataRowVersion.Original]);
                        ParameterList.Add(dr["DIS_NO", DataRowVersion.Original]);
                        ParameterList.Add(dr["ITEM", DataRowVersion.Original]);
                        ParameterList.Add(dr["PERIOD", DataRowVersion.Original]);
                        ParameterList.Add(dr["CHAN_NO", DataRowVersion.Original]);
                        ParameterList.Add(dr["PLAN_RETURN_DATE", DataRowVersion.Original]);
                        ParameterList.Add(dr["DIS_TYPE", DataRowVersion.Original]);
                        ParameterList.Add(dr["PATTERN_NO", DataRowVersion.Original]);
                        ParameterList.Add(dr["DIS_BRATE", DataRowVersion.Original]);
                        ParameterList.Add(dr["DIS_STO_CQTY", DataRowVersion.Original]);
                        ParameterList.Add(dr["DIS_PRE_CQTY", DataRowVersion.Original]);
                        ParameterList.Add(dr["DIS_TOT_QTY", DataRowVersion.Original]);
                        ParameterList.Add(dr["DIS_TOT_OQTY", DataRowVersion.Original]);
                        ParameterList.Add(dr["DIS_TOT_PQTY", DataRowVersion.Original]);
                        ParameterList.Add(dr["IS_LOCK", DataRowVersion.Original]);

                        bResult = BCODisChan.UpdateDisChan(ParameterList, DBT);

                        if (!bResult)
                            throw new Exception(string.Format("MaintainDisChan.UpdateDisChan:Step{0} 發生錯誤", "4.3"));
                    }
                }
                else
                {
                    bResult = true;
                    #endregion
                }

                //處理刪除  
                if (dtDisItemDelete != null && dtDisItemDelete.Rows.Count > 0)
                {
                    #region
                    MaintainDisItem BCODisItem = new MaintainDisItem(ConnectionDB);

                    foreach (DataRow dr in dtDisItemDelete.Rows)
                    {
                        #region old
                        //ParameterList.Clear();
                        //ParameterList.Add(dr["ID", DataRowVersion.Original]);
                        //ParameterList.Add(dr["CODE", DataRowVersion.Original]);
                        //ParameterList.Add(dr["CREATEDATE", DataRowVersion.Original]);
                        //ParameterList.Add(dr["CREATEUID", DataRowVersion.Original]);
                        //ParameterList.Add(dr["UPDATEDATE", DataRowVersion.Original]);
                        //ParameterList.Add(dr["UPDATEUID", DataRowVersion.Original]);
                        //ParameterList.Add(dr["DIS_NO", DataRowVersion.Original]);
                        //ParameterList.Add(dr["ITEM", DataRowVersion.Original]);
                        //ParameterList.Add(dr["PERIOD", DataRowVersion.Original]);
                        //ParameterList.Add(dtDisMain.Rows[0]["RCHAN_NO"]);
                        //ParameterList.Add(dr["MEMO", DataRowVersion.Original]);

                        //bResult = BCODisItem.DeleteDisCRMItem(ParameterList, DBT);

                        //if (!bResult)
                        //    throw new Exception(string.Format("MaintainDisItem.DeleteDisCRMItem:Step{0} 發生錯誤", "4.3"));
                        #endregion

                        //20090930 modified
                        ParameterList.Clear();
                        ParameterList.Add(dr["UPDATEDATE", DataRowVersion.Original]);
                        ParameterList.Add(dr["UPDATEUID", DataRowVersion.Original]);
                        ParameterList.Add(dr["DIS_NO", DataRowVersion.Original]);
                        ParameterList.Add(dr["ITEM", DataRowVersion.Original]);
                        ParameterList.Add(dr["PERIOD", DataRowVersion.Original]);
                        bResult = BCODisItem.DeleteDisItemFor111(ParameterList, DBT);

                        if (!bResult)
                            throw new Exception(string.Format("MaintainDisItem.DeleteDisItemFor111:Step{0} 發生錯誤", "4.3"));
                    }
                }
                else
                {
                    bResult = true;
                    #endregion
                }


                #endregion

                #region 4.4) 更新配本門市檔

                #region 比較新舊值
                dc.Clear();
                dc.CompareA = dtDisStoreNew;
                dc.CompareB = dtDisStoreOld;
                dc.CompareField.AddCompareFieldRow("CODE", "", true);
                dc.CompareField.AddCompareFieldRow("ROUTE", "", false);
                dc.CompareField.AddCompareFieldRow("STEP", "", false);
                dc.CompareField.AddCompareFieldRow("DIS_QTY", "", false);
                dc.CompareData();

                dtDisStoreDiff = dc.ADiff;
                dtDisStoreAdd = dc.AOnly;
                dtDisStoreDelete = dc.BOnly;

                #endregion

                //處理新增  
                if (dtDisStoreAdd != null && dtDisStoreAdd.Rows.Count > 0)
                {
                    #region
                    MaintainDisStore BCODisStore = new MaintainDisStore(ConnectionDB);

                    foreach (DataRow dr in dtDisStoreAdd.Rows)
                    {

                        ParameterList.Clear();
                        ParameterList.Add(dr["CODE", DataRowVersion.Current]);
                        ParameterList.Add(dr["UPDATEDATE", DataRowVersion.Current]);
                        ParameterList.Add(dr["UPDATEUID", DataRowVersion.Current]);
                        ParameterList.Add(dr["DIS_NO", DataRowVersion.Current]);
                        ParameterList.Add(dr["ITEM", DataRowVersion.Current]);
                        ParameterList.Add(dr["PERIOD", DataRowVersion.Current]);
                        ParameterList.Add(dr["CHAN_NO", DataRowVersion.Current]);
                        ParameterList.Add(dr["STORE", DataRowVersion.Current]);
                        ParameterList.Add(dr["DIS_QTY", DataRowVersion.Current]);
                        ParameterList.Add(dr["PO_SOURCE_NO", DataRowVersion.Current]);
                        ParameterList.Add(dtDisMain.Rows[0]["ST_ACCEPT_DATE"]);
                        bResult = BCODisStore.CreateDisCRMStore(ParameterList, DBT);

                        if (!bResult)
                            throw new Exception(string.Format("MaintainDisStore.CreateDisCRMStore:Step{0} 發生錯誤", "4.4"));
                    
                    }
                }
                else
                {
                    bResult = true;
                    #endregion
                }

                //處理更新  
                if (dtDisStoreDiff != null && dtDisStoreDiff.Rows.Count > 0)
                {
                    #region
                    MaintainDisStore BCODisStore = new MaintainDisStore(ConnectionDB);

                    foreach (DataRow dr in dtDisStoreDiff.Rows)
                    {

                        ParameterList.Clear();
                        ParameterList.Add(dr["CODE", DataRowVersion.Current]);
                        ParameterList.Add(dr["UPDATEDATE", DataRowVersion.Current]);
                        ParameterList.Add(dr["UPDATEUID", DataRowVersion.Current]);
                        ParameterList.Add(dr["DIS_NO", DataRowVersion.Current]);
                        ParameterList.Add(dr["ITEM", DataRowVersion.Current]);
                        ParameterList.Add(dr["PERIOD", DataRowVersion.Current]);
                        ParameterList.Add(dr["CHAN_NO", DataRowVersion.Current]);
                        ParameterList.Add(dr["STORE", DataRowVersion.Current]);
                        ParameterList.Add(dr["DIS_QTY", DataRowVersion.Current]);
                        ParameterList.Add(dr["PO_SOURCE_NO", DataRowVersion.Current]);
                        ParameterList.Add(dtDisMain.Rows[0]["ST_ACCEPT_DATE"]);
                        bResult = BCODisStore.CreateDisCRMStore(ParameterList, DBT);

                        if (!bResult)
                            throw new Exception(string.Format("MaintainDisStore.CreateDisCRMStore:Step{0} 發生錯誤", "4.4"));
                    
                    }
                }
                else
                {
                    bResult = true;
                    #endregion
                }

                //處理刪除  
                if (dtDisStoreDelete != null && dtDisStoreDelete.Rows.Count > 0)
                {
                    #region
                    MaintainDisStore BCODisStore = new MaintainDisStore(ConnectionDB);

                    foreach (DataRow dr in dtDisStoreDelete.Rows)
                    {
                        ParameterList.Clear();
                        ParameterList.Add(dr["ID", DataRowVersion.Original]);
                        ParameterList.Add(dr["CODE", DataRowVersion.Original]);
                        ParameterList.Add(dr["CREATEDATE", DataRowVersion.Original]);
                        ParameterList.Add(dr["CREATEUID", DataRowVersion.Original]);
                        ParameterList.Add(dr["UPDATEDATE", DataRowVersion.Original]);
                        ParameterList.Add(dr["UPDATEUID", DataRowVersion.Original]);
                        ParameterList.Add(dr["DIS_NO", DataRowVersion.Original]);
                        ParameterList.Add(dr["ITEM", DataRowVersion.Original]);
                        ParameterList.Add(dr["PERIOD", DataRowVersion.Original]);
                        ParameterList.Add(dr["CHAN_NO", DataRowVersion.Original]);
                        ParameterList.Add(dr["STORE", DataRowVersion.Original]);
                        ParameterList.Add(dr["DIS_QTY", DataRowVersion.Original]);
                        ParameterList.Add(dr["PO_SOURCE_NO", DataRowVersion.Original]);

                        bResult = BCODisStore.DeleteDisStore(ParameterList, DBT);

                        if (!bResult)
                            throw new Exception(string.Format("MaintainDisStore.DeleteDisStore:Step{0} 發生錯誤", "4.4"));
                    }
                }
                else
                {
                    bResult = true;
                    #endregion
                }

                #endregion


                #region  4.5) 呼叫 PKG_VDS_ALO_COMM.lf_area_qty

                if (dtDisItemOld != null && dtDisItemOld.Rows.Count > 0)
                {
                    ParameterList.Clear();
                    ParameterList.Add(strDIS_NO);
                    ParameterList.Add(dtDisItemOld.Rows[0]["ITEM"]);
                    ParameterList.Add(dtDisItemOld.Rows[0]["PERIOD"]);
                    ParameterList.Add(dtDisMain.Rows[0]["RCHAN_NO"]);
                    ParameterList.Add("X");
                    VDS_ALO_COMMON_DBO DBO_COMM = new VDS_ALO_COMMON_DBO(ref USEDB);
                    bResult = DBO_COMM.doLp_area_disqty(ParameterList, DBT);
                }

                if (!bResult)
                    throw new Exception(string.Format("{0} 發生失敗", "呼叫 PKG_VDS_ALO_COMM.lf_area_qty"));
                #endregion


                #region 4.6) 異動其他相關資料表

                if (dtDisItemOld != null && dtDisItemOld.Rows.Count > 0)
                {
                    ParameterList.Clear();
                    ParameterList.Add(strDIS_NO);
                    ParameterList.Add(dtDisItemOld.Rows[0]["ITEM"]);
                    ParameterList.Add(dtDisItemOld.Rows[0]["PERIOD"]);
                    ParameterList.Add(dtDisItemOld.Rows[0]["ROOT_NO"]);
                    ProcessALOCommon BCOProcessCommon = new ProcessALOCommon(ConnectionDB);
                    bResult = BCOProcessCommon.UpdateOtherTables(ParameterList, DBT);
                }

                if (!bResult)
                    throw new Exception(string.Format("ProcessALOCommon.UpdateOtherTables:Step{0} 發生錯誤", "4.6"));

                #endregion


                #endregion

                #region 交易成功

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation成立
                    DBT.Commit();
                }

                #endregion

            }
            catch (Exception ex)
            {
                #region 交易失敗

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation失敗
                    DBT.Rollback();
                }

                #endregion

                bResult = false;

                throw GetNewException(ex);
            }
            finally
            {
                #region 判斷是否關閉交易連線

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation,關閉連線
                    if (Conn.State == ConnectionState.Connecting)
                    {
                        Conn.Close();
                    }
                }

                #endregion

            }


            return bResult;

            #endregion
        }
        /// <summary>
        /// 依條件,產生配本記錄(含配本主檔、配本商品、配本通路、配本參照設定、配本通路參照) 
        /// </summary>
        /// <param name="dtDisTmpRec">配本輔助項目設定</param>
        /// <param name="dtDisMain">新增配本主檔</param>
        /// <param name="dtDisItem">新增配本商品</param>
        /// <param name="dtDisChan">新增配本通路</param>
        /// <param name="dtDisItemRefer">新增配本參照</param>
        /// <param name="dtDisType109Tmp">109等級配本設定</param>
        /// <param name="dtDisTypeTmp">105類似配本/110定額配本設定</param>
        /// <param name="vItem">品號</param>
        /// <param name="vPeriod">期別</param>
        /// <param name="vUserID">使用者</param>
        /// <param name="RootDBT"></param>
        /// <returns></returns>
        public string CreateDisRecordFor131(
            DataTable dtDisTmpRec, DataTable dtDisMain, DataTable dtDisItem, DataTable dtDisChan,
            DataTable dtDisItemRefer, DataTable dtDisType109Tmp, DataTable dtDisTypeTmp,
            string vItem, string vPeriod, string vUserID, DbTransaction RootDBT)
        {
            #region
            string strDisNo = "";

            bool bResult = false;
            bool IsRootTranscation = false;
            ArrayList ParameterList = new ArrayList();

            try
            {
                //判斷是否有傳入Root Transcation 
                IsRootTranscation = (RootDBT == null) ? true : false;


                #region 啟動交易或指定RootTranscation

                //4.1) 控制 Begin Transaction
                if (IsRootTranscation)
                {
                    //獨立呼叫啟動Transcation
                    Conn = USEDB.CreateConnection();
                    Conn.Open();
                    DBT = Conn.BeginTransaction();
                }
                else
                {
                    DBT = RootDBT;
                }

                #endregion

                #region biz logical


                #region 4.2) 新增配本主檔並記錄回傳配本序號
                if (dtDisMain != null && dtDisMain.Rows.Count > 0)
                {
                    MaintainDisMain BCODisMain = new MaintainDisMain(ConnectionDB);
                    bResult = BCODisMain.CreateDisMainFor111(dtDisMain, ref strDisNo, DBT);
                }
                else
                {
                    bResult = true;
                }

                if (!bResult)
                    throw new Exception(string.Format("MaintainDisRecord.CreateDisRecordFor131:Step{0} 發生錯誤", "4.2"));
                #endregion

                #region 4.3) 新增配本商品檔
                if (dtDisItem != null && dtDisItem.Rows.Count > 0)
                {
                    MaintainDisItem BCODisItem = new MaintainDisItem(ConnectionDB);
                    bResult = BCODisItem.CreateDisItemFor131(dtDisItem, strDisNo, DBT);
                }
                else
                {
                    bResult = true;
                }


                if (!bResult)
                    throw new Exception(string.Format("MaintainDisRecord.CreateDisRecordFor131:Step{0} 發生錯誤", "4.3"));

                #endregion

                #region 4.4) 新增配本通路檔
                if (dtDisChan != null && dtDisChan.Rows.Count > 0)
                {
                    MaintainDisChan BCODisChan = new MaintainDisChan(ConnectionDB);
                    bResult = BCODisChan.CreateDisChanFor131(dtDisChan, strDisNo, DBT);
                }
                else
                {
                    bResult = true;
                }

                if (!bResult)
                    throw new Exception(string.Format("MaintainDisRecord.CreateDisRecordFor131:Step{0} 發生錯誤", "4.4"));
                #endregion

                #region 4.5) 新增配本參照設定
                if (dtDisItemRefer != null && dtDisItemRefer.Rows.Count > 0)
                {
                    MaintainDisItemRefer BCODisItemRefer = new MaintainDisItemRefer(ConnectionDB);
                    bResult = BCODisItemRefer.CreateDisItemReferForAll(dtDisItemRefer, dtDisChan, strDisNo, vItem, vPeriod, DBT);
                }
                else
                {
                    bResult = true;
                }

                if (!bResult)
                    throw new Exception(string.Format("MaintainDisItemRefer.CreateDisRecordFor131:Step{0} 發生錯誤", "4.5"));
                #endregion

                #region 4.6) 維護配本輔助項目設定
                if (dtDisTmpRec != null && dtDisTmpRec.Rows.Count > 0)
                {
                    #region

                    MaintainDisAssist BCODisAssist = new MaintainDisAssist(ConnectionDB);
                    DataTable dtDisAssist = BCODisAssist.GetDisAssistMainSchema();
                    #endregion



                    //a) 判斷是否需新增特殊調整
                    if (dtDisTmpRec.Rows[0]["SP_CHANGE"] != null && dtDisTmpRec.Rows[0]["SP_CHANGE"].ToString().Trim() != "0")
                    {
                        #region 新增特殊調整(ASSIST_CODE='09')
                        DataRow dr = dtDisAssist.NewRow();
                        dr["DIS_NO"] = strDisNo;
                        dr["ITEM"] = vItem;
                        dr["PERIOD"] = vPeriod;
                        dr["CHAN_NO"] = "0";//新增時固定為0
                        dr["ASSIST_CODE"] = "09";
                        dr["OPERATOR1"] = DBNull.Value;
                        dr["OP_VALUE1"] = DBNull.Value;
                        dr["OPERATOR2"] = DBNull.Value;
                        dr["OP_VALUE2"] = DBNull.Value;
                        dr["CHANGE_TYPE"] = DBNull.Value;
                        dr["CHANGE_RATE"] = DBNull.Value;
                        dr["ORDER_CHANGE"] = DBNull.Value;
                        dr["UPDATEDATE"] = DateTime.Now;
                        dr["UPDATEUID"] = vUserID;
                        dtDisAssist.Rows.Add(dr);

                        bResult = BCODisAssist.CreateDisAssist(dtDisAssist, null, DBT);

                        #endregion
                    }

                    //b) 判斷是否需新增訂單匯入

                    if (dtDisTmpRec.Rows[0]["ORDER_CHANGE"] != null && dtDisTmpRec.Rows[0]["ORDER_CHANGE"].ToString().Trim() != "0")
                    {
                        #region 新增訂單匯入(ASSIST_CODE='10'),
                        DataRow dr = dtDisAssist.NewRow();
                        dr["DIS_NO"] = strDisNo;
                        dr["ITEM"] = vItem;
                        dr["PERIOD"] = vPeriod;
                        dr["CHAN_NO"] = "0";//新增時固定為0
                        dr["ASSIST_CODE"] = "10";
                        dr["OPERATOR1"] = DBNull.Value;
                        dr["OP_VALUE1"] = DBNull.Value;
                        dr["OPERATOR2"] = DBNull.Value;
                        dr["OP_VALUE2"] = DBNull.Value;
                        dr["CHANGE_TYPE"] = DBNull.Value;
                        dr["CHANGE_RATE"] = DBNull.Value;
                        dr["ORDER_CHANGE"] = dtDisTmpRec.Rows[0]["ORDER_CHANGE"].ToString().Trim();
                        dr["UPDATEDATE"] = DateTime.Now;
                        dr["UPDATEUID"] = vUserID;
                        dtDisAssist.Rows.Add(dr);

                        bResult = BCODisAssist.CreateDisAssist(dtDisAssist, null, DBT);

                        #endregion
                    }
                }
                else
                {
                    bResult = true;
                }

                if (!bResult)
                    throw new Exception(string.Format("MaintainDisAssist.CreateDisAssist:Step{0} 發生錯誤", "4.6"));
                #endregion

                #region 4.7) 若dtDisItem.Rows.DIS_TYPE ='109' =>需判斷是否記錄109等級配本設定
                if (dtDisItem != null && dtDisItem.Rows.Count > 0)
                {
                    if (dtDisItem.Rows[0]["DIS_TYPE"].ToString().Trim() == "109")
                    {
                        if (dtDisType109Tmp != null && dtDisType109Tmp.Rows.Count > 0)
                        {
                            MaintainDisType109Tmp BCODisType109 = new MaintainDisType109Tmp(ConnectionDB);
                            bResult = BCODisType109.SaveDisType109Tmp(dtDisType109Tmp, strDisNo, vItem, vPeriod, DBT);
                        }

                    }
                }
                else
                {
                    bResult = true;
                }

                if (!bResult)
                    throw new Exception(string.Format("MaintainDisType109Tmp.SaveDisType109Tmp:Step{0} 發生錯誤", "4.7"));

                #endregion

                #region 4.8) 若dtDisItem.Rows.DIS_TYPE in ('105','110') =>需判斷是否記錄105類似配本/110定額配本設定記錄
                if (dtDisItem != null && dtDisItem.Rows.Count > 0)
                {
                    if (dtDisItem.Rows[0]["DIS_TYPE"].ToString().Trim() == "105" || dtDisItem.Rows[0]["DIS_TYPE"].ToString().Trim() == "110")
                    {
                        if (dtDisTypeTmp != null && dtDisTypeTmp.Rows.Count > 0)
                        {
                            MaintainDisTypeTmp BCODisType = new MaintainDisTypeTmp(ConnectionDB);
                            bResult = BCODisType.SaveDisTypeTmp(dtDisTypeTmp, strDisNo, vItem, vPeriod, DBT);
                        }

                    }
                }
                else
                {
                    bResult = true;
                }

                if (!bResult)
                    throw new Exception(string.Format("MaintainDisTypeTmp.SaveDisTypeTmp:Step{0} 發生錯誤", "4.8"));

                #endregion

                #region 4.9) 異動其他相關資料表
                ParameterList.Clear();
                ParameterList.Add(strDisNo);
                ParameterList.Add(vItem);
                ParameterList.Add(vPeriod);
                ParameterList.Add(vUserID);

                ProcessALOCommon BCOProcessCommon = new ProcessALOCommon(ConnectionDB);

                bResult = BCOProcessCommon.UpdateOtherTables(ParameterList, DBT);

                if (!bResult)
                    throw new Exception(string.Format("ProcessALOCommon.UpdateOtherTables:Step{0} 發生錯誤", "4.9"));

                #endregion


                #endregion

                #region 交易成功

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation成立
                    DBT.Commit();
                }

                #endregion

            }
            catch (Exception ex)
            {
                #region 交易失敗

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation失敗
                    DBT.Rollback();
                }

                #endregion

                strDisNo = "";

                throw GetNewException(ex);
            }
            finally
            {
                #region 判斷是否關閉交易連線

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation,關閉連線
                    if (Conn.State == ConnectionState.Connecting)
                    {
                        Conn.Close();
                    }
                }

                #endregion

            }


            return strDisNo;
            #endregion
        }
        public bool UpdateDisRecordFor131(
            DataTable dtDisTmpRecNew, DataTable dtDisTmpRecOld,
            DataTable dtDisMainNew, DataTable dtDisMainOld,
            DataTable dtDisItemNew, DataTable dtDisItemOld,
            DataTable dtDisChanNew, DataTable dtDisChanOld,
            DataTable dtDisItemReferNew, DataTable dtDisItemReferOld,
            DataTable dtDisType109TmpNew, DataTable dtDisType109TmpOld,
            DataTable dtDisTypeTmpNew, DataTable dtDisTypeTmpOld, DataTable dtDisChanReferNEW,
            string vDisNo, string vItem, string vPeriod, string vUserID, string vStAcceptDate, DbTransaction RootDBT)
        {
            #region

            bool bResult = false;
            bool IsRootTranscation = false;
            ArrayList ParameterList = new ArrayList();
            DataCompare dc = new DataCompare();
            DataTable dtDisMainDiff = null;
            DataTable dtDisItemDiff = null;

            DataTable dtDisChanDiff = null;
            DataTable dtDisChanAdd = null;
            DataTable dtDisChanDelete = null;

            DataTable dtDisItemReferDiff = null;
            DataTable dtDisItemReferAdd = null;
            DataTable dtDisItemReferDelete = null;

            DataTable dtDisTmpRecDiff = null;
            DataTable dtDisTypeTmpDiff = null;
            DataTable dtDisTypeTmpDelete = null;

            DataTable dtDisType109TmpDiff = null;

            try
            {
                //判斷是否有傳入Root Transcation 
                IsRootTranscation = (RootDBT == null) ? true : false;


                #region 啟動交易或指定RootTranscation

                //4.1) 控制 Begin Transaction
                if (IsRootTranscation)
                {
                    //獨立呼叫啟動Transcation
                    Conn = USEDB.CreateConnection();
                    Conn.Open();
                    DBT = Conn.BeginTransaction();
                }
                else
                {
                    DBT = RootDBT;
                }

                #endregion

                #region biz logical


                #region 4.2) 更新配本主檔並記

                #region 比較新舊值
                dc.Clear();
                dc.CompareA = dtDisMainNew;
                dc.CompareB = dtDisMainOld;
                dc.CompareField.AddCompareFieldRow("DIS_NO", "", true);
                dc.CompareField.AddCompareFieldRow("ST_ACCEPT_DATE", "", false);
                dc.CompareData();
                dtDisMainDiff = dc.ADiff;
                #endregion

                if (dtDisMainDiff != null && dtDisMainDiff.Rows.Count > 0)
                {
                    MaintainDisMain BCODisMain = new MaintainDisMain(ConnectionDB);
                    bResult = BCODisMain.UpdateDisMainFor111(dtDisMainDiff, DBT);
                }
                else
                {
                    bResult = true;
                }

                if (!bResult)
                    throw new Exception(string.Format("MaintainDisRecord.UpdateDisMainFor111:Step{0} 發生錯誤", "4.2"));
                #endregion

                #region 4.3) 更新配本商品檔

                #region 比較新舊值
                dc.Clear();
                dc.CompareA = dtDisItemNew;
                dc.CompareB = dtDisItemOld;
                dc.CompareField.AddCompareFieldRow("DIS_NO", "", true);
                dc.CompareField.AddCompareFieldRow("ITEM", "", true);
                dc.CompareField.AddCompareFieldRow("PERIOD", "", true);
                dc.CompareField.AddCompareFieldRow("INCLUDE_NON_EFF", "", false);
                dc.CompareField.AddCompareFieldRow("DIS_TYPE", "", false);
                dc.CompareField.AddCompareFieldRow("DIS_PRE_QTY", "", false);
                dc.CompareField.AddCompareFieldRow("DIS_QTY", "", false);
                dc.CompareField.AddCompareFieldRow("CHAN_TYPE", "", false);


                dc.CompareData();
                dtDisItemDiff = dc.ADiff;
                #endregion

                if (dtDisItemDiff != null && dtDisItemDiff.Rows.Count > 0)
                {
                    MaintainDisItem BCODisItem = new MaintainDisItem(ConnectionDB);
                    bResult = BCODisItem.UpdateDisItemFor111(dtDisItemDiff, DBT);
                }
                else
                {
                    bResult = true;
                }


                if (!bResult)
                    throw new Exception(string.Format("MaintainDisRecord.UpdateDisItemFor111:Step{0} 發生錯誤", "4.3"));

                #endregion

                #region 4.4) 更新配本通路檔

                #region 比較新舊值
                dc.Clear();
                dc.CompareA = dtDisChanNew;
                dc.CompareB = dtDisChanOld;
                dc.CompareField.AddCompareFieldRow("DIS_NO", "", true);
                dc.CompareField.AddCompareFieldRow("ITEM", "", true);
                dc.CompareField.AddCompareFieldRow("PERIOD", "", true);
                dc.CompareField.AddCompareFieldRow("CHAN_NO", "", true);
                dc.CompareField.AddCompareFieldRow("DIS_TYPE", "", false);
                dc.CompareField.AddCompareFieldRow("DIS_PRE_CQTY", "", false);
                dc.CompareField.AddCompareFieldRow("ID", "", false);

                dc.CompareData();
                dtDisChanDiff = dc.ADiff;
                dtDisChanAdd = dc.AOnly;
                dtDisChanDelete = dc.BOnly;
                #endregion

                if ((dtDisChanDiff != null && dtDisChanDiff.Rows.Count > 0) ||
                    (dtDisChanAdd != null && dtDisChanAdd.Rows.Count > 0) ||
                    (dtDisChanDelete != null && dtDisChanDelete.Rows.Count > 0))
                {
                    MaintainDisChan BCODisChan = new MaintainDisChan(ConnectionDB);
                    bResult = BCODisChan.UpdateDisChanFor131(dtDisChanDiff, dtDisChanAdd, dtDisChanDelete, vStAcceptDate, DBT);
                }
                else
                {
                    bResult = true;
                }

                if (!bResult)
                    throw new Exception(string.Format("MaintainDisRecord.CreateDisRecordFor131:Step{0} 發生錯誤", "4.4"));
                #endregion

                #region 4.5) 更新配本參照設定

                #region 比較新舊值
                dc.Clear();
                dc.CompareA = dtDisItemReferNew;
                dc.CompareB = dtDisItemReferOld;
                dc.CompareField.AddCompareFieldRow("DIS_NO", "", true);
                dc.CompareField.AddCompareFieldRow("ITEM", "", true);
                dc.CompareField.AddCompareFieldRow("PERIOD", "", true);
                dc.CompareField.AddCompareFieldRow("RITEM", "", true);
                dc.CompareField.AddCompareFieldRow("RPERIOD", "", true);
                dc.CompareField.AddCompareFieldRow("REFER_RATE", "", false);
                dc.CompareField.AddCompareFieldRow("ID", "", false);

                dc.CompareData();
                dtDisItemReferDiff = dc.ADiff;
                dtDisItemReferAdd = dc.AOnly;
                dtDisItemReferDelete = dc.BOnly;
                #endregion

                if ((dtDisItemReferDiff != null && dtDisItemReferDiff.Rows.Count > 0) ||
                    (dtDisItemReferAdd != null && dtDisItemReferAdd.Rows.Count > 0) ||
                    (dtDisItemReferDelete != null && dtDisItemReferDelete.Rows.Count > 0))
                {
                    MaintainDisItemRefer BCODisItemRefer = new MaintainDisItemRefer(ConnectionDB);
                    bResult = BCODisItemRefer.UpdateItemAndChanRefer(dtDisItemReferDiff, dtDisItemReferAdd, dtDisItemReferDelete, dtDisChanOld, dtDisChanNew, dtDisItemReferNew, vItem, vPeriod, DBT);
                }
                else
                {
                    bResult = true;
                }

                if (!bResult)
                    throw new Exception(string.Format("MaintainDisItemRefer.CreateDisRecordFor131:Step{0} 發生錯誤", "4.5"));
                #endregion

                #region 4.5.2) 更新通路參照

                if (dtDisChanReferNEW != null)
                {
                    MaintainDisChanRefer BCOChanRef = new MaintainDisChanRefer(ConnectionDB);

                    bResult = BCOChanRef.UpdateDisChanReferFor(dtDisChanReferNEW,
                                                                  vDisNo,
                                                                  vItem,
                                                                  vPeriod,
                                                                  vUserID,
                                                                  DBT
                                                                  );

                    if (!bResult)
                        throw new Exception(string.Format("MaintainDisChanRefer.UpdateDisChanReferFor:Step{0} 發生錯誤", "4.5.2"));

                }
                #endregion


                #region 4.6) 維護配本輔助項目設定

                #region 比較新舊值
                dc.Clear();
                dc.CompareA = dtDisTmpRecNew;
                dc.CompareB = dtDisTmpRecOld;
                dc.CompareField.AddCompareFieldRow("ID", "", true);
                dc.CompareField.AddCompareFieldRow("CODE", "", true);
                dc.CompareField.AddCompareFieldRow("SP_CHANGE", "", false);
                dc.CompareField.AddCompareFieldRow("ORDER_CHANGE", "", false);
                dc.CompareField.AddCompareFieldRow("DIS_TYPE", "", false);
                dc.CompareData();
                dtDisTmpRecDiff = dc.ADiff;
                #endregion

                if (dtDisTmpRecDiff != null && dtDisTmpRecDiff.Rows.Count > 0)
                {
                    #region

                    MaintainDisAssist BCODisAssist = new MaintainDisAssist(ConnectionDB);
                    DataTable dtDisAssist = BCODisAssist.GetDisAssistMainSchema();


                    ParameterList.Clear();
                    ParameterList.Add(dtDisTmpRecDiff.Rows[0]["DIS_NO"]);
                    ParameterList.Add(dtDisTmpRecDiff.Rows[0]["ITEM"]);
                    ParameterList.Add(dtDisTmpRecDiff.Rows[0]["PERIOD"]);
                    ParameterList.Add(DBNull.Value);//CHAN_NO
                    ParameterList.Add(dtDisTmpRecDiff.Rows[0]["UPDATEDATE"]);
                    ParameterList.Add(dtDisTmpRecDiff.Rows[0]["UPDATEUID"]);

                    BCODisAssist.DeleteOldDisAssist(ParameterList, DBT);
                    #endregion



                    //a) 判斷是否需更新特殊調整
                    if (dtDisTmpRecDiff.Rows[0]["SP_CHANGE"] != null && dtDisTmpRecDiff.Rows[0]["SP_CHANGE"].ToString().Trim() != "0")
                    {
                        #region 更新特殊調整(ASSIST_CODE='09')
                        DataRow dr = dtDisAssist.NewRow();
                        dr["DIS_NO"] = vDisNo;
                        dr["ITEM"] = vItem;
                        dr["PERIOD"] = vPeriod;
                        dr["CHAN_NO"] = "0";//更新時固定為0
                        dr["ASSIST_CODE"] = "09";
                        dr["OPERATOR1"] = DBNull.Value;
                        dr["OP_VALUE1"] = DBNull.Value;
                        dr["OPERATOR2"] = DBNull.Value;
                        dr["OP_VALUE2"] = DBNull.Value;
                        dr["CHANGE_TYPE"] = DBNull.Value;
                        dr["CHANGE_RATE"] = DBNull.Value;
                        dr["ORDER_CHANGE"] = DBNull.Value;
                        dr["UPDATEDATE"] = DateTime.Now;
                        dr["UPDATEUID"] = vUserID;
                        dtDisAssist.Rows.Add(dr);

                        bResult = BCODisAssist.CreateDisAssist(dtDisAssist, null, DBT);

                        #endregion
                    }

                    //b) 判斷是否需更新訂單匯入

                    if (dtDisTmpRecDiff.Rows[0]["ORDER_CHANGE"] != null && dtDisTmpRecDiff.Rows[0]["ORDER_CHANGE"].ToString().Trim() != "0")
                    {
                        #region 更新訂單匯入(ASSIST_CODE='10'),
                        DataRow dr = dtDisAssist.NewRow();
                        dr["DIS_NO"] = vDisNo;
                        dr["ITEM"] = vItem;
                        dr["PERIOD"] = vPeriod;
                        dr["CHAN_NO"] = "0";//更新時固定為0
                        dr["ASSIST_CODE"] = "10";
                        dr["OPERATOR1"] = DBNull.Value;
                        dr["OP_VALUE1"] = DBNull.Value;
                        dr["OPERATOR2"] = DBNull.Value;
                        dr["OP_VALUE2"] = DBNull.Value;
                        dr["CHANGE_TYPE"] = DBNull.Value;
                        dr["CHANGE_RATE"] = DBNull.Value;
                        dr["ORDER_CHANGE"] = dtDisTmpRecDiff.Rows[0]["ORDER_CHANGE"].ToString().Trim();
                        dr["UPDATEDATE"] = DateTime.Now;
                        dr["UPDATEUID"] = vUserID;
                        dtDisAssist.Rows.Add(dr);

                        bResult = BCODisAssist.CreateDisAssist(dtDisAssist, null, DBT);

                        #endregion
                    }
                }
                else
                {
                    bResult = true;
                }

                if (!bResult)
                    throw new Exception(string.Format("MaintainDisAssist.CreateDisAssist:Step{0} 發生錯誤", "4.6"));
                #endregion

                #region 4.7) 若dtDisItem.Rows.DIS_TYPE ='109' =>需判斷是否記錄109等級配本設定

                #region 比較新舊值
                dc.Clear();
                dc.CompareA = dtDisType109TmpNew;
                dc.CompareB = dtDisType109TmpOld;
                dc.CompareField.AddCompareFieldRow("DIS_NO", "", true);
                dc.CompareField.AddCompareFieldRow("ITEM", "", true);
                dc.CompareField.AddCompareFieldRow("PERIOD", "", true);
                dc.CompareField.AddCompareFieldRow("RANK_CODE", "", true);
                dc.CompareField.AddCompareFieldRow("RANK_LEVEL", "", true);
                //dc.CompareField.AddCompareFieldRow("VENDOR", "", true);
                dc.CompareField.AddCompareFieldRow("PATTERN_NO", "", true);
                dc.CompareField.AddCompareFieldRow("RANK_DIS_QTY", "", false);

                dc.CompareData();
                dtDisType109TmpDiff = dc.ADiff;
                #endregion

                if (dtDisTmpRecNew != null && dtDisTmpRecNew.Rows.Count > 0)
                {
                    if (dtDisTmpRecNew.Rows[0]["DIS_TYPE"].ToString().Trim() == "109")
                    {
                        //if (dtDisType109TmpDiff != null && dtDisType109TmpDiff.Rows.Count > 0)
                        //{
                        //    MaintainDisType109Tmp BCODisType109 = new MaintainDisType109Tmp(ConnectionDB);
                        //    bResult = BCODisType109.SaveDisType109Tmp(dtDisType109TmpDiff, vDisNo, vItem, vPeriod, DBT);
                        //}

                        if (dtDisType109TmpNew != null && dtDisType109TmpNew.Rows.Count > 0)//20090811 added
                        {
                            MaintainDisType109Tmp BCODisType109 = new MaintainDisType109Tmp(ConnectionDB);
                            bResult = BCODisType109.SaveDisType109Tmp(dtDisType109TmpNew, vDisNo, vItem, vPeriod, DBT);
                        }
                    }
                }
                else
                {
                    bResult = true;
                }

                if (!bResult)
                    throw new Exception(string.Format("MaintainDisType109Tmp.SaveDisType109Tmp:Step{0} 發生錯誤", "4.7"));

                #endregion

                #region 4.8) 若dtDisItem.Rows.DIS_TYPE in ('105','110') =>需判斷是否記錄105類似配本/110定額配本設定記錄

                #region 比較新舊值
                dc.Clear();
                dc.CompareA = dtDisTypeTmpNew;
                dc.CompareB = dtDisTypeTmpOld;
                dc.CompareField.AddCompareFieldRow("DIS_NO", "", true);
                dc.CompareField.AddCompareFieldRow("ITEM", "", true);
                dc.CompareField.AddCompareFieldRow("PERIOD", "", true);
                dc.CompareField.AddCompareFieldRow("DIS_TYPE", "", true);
                dc.CompareField.AddCompareFieldRow("DIS_QTY", "", false);

                dc.CompareData();
                dtDisTypeTmpDiff = dc.ADiff;
                dtDisTypeTmpDelete = dc.BOnly;

                #endregion

                if (dtDisTmpRecNew != null && dtDisTmpRecNew.Rows.Count > 0)
                {
                    if (dtDisTmpRecNew.Rows[0]["DIS_TYPE"].ToString().Trim() == "105" || dtDisTmpRecNew.Rows[0]["DIS_TYPE"].ToString().Trim() == "110")
                    {
                        //if (dtDisTypeTmpDiff != null && dtDisTypeTmpDiff.Rows.Count > 0)
                        //{
                        //    MaintainDisTypeTmp BCODisType = new MaintainDisTypeTmp(ConnectionDB);
                        //    bResult = BCODisType.SaveDisTypeTmp(dtDisTypeTmpDiff, vDisNo, vItem, vPeriod, DBT);
                        //}

                        if (dtDisTypeTmpNew != null && dtDisTypeTmpNew.Rows.Count > 0)//20090812 added
                        {
                            MaintainDisTypeTmp BCODisType = new MaintainDisTypeTmp(ConnectionDB);
                            bResult = BCODisType.SaveDisTypeTmp(dtDisTypeTmpNew, vDisNo, vItem, vPeriod, DBT);
                        }
                    }
                    else
                    {
                        if (dtDisTypeTmpDelete != null && dtDisTypeTmpDelete.Rows.Count > 0)//20090820 added
                        {
                            MaintainDisTypeTmp BCODisType = new MaintainDisTypeTmp(ConnectionDB);
                            bResult = BCODisType.DeleteDisTypeTmp(vDisNo, vItem, vPeriod, DBT);
                        }

                    }
                }
                else
                {
                    bResult = true;
                }

                if (!bResult)
                    throw new Exception(string.Format("MaintainDisTypeTmp.SaveDisTypeTmp:Step{0} 發生錯誤", "4.8"));

                #endregion

                #region 4.9) 異動其他相關資料表
                ParameterList.Clear();
                ParameterList.Add(vDisNo);
                ParameterList.Add(vItem);
                ParameterList.Add(vPeriod);
                ParameterList.Add(vUserID);

                ProcessALOCommon BCOProcessCommon = new ProcessALOCommon(ConnectionDB);

                bResult = BCOProcessCommon.UpdateOtherTables(ParameterList, DBT);

                if (!bResult)
                    throw new Exception(string.Format("ProcessALOCommon.UpdateOtherTables:Step{0} 發生錯誤", "4.9"));

                #endregion


                #endregion

                #region 交易成功

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation成立
                    DBT.Commit();
                }

                #endregion

            }
            catch (Exception ex)
            {
                #region 交易失敗

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation失敗
                    DBT.Rollback();
                }

                #endregion

                bResult = false;

                throw GetNewException(ex);
            }
            finally
            {
                #region 判斷是否關閉交易連線

                if (IsRootTranscation)
                {
                    //獨立呼叫Transcation,關閉連線
                    if (Conn.State == ConnectionState.Connecting)
                    {
                        Conn.Close();
                    }
                }

                #endregion

            }


            return bResult;

            #endregion
        }
Exemple #4
0
    protected void btn_SaveAssist_Click(object sender, EventArgs e)
    {
        #region
        try
        {
            DateTime ProcessingDateTime = OperationProcessingDateTime;
            string strUserId = Session["UID"].ToString();
            bool bResult = false;

            DataTable dtAssistMain = null;

            if (CheckAndSetAssistMainByAssistCodeChecked(ProcessingDateTime,strUserId,out dtAssistMain))
            {

                #region
                DataTable dtTemp = dtDisAssistDetlAll;

                if (dtTemp != null && dtTemp.Rows.Count > 0)
                {
                    string strChanNo = GetChanNo_AssistSetting();

                    foreach (DataRow dr in dtTemp.Rows)
                    {
                        if (dr.RowState != DataRowState.Deleted)
                        {
                            dr["CHAN_NO"] = strChanNo;
                        }
                    }

                    dtDisAssistDetlAll = dtTemp;
                }
                #endregion

                ALOModel.ALOCommon BCOCommon = new ALOModel.ALOCommon();
                System.Data.Common.DbTransaction DBT = BCOCommon.OpenAndGetConnection(ConnectionDB).BeginTransaction();

                ALOModel.MaintainDisAssist BCO = new ALOModel.MaintainDisAssist(ConnectionDB);

                ALOModel.MaintainDisItem BCO2 = new ALOModel.MaintainDisItem(ConnectionDB);

                ArrayList ParameterList = new ArrayList();//20091106
                ParameterList.Clear();
                ParameterList.Add(txt_DisNo.Text.Trim());
                ParameterList.Add(SLP_SKU1.Text.Trim());
                ParameterList.Add(SLP_ItemPeriod1.Text.Trim());
                ParameterList.Add(GetChanNo_AssistSetting());
                ParameterList.Add(ProcessingDateTime);
                ParameterList.Add(strUserId);



                try
                {
                    bResult = BCO.DeleteOldDisAssist(ParameterList, DBT);

                    if (bResult)
                    {
                        #region 重新將09、10類型之輔助項目填回DB
                        if (dtDisAssistMainALO131 != null && dtDisAssistMainALO131.Rows.Count > 0)
                        {
                            for (Int32 i = 0; i <= dtDisAssistMainALO131.Rows.Count - 1; i++)
                            {
                                if (dtDisAssistMainALO131.Rows[i]["ASSIST_CODE"].ToString().Trim() == "09" ||
                                    dtDisAssistMainALO131.Rows[i]["ASSIST_CODE"].ToString().Trim() == "10")
                                {

                                    ParameterList.Clear();
                                    ParameterList.Add(dtDisAssistMainALO131.Rows[i]["DIS_NO"]);
                                    ParameterList.Add(dtDisAssistMainALO131.Rows[i]["ITEM"]);
                                    ParameterList.Add(dtDisAssistMainALO131.Rows[i]["PERIOD"]);
                                    ParameterList.Add(dtDisAssistMainALO131.Rows[i]["CHAN_NO"]); 
                                    ParameterList.Add(dtDisAssistMainALO131.Rows[i]["ASSIST_CODE"]);
                                    ParameterList.Add(dtDisAssistMainALO131.Rows[i]["OPERATOR1"]);
                                    ParameterList.Add(dtDisAssistMainALO131.Rows[i]["OP_VALUE1"]);
                                    ParameterList.Add(dtDisAssistMainALO131.Rows[i]["OPERATOR2"]);
                                    ParameterList.Add(dtDisAssistMainALO131.Rows[i]["OP_VALUE2"]);
                                    ParameterList.Add(dtDisAssistMainALO131.Rows[i]["CHANGE_TYPE"]);
                                    ParameterList.Add(dtDisAssistMainALO131.Rows[i]["CHANGE_RATE"]);
                                    ParameterList.Add(dtDisAssistMainALO131.Rows[i]["ORDER_CHANGE"]);
                                    ParameterList.Add(dtDisAssistMainALO131.Rows[i]["UPDATEDATE"]);
                                    ParameterList.Add(dtDisAssistMainALO131.Rows[i]["UPDATEUID"]);
                                    bResult = BCO.CreateAssistMain(ParameterList, DBT);
                                }
                            }

                        }
                        #endregion

                        if (BCO.CreateAssistMain(dtAssistMain, DBT))
                        {
                            bResult = BCO.CreateAssistDetl(dtDisAssistDetlAll, DBT);

                            ArrayList ParameterList1 = new ArrayList();//20091106
                            ParameterList1.Clear();
                            ParameterList1.Add(txt_Remark.Text.Trim());
                            ParameterList1.Add(s_ID_DisItem);
                            ParameterList1.Add(s_UPDATEDATE);
                            ParameterList1.Add(s_UPDATEUID);
                            ParameterList1.Add(s_DISNO);
                            ParameterList1.Add(s_ITEM);
                            ParameterList1.Add(s_PERIOD);

                            BCO2.SaveAssistMemo(ParameterList1, DBT);
                        

                            ResultMsgLabel.Text = "存檔成功";

                        }
                    }

                    DBT.Commit();//交易成功


                }
                catch (Exception ex)
                {
                    DBT.Rollback();//交易失敗
                    throw ex;
                }
                finally 
                {
                    GetAssistMainAndDetl();
                }
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        #endregion
    }
Exemple #5
0
    /// <summary>
    /// 查詢配本商品
    /// </summary>
    /// <param name="dis_no">配本序號</param>
    /// <param name="approve_date">確認日期</param>
    /// <param name="item">回傳->配本商品品號</param>
    /// <param name="period">回傳->配本商品期別</param>
    private void getDis_Item(string dis_no, string approve_date, out string item, out string period)
    {
        item = "";
        period = "";
        try
        {
            ArrayList ParameterList = new ArrayList();//20091113

            ParameterList.Clear();
            ParameterList.Add(dis_no); //配本序號
            BCO.MaintainDisItem bco = new BCO.MaintainDisItem(ConnectionDB);
            DataTable dt;
            dt = bco.QueryDisItemFor111(ParameterList);
            if (dt.Rows.Count > 0)
            {
                if (approve_date == "")
                {
                    btnPrev2.Enabled = true;
                    btnNext2.Enabled = true;
                    btnQuery2.Enabled = true;
                }
                GridView1.DataSource = dt;
                GridView1.DataBind();
                SLP_ITEM.Text = dt.Rows[0]["ITEM"].ToString();
                SLP_PERIOD.Text = dt.Rows[0]["PERIOD"].ToString();
                txtN_ONHD_QTY.Text = dt.Rows[0]["N_ONHD_QTY"].ToString().Length == 0 ? "0" : dt.Rows[0]["N_ONHD_QTY"].ToString(); //採購量
                txtN_PER_QTY.Text = dt.Rows[0]["N_PER_QTY"].ToString().Length == 0 ? "0" : dt.Rows[0]["N_PER_QTY"].ToString(); //可配量
                SLP_DIS_TYPE.Text = dt.Rows[0]["DIS_TYPE"].ToString();

                hidITEM.Value = dt.Rows[0]["ITEM"].ToString();
                hidPERIOD.Value = dt.Rows[0]["PERIOD"].ToString();
                hidN_ONHD_QTY.Value = dt.Rows[0]["N_ONHD_QTY"].ToString().Length == 0 ? "0" : dt.Rows[0]["N_ONHD_QTY"].ToString();
                hidN_PER_QTY.Value = dt.Rows[0]["N_PER_QTY"].ToString().Length == 0 ? "0" : dt.Rows[0]["N_PER_QTY"].ToString();
                hidRoot_No.Value = dt.Rows[0]["Root_No"].ToString();

                item = dt.Rows[0]["ITEM"].ToString();
                period = dt.Rows[0]["PERIOD"].ToString();
                hidID.Value = dt.Rows[0]["ID"].ToString(); //ID值,供上、下筆查詢時使用
                hidNum.Value = "1";

                string SessionIDName = "ALO121_dt1" + PageTimeStamp.Value;
                Session[SessionIDName] = dt;
            }
        }
        catch (Exception ex)
        {
            lblErrorQ1.Text = ex.Message;
            lblErrorQ1.Visible = true;
        }
    }
Exemple #6
0
    /// <summary>
    /// 取得原始資料庫資料
    /// </summary>
    private void GetAllOriginalDatatables()
    {
        #region
        try
        {
            #region

            ArrayList ParameterList1 = new ArrayList();//20091106
            ParameterList1.Clear();
            ParameterList1.Add(s_DISNO);
            ParameterList1.Add(s_ITEM);
            ParameterList1.Add(s_PERIOD);
            ParameterList1.Add(null);//CHAN_NO

            #region DIS_MAIN
            ALOModel.MaintainDisMain BCO1 = new ALOModel.MaintainDisMain(ConnectionDB);
            dtDisMainOld = BCO1.QueryByDisNo(ParameterList1);
            dtDisMain = dtDisMainOld.Copy();

            DataColumn[] PrimaryKeys11 = new DataColumn[1];
            PrimaryKeys11[0] = dtDisMainOld.Columns["DIS_NO"];
            dtDisMainOld.PrimaryKey = PrimaryKeys11;

            DataColumn[] PrimaryKeys12 = new DataColumn[1];
            PrimaryKeys12[0] = dtDisMain.Columns["DIS_NO"];
            dtDisMain.PrimaryKey = PrimaryKeys12;
            #endregion

            #region DIS_ITEM
            ALOModel.MaintainDisItem BCO2 = new ALOModel.MaintainDisItem(ConnectionDB);
            dtDisItemOld = BCO2.QueryByDisNo(ParameterList1);
            dtDisItem = dtDisItemOld.Copy();

            DataColumn[] PrimaryKeys21 = new DataColumn[3];
            PrimaryKeys21[0] = dtDisItemOld.Columns["DIS_NO"];
            PrimaryKeys21[1] = dtDisItemOld.Columns["ITEM"];
            PrimaryKeys21[2] = dtDisItemOld.Columns["PERIOD"];
            dtDisItemOld.PrimaryKey = PrimaryKeys21;

            DataColumn[] PrimaryKeys22 = new DataColumn[3];
            PrimaryKeys22[0] = dtDisItem.Columns["DIS_NO"];
            PrimaryKeys22[1] = dtDisItem.Columns["ITEM"];
            PrimaryKeys22[2] = dtDisItem.Columns["PERIOD"];
            dtDisItem.PrimaryKey = PrimaryKeys22;
            #endregion

            #region DIS_CHAN
            ALOModel.MaintainDisChan BCO3 = new ALOModel.MaintainDisChan(ConnectionDB);
            dtDisChanOld = BCO3.QueryDisChanFor111(ParameterList1);
            dtDisChan = dtDisChanOld.Copy();

            DataColumn[] PrimaryKeys31 = new DataColumn[4];
            PrimaryKeys31[0] = dtDisChanOld.Columns["DIS_NO"];
            PrimaryKeys31[1] = dtDisChanOld.Columns["ITEM"];
            PrimaryKeys31[2] = dtDisChanOld.Columns["PERIOD"];
            PrimaryKeys31[3] = dtDisChanOld.Columns["CHAN_NO"];
            dtDisChanOld.PrimaryKey = PrimaryKeys31;

            DataColumn[] PrimaryKeys32 = new DataColumn[4];
            PrimaryKeys32[0] = dtDisChan.Columns["DIS_NO"];
            PrimaryKeys32[1] = dtDisChan.Columns["ITEM"];
            PrimaryKeys32[2] = dtDisChan.Columns["PERIOD"];
            PrimaryKeys32[3] = dtDisChan.Columns["CHAN_NO"];
            dtDisChan.PrimaryKey = PrimaryKeys32;
            #endregion

            #region DIS_CHAN_REFER
            //ALOModel.MaintainDisChanRefer BCO9 = new ALOModel.MaintainDisChanRefer(ConnectionDB);
            //dtDisChanReferOld = BCO9.QueryDisChanReferByDisNo(ParameterList1);
            //dtDisChanRefer = dtDisChanReferOld.Copy();

            //DataColumn[] PrimaryKeys91 = new DataColumn[6];
            //PrimaryKeys91[0] = dtDisChanReferOld.Columns["DIS_NO"];
            //PrimaryKeys91[1] = dtDisChanReferOld.Columns["ITEM"];
            //PrimaryKeys91[2] = dtDisChanReferOld.Columns["PERIOD"];
            //PrimaryKeys91[3] = dtDisChanReferOld.Columns["CHAN_NO"];
            //PrimaryKeys91[4] = dtDisChanReferOld.Columns["RITEM"];
            //PrimaryKeys91[5] = dtDisChanReferOld.Columns["RPERIOD"];
            //dtDisChanReferOld.PrimaryKey = PrimaryKeys91;

            //DataColumn[] PrimaryKeys92 = new DataColumn[6];
            //PrimaryKeys92[0] = dtDisChanRefer.Columns["DIS_NO"];
            //PrimaryKeys92[1] = dtDisChanRefer.Columns["ITEM"];
            //PrimaryKeys92[2] = dtDisChanRefer.Columns["PERIOD"];
            //PrimaryKeys92[3] = dtDisChanRefer.Columns["CHAN_NO"];
            //PrimaryKeys92[4] = dtDisChanRefer.Columns["RITEM"];
            //PrimaryKeys92[5] = dtDisChanRefer.Columns["RPERIOD"];
            //dtDisChanRefer.PrimaryKey = PrimaryKeys92;
            #endregion

            #region DIS_ITEM_REFER
            ALOModel.MaintainDisItemRefer BCO4 = new ALOModel.MaintainDisItemRefer(ConnectionDB);
            dtDisItemReferOld = BCO4.QueryDisItemReferFor111(ParameterList1);
            dtDisItemRefer = dtDisItemReferOld.Copy();

            DataColumn[] PrimaryKeys41 = new DataColumn[5];
            PrimaryKeys41[0] = dtDisItemReferOld.Columns["DIS_NO"];
            PrimaryKeys41[1] = dtDisItemReferOld.Columns["ITEM"];
            PrimaryKeys41[2] = dtDisItemReferOld.Columns["PERIOD"];
            PrimaryKeys41[3] = dtDisItemReferOld.Columns["RITEM"];
            PrimaryKeys41[4] = dtDisItemReferOld.Columns["RPERIOD"];
            dtDisItemReferOld.PrimaryKey = PrimaryKeys41;

            DataColumn[] PrimaryKeys42 = new DataColumn[5];
            PrimaryKeys42[0] = dtDisItemRefer.Columns["DIS_NO"];
            PrimaryKeys42[1] = dtDisItemRefer.Columns["ITEM"];
            PrimaryKeys42[2] = dtDisItemRefer.Columns["PERIOD"];
            PrimaryKeys42[3] = dtDisItemRefer.Columns["RITEM"];
            PrimaryKeys42[4] = dtDisItemRefer.Columns["RPERIOD"];
            dtDisItemRefer.PrimaryKey = PrimaryKeys42;

            #endregion

            #region DIS_TYPE_TMP
            ALOModel.MaintainDisTypeTmp BCO5 = new ALOModel.MaintainDisTypeTmp(ConnectionDB);
            dtDisTypeTmpOld = BCO5.QueryDisTypeTmp(ParameterList1);
            dtDisTypeTmp = dtDisTypeTmpOld.Copy();

            DataColumn[] PrimaryKeys51 = new DataColumn[4];
            PrimaryKeys51[0] = dtDisTypeTmpOld.Columns["DIS_NO"];
            PrimaryKeys51[1] = dtDisTypeTmpOld.Columns["ITEM"];
            PrimaryKeys51[2] = dtDisTypeTmpOld.Columns["PERIOD"];
            PrimaryKeys51[3] = dtDisTypeTmpOld.Columns["DIS_TYPE"];
            dtDisTypeTmpOld.PrimaryKey = PrimaryKeys51;

            DataColumn[] PrimaryKeys52 = new DataColumn[4];
            PrimaryKeys52[0] = dtDisTypeTmp.Columns["DIS_NO"];
            PrimaryKeys52[1] = dtDisTypeTmp.Columns["ITEM"];
            PrimaryKeys52[2] = dtDisTypeTmp.Columns["PERIOD"];
            PrimaryKeys52[3] = dtDisTypeTmp.Columns["DIS_TYPE"];
            dtDisTypeTmp.PrimaryKey = PrimaryKeys52;
            #endregion

            #region DIS_TYPE_109_TMP
            ALOModel.MaintainDisType109Tmp BCO6 = new ALOModel.MaintainDisType109Tmp(ConnectionDB);
            dtDisType109TmpOld = BCO6.QueryDisType109Tmp(ParameterList1);
            dtDisTypeTmp109 = dtDisType109TmpOld.Copy();

            DataColumn[] PrimaryKeys61 = new DataColumn[6];
            PrimaryKeys61[0] = dtDisType109TmpOld.Columns["DIS_NO"];
            PrimaryKeys61[1] = dtDisType109TmpOld.Columns["ITEM"];
            PrimaryKeys61[2] = dtDisType109TmpOld.Columns["PERIOD"];
            PrimaryKeys61[3] = dtDisType109TmpOld.Columns["RANK_CODE"];
            PrimaryKeys61[4] = dtDisType109TmpOld.Columns["RANK_LEVEL"];
            PrimaryKeys61[5] = dtDisType109TmpOld.Columns["PATTERN_NO"];
            dtDisType109TmpOld.PrimaryKey = PrimaryKeys61;

            DataColumn[] PrimaryKeys62 = new DataColumn[6];
            PrimaryKeys62[0] = dtDisTypeTmp109.Columns["DIS_NO"];
            PrimaryKeys62[1] = dtDisTypeTmp109.Columns["ITEM"];
            PrimaryKeys62[2] = dtDisTypeTmp109.Columns["PERIOD"];
            PrimaryKeys62[3] = dtDisTypeTmp109.Columns["RANK_CODE"];
            PrimaryKeys62[4] = dtDisTypeTmp109.Columns["RANK_LEVEL"];
            PrimaryKeys62[5] = dtDisTypeTmp109.Columns["PATTERN_NO"];
            dtDisTypeTmp109.PrimaryKey = PrimaryKeys62;
            #endregion

            #region DIS_ASSIST
            ALOModel.MaintainDisAssist BCO7 = new ALOModel.MaintainDisAssist(ConnectionDB);
            dtDisAssistMainOld = BCO7.QueryDisAssistMainWithoutChan(ParameterList1);
            dtDisAssistMain = dtDisAssistMainOld.Copy();

            DataColumn[] PrimaryKeys71 = new DataColumn[4];
            PrimaryKeys71[0] = dtDisAssistMainOld.Columns["DIS_NO"];
            PrimaryKeys71[1] = dtDisAssistMainOld.Columns["ITEM"];
            PrimaryKeys71[2] = dtDisAssistMainOld.Columns["PERIOD"];
            PrimaryKeys71[3] = dtDisAssistMainOld.Columns["ASSIST_CODE"];
            dtDisAssistMainOld.PrimaryKey = PrimaryKeys71;

            DataColumn[] PrimaryKeys72 = new DataColumn[4];
            PrimaryKeys72[0] = dtDisAssistMain.Columns["DIS_NO"];
            PrimaryKeys72[1] = dtDisAssistMain.Columns["ITEM"];
            PrimaryKeys72[2] = dtDisAssistMain.Columns["PERIOD"];
            PrimaryKeys72[3] = dtDisAssistMain.Columns["ASSIST_CODE"];
            dtDisAssistMain.PrimaryKey = PrimaryKeys72;

            //20090818 added
            dtDisAssistDetlAll = BCO7.QueryDisAssistDetlWithoutChan(ParameterList1);
            #endregion

            #region DIS_REC
            ALOModel.MaintainDisTmpRec BCO8 = new ALOModel.MaintainDisTmpRec(ConnectionDB);
            ParameterList1.Clear();
            ParameterList1.Add(s_ID_DisRec);
            dtDisTmpRecOld = BCO8.QueryById(ParameterList1);
            dtDisTmpRec = dtDisTmpRecOld.Copy();

            DataColumn[] PrimaryKeys81 = new DataColumn[2];
            PrimaryKeys81[0] = dtDisTmpRecOld.Columns["ID"];
            PrimaryKeys81[1] = dtDisTmpRecOld.Columns["CODE"];
            dtDisTmpRecOld.PrimaryKey = PrimaryKeys81;

            DataColumn[] PrimaryKeys82 = new DataColumn[2];
            PrimaryKeys82[0] = dtDisTmpRec.Columns["ID"];
            PrimaryKeys82[1] = dtDisTmpRec.Columns["CODE"];
            dtDisTmpRec.PrimaryKey = PrimaryKeys82;
            #endregion

            #endregion
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        #endregion
    }
Exemple #7
0
 private void MakeDataTableDisItem()
 {
     #region
     try
     {
         ALOModel.MaintainDisItem BCO = new ALOModel.MaintainDisItem(ConnectionDB);
         dtDisItem = BCO.GetDisItemSchema();
     }
     catch (Exception ex)
     {
         ErrorMsgLabel.Text = ex.Message;
     }
     #endregion
 }
Exemple #8
0
    /// <summary>
    /// 갮ھڰt���Ǹ��ot��ӫ~
    /// </summary>
    /// <param name="strDisNo"></param>
    private void GetDisItemByDisNo(string strDisNo)
    {
        #region
        DataTable dt = new DataTable();
        try
        {

            if (strDisNo != "")
            {
                ArrayList ParameterList = new ArrayList();//20091113

                ParameterList.Clear();
                ParameterList.Add(strDisNo);
                ALOModel.MaintainDisItem BCO = new ALOModel.MaintainDisItem(ConnectionDB);
                dt = BCO.QueryDisItemFor111(ParameterList);
            }

            if (dt != null && dt.Rows.Count > 0)
            {
                //���������n����
                for (int x = dt.Columns.Count - 1; x >= 0; x--)
                {
                    if (dt.Columns[x].ColumnName != "DIS_NO" &&
                        dt.Columns[x].ColumnName != "ITEM" &&
                        dt.Columns[x].ColumnName != "PERIOD")
                    {
                        dt.Columns.RemoveAt(x);
                    }
                }
                dt.AcceptChanges();
            }

        }
        catch (Exception ex)
        {
            throw ex;
        }

        dtDisItem = dt;
        dt.Dispose();

        #endregion
    }
Exemple #9
0
    /// <summary>
    /// 刪除配本商品事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void ItemDeleteBtn_Click(object sender, EventArgs e)
    {
        try
        {
            ErrorMsgLabel.Text = "";

            ALOModel.MaintainDisItem MDI = new ALOModel.MaintainDisItem(ConnectionDB);

            #region 輸入變數
            ArrayList ParameterList = new ArrayList();

            ParameterList.Clear();
            //更新日期
            SessionIDName = "ALO111ItemGridViewDv_" + PageTimeStamp.Value;

            DataView dv = (DataView)Session[SessionIDName];

            DateTime UpdateDate = DateTime.Now;
            for (int i = 0; i < dv.Count; i++)
            {
                if ((dv[i]["ITEM"].ToString() == SLP_SKU1.Text) &&
                     (dv[i]["PERIOD"].ToString() == SLP_ItemPeriod1.Text)
                   )
                {
                    UpdateDate = DateTime.Parse(dv[i]["UPDATEDATE"].ToString());
                }
            }
            ParameterList.Add(UpdateDate);
            //更新使用者
            ParameterList.Add(Session["UID"].ToString());
            //配本序號
            ParameterList.Add(DISNOTxt.Text);
            //商品序號
            ParameterList.Add(SLP_SKU1.Text);
            //期別
            ParameterList.Add(SLP_ItemPeriod1.Text);

            #endregion

            bool DeleteOK = MDI.DeleteDisItemFor111(ParameterList,
                                                    null
                                                    );

            if (!DeleteOK)
            {
                throw new Exception("刪除配本商品失敗!");
            }
            else
            {
                #region 依配本序號查詢

                SLP_SKU0.Text = "";//2010/04/07 added
                UpdatePanel_ItemGridView.Update();

                ALOItemBind();
                ALODisMainBind();

                if (DISNOTxt.Text != "")
                {
                    FormStatusControl(FormStatus.View);
                }

                #endregion

                UpdatePanel_ALODisHead.Update();
                UpdatePanel_Item.Update();
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = "刪除配本商品事件發生錯誤!錯誤訊息:" + ex.Message;
        }
        finally
        {
            UpdatePanel_ErrorMessage.Update();
        }
    }
Exemple #10
0
    /// <summary>
    /// 配本商品列表GridView
    /// </summary>
    private void ItemGridViewBind()
    {
        ALOModel.MaintainDisItem bco = new ALOModel.MaintainDisItem(ConnectionDB);

        #region 輸入變數

        ArrayList ParameterList = new ArrayList();
        ParameterList.Clear();
        ParameterList.Add(DISNOTxt.Text);

        #endregion

        DataTable Dt = bco.QueryDisItemFor111(ParameterList);

        #region 使用XML放置到前端資料

        XML_GridViewItemList.InnerHtml = (Dt.Rows.Count > 0) ? Dt.DataSet.GetXml() : "";

        #endregion

        SessionIDName = "ALO111ItemGridViewDv_" + PageTimeStamp.Value;

        DataView dv = Dt.DefaultView;

        if (SLP_SKU0.Text != "") //有輸入過濾商品品號
        {
            dv.RowFilter = "ITEM='" + SLP_SKU0.Text + "'";
        }

        Session[SessionIDName] = dv;
        GridView_ItemList.DataSource = dv;
        GridView_ItemList.DataBind();

    }
Exemple #11
0
    /// <summary>
    /// 設定Momo資訊
    /// </summary>
    private void SettingMemo()
    {
        //設定Memo
        ALOModel.MaintainDisItem MDI = new ALOModel.MaintainDisItem(ConnectionDB);

        #region 輸入變數

        ArrayList ParameterList = new ArrayList();//20091113

        ParameterList.Clear();
        //配本序號
        ParameterList.Add(Request.QueryString["DIS_NO"]);
        //配本項目商品
        ParameterList.Add(Request.QueryString["ITEM"]);
        //配本項目期別
        ParameterList.Add(Request.QueryString["PERIOD"]);

        #endregion

        MemoTxtBox.Text = MDI.QueryDisAssistMemo(ParameterList);

    }
Exemple #12
0
    /// <summary>
    /// 確認設定
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void ConfirmBtn_Click(object sender, EventArgs e)
    {
        #region
        try
        {
            ErrorMsgLabel.Text = "";

            if (IsValid)
            {
                string DetailSessionIDAndName = "ALO113AddistDetail_" + PageTimeStamp.Value;

                #region 檢核輸入值

                if (POSSaleCheckBox.Checked)//03
                {
                    #region
                    if (!CheckAssistDetlIsSetByAssistCode(POSSaleAddPercentRadioButton.Checked, SLPNumber_POSSaleAddPercent.Text.Trim(), "03", SLPNumber_POSSaleCondition.Text.Trim()))
                        return;
                    #endregion
                }

                if (AllSaleCheckBox.Checked)//04
                {
                    #region
                    if (!CheckAssistDetlIsSetByAssistCode(AllSaleAddPercentRadioButton.Checked, SLPNumber_AllSaleAddPercent.Text.Trim(), "04", null))
                        return;
                    #endregion
                }

                if (PrePeriodCheckBox.Checked)//05
                {
                    #region
                    if (!CheckAssistDetlIsSetByAssistCode(PrePeriodAddPercentRadioButton.Checked, SLPNumber_PrePeriodAddPercent.Text.Trim(), "05", SLPNumber_PrePeriod.Text.Trim()))
                        return;
                    #endregion
                }

                if (POSAddCheckBox.Checked)//06
                {
                    #region
                    if (!CheckAssistDetlIsSetByAssistCode(POSAdd_AddPercentRadioButton.Checked, SLPNumber_POSAdd_AddPercent.Text.Trim(), "06", SLPNumber_POSAdd.Text.Trim()))
                        return;
                    #endregion
                }

                if (GoodsReturnCheckBox.Checked)//07
                {
                    #region
                    if (!CheckAssistDetlIsSetByAssistCode(GoodsReturnAddPercentRadioButton.Checked, SLPNumber_GoodsReturnAddPercent.Text.Trim(), "07", SLPNumber_GoodsReturnPercent.Text.Trim()))
                        return;

                    #endregion
                }

                if (QTYLessThanPreSaleCheckBox.Checked)//08
                {
                    #region
                    if (!CheckAssistDetlIsSetByAssistCode(QTYLessThanPreSaleAddPercentRadioButton.Checked, SLPNumber_QTYLessThanPreSaleAddPercent.Text.Trim(), "08", null))
                        return;
                    #endregion
                }


                #endregion

                #region 檢核明細資料

                #region not in use : can't check detail data correctly
                //if (POSSaleSettingQTYRadioButton.Checked ||
                //     AllSaleSettingQTYRadioButton.Checked ||
                //     PrePeriodSettingQTYRadioButton.Checked ||
                //     POSAddSettingQTYRadioButton.Checked ||
                //     GoodsReturnSettingQTYRadioButton.Checked ||
                //     QTYLessThanPreSaleSettingQtyRadioButton.Checked
                //    ) //如果有設定本數
                //{
                //    dtAssistDetl = (DataTable)Session[DetailSessionIDAndName];

                //    if (dtAssistDetl.Rows.Count == 0)
                //    {
                //        throw new Exception("加減本數明細無資料,不可存檔!!");
                //    }
                //}
                #endregion

                #endregion

                #region 儲存輔助功能設定項目

                string SessionMainIDAndName = "ALO113dtAssistMain_" + PageTimeStamp.Value;
                dtAssistMain = (DataTable)Session[SessionMainIDAndName];
                dtAssistDetl = (DataTable)Session[DetailSessionIDAndName];

                SettingMainDt();
                SettingDetlDt();


                DateTime ProcessingDateTime = DateTime.Now;
                ArrayList ParameterList2 = new ArrayList();
                ParameterList2.Clear();
                ParameterList2.Add(Request.QueryString["DIS_NO"]);
                ParameterList2.Add(Request.QueryString["ITEM"]);
                ParameterList2.Add(Request.QueryString["PERIOD"]);
                ParameterList2.Add(GetChanNo_AssistSetting());
                ParameterList2.Add(ProcessingDateTime);
                ParameterList2.Add(Session["UID"].ToString());

                bool SaveMainOK = SaveAssitMaiAndDetl(dtAssistMain, dtAssistDetl, ParameterList2);

                if (!SaveMainOK)
                {
                    throw new Exception("儲存輔助功能失敗!!");
                }

                #endregion

                #region 儲存備註

                ALOModel.MaintainDisItem MDI = new ALOModel.MaintainDisItem(ConnectionDB);

                #region 輸入變數
                ////new
                //db.AddInParameter(cmd, "NEW_MEMO", DbType.String, ParameterList[0]);
                ////old
                //db.AddInParameter(cmd, "OLD_ID", DbType.VarNumeric, ParameterList[1]);
                //db.AddInParameter(cmd, "OLD_UPDATEDATE", DbType.Date, DateTime.Parse(ParameterList[2].ToString()));
                //db.AddInParameter(cmd, "OLD_UPDATEUID", DbType.String, ParameterList[3]);
                //db.AddInParameter(cmd, "OLD_DIS_NO", DbType.String, ParameterList[4]);
                //db.AddInParameter(cmd, "OLD_ITEM", DbType.String, ParameterList[5]);
                //db.AddInParameter(cmd, "OLD_PERIOD", DbType.String, ParameterList[6]);

                ArrayList ParameterList = new ArrayList();//20091113

                ParameterList.Clear();
                //新值Memo
                ParameterList.Add(MemoTxtBox.Text);
                //舊值ID(目前暫無使用 請隨便設個ID)
                ParameterList.Add(100);
                //更新日期
                ParameterList.Add(DateTime.Now);
                //更新者
                ParameterList.Add(Session["UID"].ToString());
                //配本序號
                ParameterList.Add(Request.QueryString["DIS_NO"]);
                //配本商品
                ParameterList.Add(Request.QueryString["ITEM"]);
                //期別
                ParameterList.Add(Request.QueryString["PERIOD"]);

                #endregion

                bool SaveMemoOK = MDI.SaveAssistMemo(ParameterList,
                                                     null
                                                     );

                if (!SaveMemoOK)
                {
                    throw new Exception("儲存備註失敗!");
                }

                #endregion

                SetUIByCheckBoxChecked();//2010/04/15 added 
                ResultMsgLabel.Text = "確認設定成功!";

            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = "確認設定發生錯誤!錯誤訊息:" + ex.Message;
        }
        finally
        {
            UpdatePanel_ErrorMessage.Update();
        }
        #endregion
    }