public DataTable QueryVenderAssigendStore(ArrayList ParameterList)
 {
     #region
     try
     {
         VDS_ALO_COMMON_DBO DBO = new VDS_ALO_COMMON_DBO(ref USEDB);
         DataTable dt = DBO.doQueryVenderAssigendStore(ParameterList);
         return dt;
     }
     catch (Exception ex)
     {
         throw GetNewException(ex);
     }
     #endregion
 }
 public DataTable QueryOpenAndCloseStore(ArrayList ParameterList)
 {
     #region
     try
     {
         VDS_ALO_COMMON_DBO DBO = new VDS_ALO_COMMON_DBO(ref USEDB);
         DataTable dt = DBO.doCheckStoreOpenAndClose(ParameterList);
         return dt;
     }
     catch (Exception ex)
     {
         throw GetNewException(ex);
     }
     #endregion
 }
Exemplo n.º 3
0
        public bool CreateDisCRMRecord(DataTable dtDisMain, DataTable dtDisItem, DataTable dtDisStore, out string vDisNo, DbTransaction RootDBT)
        {
            #region
            bool bResult = false;
            bool IsRootTranscation = false;

            try
            {
                VDS_ALO_DIS_MAIN_DBO DBO_MAIN = new VDS_ALO_DIS_MAIN_DBO(ref USEDB);
                VDS_ALO_DIS_ITEM_DBO DBO_ITEM = new VDS_ALO_DIS_ITEM_DBO(ref USEDB);
                VDS_ALO_DIS_CHAN_DBO DBO_CHAN = new VDS_ALO_DIS_CHAN_DBO(ref USEDB);
                VDS_ALO_DIS_STORE_DBO DBO_STORE = new VDS_ALO_DIS_STORE_DBO(ref USEDB);
                VDS_ALO_COMMON_DBO DBO_COMM = new VDS_ALO_COMMON_DBO(ref USEDB);


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


                #region 啟動交易或指定RootTranscation

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

                #endregion

                vDisNo = "";
                string strCode = "", strCodeLast = "";

                ArrayList ParameterList = new ArrayList();

                //配本主檔:VDS_ALO_DIS_MAIN                           

                if (dtDisMain != null && dtDisMain.Rows.Count > 0)
                {
                    ParameterList.Clear();
                    ParameterList.Add(dtDisMain.Rows[0]["UPDATEDATE"]);
                    ParameterList.Add(dtDisMain.Rows[0]["UPDATEUID"]);
                    ParameterList.Add(dtDisMain.Rows[0]["DIS_DATE"]);
                    ParameterList.Add(dtDisMain.Rows[0]["ST_ACCEPT_DATE"]);
                    ParameterList.Add(dtDisMain.Rows[0]["RCHAN_NO"]);
                    ParameterList.Add(dtDisMain.Rows[0]["PO_SOURCE_NO"]);

                    vDisNo = DBO_MAIN.doCreateDisCRMMain(ParameterList, DBT);
                }

                if (vDisNo != "")
                {
                    foreach (DataRow dr in dtDisItem.Rows)
                    {
                        #region 配本商品檔:VDS_ALO_DIS_ITEM
                        ParameterList.Clear();
                        ParameterList.Add(dr["CREATEDATE"]);
                        ParameterList.Add(dr["CREATEUID"]);
                        ParameterList.Add(vDisNo);
                        ParameterList.Add(dr["ITEM"]);
                        ParameterList.Add(dr["PERIOD"]);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(dr["DIS_QTY"]);
                        ParameterList.Add(dr["ACCEPT_QTY"]);
                        ParameterList.Add(dr["DIS_STO_QTY"]);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(dr["TAX_TYPE"]);
                        ParameterList.Add(dr["ROOT_NO"]);
                        ParameterList.Add(dr["PMA"]);
                        ParameterList.Add(dr["PATTERN_NO"]);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(DBNull.Value);
                        ParameterList.Add(DBNull.Value);
                        bResult = DBO_ITEM.doCreateDisItem(ParameterList, DBT);

                        if (!bResult)
                            throw new Exception(string.Format("寫入 {0} 發生失敗", "配本商品檔:VDS_ALO_DIS_ITEM"));

                        #endregion

                        #region 配本通路檔:VDS_ALO_DIS_CHAN
                        ParameterList.Clear();
                        ParameterList.Add(vDisNo);
                        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); //2009-05-04 cyhsu add for V_DIS_PRE_CQTY
                        ParameterList.Add(dtDisMain.Rows[0]["ST_ACCEPT_DATE"]);
                        bResult = DBO_CHAN.doCreateDisChan(ParameterList, DBT);

                        if (!bResult)
                            throw new Exception(string.Format("寫入 {0} 發生失敗", "配本通路檔:VDS_ALO_DIS_CHAN"));

                        #endregion

                        #region 配本門市檔:VDS_ALO_DIS_STORE
                        if (dtDisStore != null && dtDisStore.Rows.Count > 0)
                        {
                            foreach (DataRow dr2 in dtDisStore.Rows)
                            {
                                strCode = string.Format("{0}_{1}_{2}_{3}_{4}",
                                    vDisNo, dr2["ITEM"].ToString().Trim(), dr2["PERIOD"].ToString().Trim(), dtDisMain.Rows[0]["RCHAN_NO"].ToString().Trim(), dr2["STORE"].ToString().Trim());

                                if (strCode != strCodeLast)
                                {
                                    ParameterList.Clear();
                                    ParameterList.Add(strCode);
                                    ParameterList.Add(dr2["UPDATEDATE"]);
                                    ParameterList.Add(dr2["UPDATEUID"]);
                                    ParameterList.Add(vDisNo);
                                    ParameterList.Add(dr2["ITEM"]);
                                    ParameterList.Add(dr2["PERIOD"]);
                                    ParameterList.Add(dtDisMain.Rows[0]["RCHAN_NO"]);
                                    ParameterList.Add(dr2["STORE"]);
                                    //ParameterList.Add(dr2["ROUTE"]);//是否需要? doCreateDisCRMStore 參數不相符
                                    //ParameterList.Add(dr2["STEP"]);
                                    ParameterList.Add(dr2["DIS_QTY"]);
                                    ParameterList.Add(dr2["PO_SOURCE_NO"]);
                                    ParameterList.Add(dtDisMain.Rows[0]["ST_ACCEPT_DATE"]);

                                    bResult = DBO_STORE.doCreateDisCRMStore(ParameterList, DBT);
                                }

                                strCodeLast = string.Format("{0}_{1}_{2}_{3}_{4}",
                                    vDisNo, dr2["ITEM"].ToString().Trim(), dr2["PERIOD"].ToString().Trim(), dtDisMain.Rows[0]["RCHAN_NO"].ToString().Trim(), dr2["STORE"].ToString().Trim());
                            }

                        }

                        if (!bResult)
                            throw new Exception(string.Format("寫入 {0} 發生失敗", "配本門市檔:VDS_ALO_DIS_STORE"));

                        #endregion

                        #region 呼叫 PKG_VDS_ALO_COMM.lf_area_qty
                        ParameterList.Clear();
                        ParameterList.Add(vDisNo);
                        ParameterList.Add(dr["ITEM"]);
                        ParameterList.Add(dr["PERIOD"]);
                        ParameterList.Add(dtDisMain.Rows[0]["RCHAN_NO"]);
                        ParameterList.Add("X");
                        bResult = DBO_COMM.doLp_area_disqty(ParameterList, DBT);

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

                    }
                }
                else
                {
                    throw new Exception(string.Format("{0} 發生失敗", "呼叫 PKG_VDS_ALO_DIS_MAIN.CreateDisCRMMain"));
                }

                #region 交易成功

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

                #endregion

                bResult = true;
            }
            catch (Exception ex)
            {
                #region 交易失敗

                bResult = false;

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

                #endregion

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

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

                #endregion

            }

            return bResult;
            #endregion
        }
Exemplo n.º 4
0
        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
        }
Exemplo n.º 5
0
        /// <summary>
        /// 檢查品號、與商品分類關連正確性
        /// </summary>
        /// <param name="ParameterList"></param>
        /// <returns></returns>
        public bool CheckItemClassValid(ArrayList ParameterList)
        {
            #region
            try
            {
                VDS_ALO_COMMON_DBO ALOM = new VDS_ALO_COMMON_DBO(ref USEDB);
                return ALOM.doCheckItemClassValid(ParameterList);
            }
            catch (Exception ex)
            {
                throw GetNewException(ex);
            }

            #endregion
        }
Exemplo n.º 6
0
        public bool Lp_area_disqty_all(ArrayList ParameterList, DbTransaction RootDBT)
        {
            #region
            bool bResult = false;
            bool IsRootTranscation = false;

            try
            {
                VDS_ALO_COMMON_DBO ALOM = new VDS_ALO_COMMON_DBO(ref USEDB);

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


                #region 啟動交易或指定RootTranscation

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

                #endregion


                bResult = ALOM.doLp_area_disqty_all(ParameterList, RootDBT); ;

                #region 交易成功

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

                #endregion

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

                bResult = false;

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

                #endregion

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

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

                #endregion

            }

            return bResult;
            #endregion
        }
Exemplo n.º 7
0
        /// <summary>
        /// 根據傳入參數,回傳完整商品ID、NAME資訊(群分類、大分類、Pattern、Item)
        /// </summary>
        /// <param name="ParameterList"></param>
        /// <returns></returns>
        public DataTable QueryItemClassInfo(ArrayList ParameterList)
        {
            #region
            try
            {
                VDS_ALO_COMMON_DBO DBO = new VDS_ALO_COMMON_DBO(ref USEDB);
                DataTable Dt = DBO.doQueryItemClassInfo(ParameterList);

                return Dt;
            }
            catch (Exception ex)
            {
                throw GetNewException(ex);
            }
            #endregion
        }
Exemplo n.º 8
0
 /// <summary>
 /// 檢查PO單號是否重複
 /// </summary>
 /// <param name="ParameterList"></param>
 /// <param name="strErrMsg"></param>
 /// <returns></returns>
 public bool CheckPODuplicate(ArrayList ParameterList, out string strErrMsg)
 {
     #region
     try
     {
         VDS_ALO_COMMON_DBO DBO = new VDS_ALO_COMMON_DBO(ref USEDB);
         return DBO.doCheckPODuplicate(ParameterList, out strErrMsg);
     }
     catch (Exception ex)
     {
         throw GetNewException(ex);
     }
     #endregion
 }
Exemplo n.º 9
0
        public void QueryEffectRouteAndStep(ArrayList ParameterList, out string strRoute, out string strStep, out string strTransNo)
        {
            #region
            try
            {
                VDS_ALO_COMMON_DBO ALOM = new VDS_ALO_COMMON_DBO(ref USEDB);
                ALOM.doQueryEffectRouteAndStep(ParameterList, out  strRoute, out  strStep, out  strTransNo);
            }
            catch (Exception ex)
            {
                throw GetNewException(ex);
            }

            #endregion
        }
Exemplo n.º 10
0
        public DataTable QueryApproveErrorData(ArrayList ParameterList)
        {
            #region
            try
            {
                VDS_ALO_COMMON_DBO ALOM = new VDS_ALO_COMMON_DBO(ref USEDB);
                return ALOM.doQueryApproveErrorData(ParameterList);
            }
            catch (Exception ex)
            {
                throw GetNewException(ex);
            }

            #endregion
        }
Exemplo n.º 11
0
        public DataTable QueryItemPeriodChanSalesInfo(ArrayList ParameterList)
        {
            #region
            try
            {
                VDS_ALO_COMMON_DBO ALOM = new VDS_ALO_COMMON_DBO(ref USEDB);
                return ALOM.doQueryItemPeriodChanSalesInfo(ParameterList);
            }
            catch (Exception ex)
            {
                throw GetNewException(ex);
            }

            #endregion
        }
Exemplo n.º 12
0
        public Int32 QueryPurchaseQty(ArrayList ParameterList)
        {
            #region
            try
            {
                VDS_ALO_COMMON_DBO ALOM = new VDS_ALO_COMMON_DBO(ref USEDB);
                return ALOM.doQueryPurchaseQty(ParameterList);
            }
            catch (Exception ex)
            {
                throw GetNewException(ex);
            }

            #endregion
        }
Exemplo n.º 13
0
        public string GetMaxUnIssuancePeriod(ArrayList ParameterList)
        {
            #region
            try
            {
                VDS_ALO_COMMON_DBO ALOM = new VDS_ALO_COMMON_DBO(ref USEDB);
                return ALOM.doGetMaxUnIssuancePeriod(ParameterList);
            }
            catch (Exception ex)
            {
                throw GetNewException(ex);
            }

            #endregion
        }
Exemplo n.º 14
0
        public string CheckCurrentItemPeriodState(ArrayList ParameterList)
        {
            #region
            try
            {
                VDS_ALO_COMMON_DBO ALOM = new VDS_ALO_COMMON_DBO(ref USEDB);
                return ALOM.doCheckCurrentItemPeriodState(ParameterList);
            }
            catch (Exception ex)
            {
                throw GetNewException(ex);
            }

            #endregion
        }
Exemplo n.º 15
0
        public bool UpdateDisItemAndStore(DataTable dtDisStore, DbTransaction RootDBT)
        {
            #region
            bool bResult = false;
            bool IsRootTranscation = false;

            try
            {
                VDS_ALO_COMMON_DBO DBO_COMMM = new VDS_ALO_COMMON_DBO(ref USEDB);
                VDS_ALO_DIS_STORE_DBO DBO_DIS_STORE = new VDS_ALO_DIS_STORE_DBO(ref USEDB);


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

                #region 啟動交易或指定RootTranscation

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

                #endregion

                ArrayList ParameterList = new ArrayList();
                if (dtDisStore != null && dtDisStore.Rows.Count > 0)
                {
                    for (Int32 i = 0; i <= dtDisStore.Rows.Count - 1; i++)
                    {
                        #region
                        //a) 配本序號異動時(目前配本序號<>前一配本序號)時,需更新配本其他相關記錄檔。
                        #region
                        if (strLastDisNO != "" && strLastDisNO != dtDisStore.Rows[i]["DIS_NO", DataRowVersion.Original].ToString())
                        {
                            ParameterList.Clear();
                            ParameterList.Add(strLastDisNO);
                            ParameterList.Add("X");
                            bResult = DBO_COMMM.doLp_area_disqty_all(ParameterList, DBT);

                            if (!bResult)
                                throw new Exception(string.Format("執行 {0} 發生失敗", "配本序號異動時"));
                        }
                        #endregion

                        //b) 逐筆更新配本門市。
                        #region
                        ParameterList.Clear();
                        ParameterList.Add(dtDisStore.Rows[i]["DIS_QTY", DataRowVersion.Original]);
                        ParameterList.Add(dtDisStore.Rows[i]["UPDATEDATE", DataRowVersion.Original]);
                        ParameterList.Add(dtDisStore.Rows[i]["UPDATEUID", DataRowVersion.Original]);
                        ParameterList.Add(dtDisStore.Rows[i]["DIS_NO", DataRowVersion.Original]);
                        ParameterList.Add(dtDisStore.Rows[i]["ITEM", DataRowVersion.Original]);
                        ParameterList.Add(dtDisStore.Rows[i]["PERIOD", DataRowVersion.Original]);
                        ParameterList.Add(dtDisStore.Rows[i]["CHAN_NO", DataRowVersion.Original]);
                        ParameterList.Add(dtDisStore.Rows[i]["STORE", DataRowVersion.Original]);
                        ParameterList.Add(dtDisStore.Rows[i]["N_NEW_DIS_QTY", DataRowVersion.Current]);
                        ParameterList.Add(dtDisStore.Rows[i]["UPDATEDATE", DataRowVersion.Current]);
                        ParameterList.Add(dtDisStore.Rows[i]["UPDATEUID", DataRowVersion.Current]);

                        bResult = DBO_DIS_STORE.doUpdateDisStoreForStoreCheck(ParameterList, DBT);

                        if (!bResult)
                            throw new Exception(string.Format("執行 {0} 發生失敗", "逐筆更新配本門市"));
                        #endregion

                        strLastDisNO = dtDisStore.Rows[i]["DIS_NO", DataRowVersion.Original].ToString();

                        #endregion
                    }

                    //c) 最後一筆需更新配本其他相關記錄檔。
                    #region
                    if (strLastDisNO != "")
                    {
                        ParameterList.Clear();
                        ParameterList.Add(strLastDisNO);
                        ParameterList.Add("X");
                        bResult = DBO_COMMM.doLp_area_disqty_all(ParameterList, DBT);

                        if (!bResult)
                            throw new Exception(string.Format("執行 {0} 發生失敗", "配本序號異動時"));
                    }
                    #endregion

                }

                #region 交易成功

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

                bResult = true;
                #endregion
            }
            catch (Exception ex)
            {
                #region 交易失敗

                bResult = false;

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

                #endregion

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

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

                #endregion

            }

            return bResult;
            #endregion
        }