public DataTable QuerySwitch(QueryType QT,
                                     ArrayList ParameterList
                                     )
        {
            DBO.STM_StorePropertyDBO dbo = new STM_StorePropertyDBO(ref USEDB);
            DataTable Dt;

            try
            {
                switch (QT)
                {
                    case QueryType.ALL:
                        Dt = dbo.doQueryAll();
                        break;
                    case QueryType.CODE:
                        Dt = dbo.doQueryByCode(ParameterList);
                        break;
                    case QueryType.ID:
                        Dt = dbo.doQueryByID(ParameterList);
                        break;
                    case QueryType.Custom:
                        Dt = dbo.doQueryByFind(ParameterList);
                        break;
                    default:
                        Dt = new DataTable();
                        break;
                }

                return Dt;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public DataTable QueryStorePropertyByCode(ArrayList ParameterList)
 {
     try
     {
         DBO.STM_StorePropertyDBO dbo = new STM_StorePropertyDBO(ref USEDB);
         return dbo.doQueryByCode(ParameterList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public DataTable QueryStorePropertyByALL()
 {
     try
     {
         DBO.STM_StorePropertyDBO dbo = new STM_StorePropertyDBO(ref USEDB);
         return dbo.doQueryAll();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #4
0
        /// <summary>
        /// 基本表單更新BCO
        /// </summary>
        /// <param name="ParameterList">更新變數</param>
        /// <param name="RootDBT">是否有主交易,無主交易輸入null</param>
        /// <returns>回傳影響筆數</returns>
        public void UpdateStoreBase(ArrayList ParameterList,
                                      DbTransaction RootDBT,
                                      DataTable detail,
                                      int v_Code
                                      )
        {
            bool IsRootTranscation = false;
            string s_Log_User = string.Empty;
            DateTime d_Now; 
            ArrayList ParameterList_Detail = new ArrayList();
            
            try
            {
                DBO.STM_StoreBaseDBO dbo_STORE = new STM_StoreBaseDBO(ref USEDB);
                DBO.STM_StorePropertyDBO dbo_PROPERTY = new STM_StorePropertyDBO(ref USEDB);
                DBO.STM_StoreShelfDBO dbo_SHELF = new STM_StoreShelfDBO(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

                dbo_STORE.doUpdate(ParameterList, DBT);

                if (v_Code == 1)
                {
                    dbo_PROPERTY.doUpdate_Insert(ParameterList, DBT);
                }
                else if (v_Code == 2)
                {
                    dbo_PROPERTY.doUpdate(ParameterList, DBT);
                }

                d_Now = DateTime.Now;
                s_Log_User = ParameterList[9].ToString();

                foreach (DataRow dRow in detail.Rows)
                {
                    if (dRow.RowState == DataRowState.Added)
                    {
                       dbo_SHELF.doCreate(dRow, DBT, s_Log_User, d_Now);
                    }
                    if  (dRow.RowState == DataRowState.Modified)
                    {
                       ParameterList_Detail.Clear();
                       ParameterList_Detail.Add(dRow["CREATEDATE",DataRowVersion.Original]);
                       ParameterList_Detail.Add(dRow["CREATEUID", DataRowVersion.Original]);
                       ParameterList_Detail.Add(dRow["UPDATEDATE", DataRowVersion.Original]);
                       ParameterList_Detail.Add(dRow["UPDATEUID", DataRowVersion.Original]);
                       ParameterList_Detail.Add(dRow["STORE", DataRowVersion.Original]);
                       ParameterList_Detail.Add(dRow["SHELF_NO", DataRowVersion.Original]);
                       ParameterList_Detail.Add(dRow["NAME", DataRowVersion.Current]);
                       ParameterList_Detail.Add(d_Now);
                       ParameterList_Detail.Add(s_Log_User);
                       ParameterList_Detail.Add(dRow["STORE", DataRowVersion.Current]);
                       ParameterList_Detail.Add(dRow["SHELF_NO", DataRowVersion.Current]);
                       ParameterList_Detail.Add(dRow["SHELVE_CM3", DataRowVersion.Current]);
                       ParameterList_Detail.Add(dRow["DISPLAY_NUM", DataRowVersion.Current]);
                       dbo_SHELF.doUpdate(ParameterList_Detail, DBT);
                    }
                    if (dRow.RowState == DataRowState.Deleted)
                    {
                        dbo_SHELF.doDelete(dRow, DBT, s_Log_User, d_Now);
                    }
                }

                #region 交易成功

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

                #endregion

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

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

                #endregion

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

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

                #endregion

            }
        }
예제 #5
0
        /// <summary>
        /// 基本表單新增BCO
        /// </summary>
        /// <param name="ParameterList">輸入變數</param>
        /// <param name="RootDBT">是否有主交易,無主交易輸入null</param>
        /// <returns>回傳影響筆數</returns>
        public int CreateStoreBase(ArrayList ParameterList,
                                      DbTransaction RootDBT,
                                      DataTable detail
                                      )
        {
            int PID = 0;

            bool IsRootTranscation = false;
            string s_Log_User = string.Empty;
            DateTime d_Now;

            try
            {
                DBO.STM_StoreBaseDBO dbo_STORE = new STM_StoreBaseDBO(ref USEDB);
                DBO.STM_StorePropertyDBO dbo_PROPERTY = new STM_StorePropertyDBO(ref USEDB);
                DBO.STM_StoreShelfDBO dbo_SHELF = new STM_StoreShelfDBO(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

                PID = dbo_STORE.doCreate(ParameterList, DBT);

                dbo_PROPERTY.doCreate(ParameterList, DBT);

                d_Now = DateTime.Now;
                s_Log_User = ParameterList[3].ToString();

                foreach (DataRow dRow in detail.Rows)
                {
                    if (dRow.RowState != DataRowState.Deleted)
                    {
                        dbo_SHELF.doCreate(dRow, DBT, s_Log_User, d_Now);
                    }
                }

                #region 交易成功

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

                #endregion

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

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

                #endregion

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

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

                #endregion

            }
        }
        /// <summary>
        /// 測試SP交易失敗
        /// </summary>
        /// <param name="ParameterList">變數</param>
        /// <param name="RootDBT">是否有主交易,無主交易輸入null</param>
        public void TestTranscation(ArrayList ParameterList1,
                                    ArrayList ParameterList2,
                                    ArrayList ParameterList3,
                                    DbTransaction RootDBT
                                    )
        {
            bool IsRootTranscation = false;

            try
            {
                DBO.STM_StorePropertyDBO dbo = new STM_StorePropertyDBO(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

                dbo.doCreate(ParameterList1, DBT);

                dbo.doUpdate(ParameterList2, DBT);

                dbo.doDelete(ParameterList3, DBT);

                throw new Exception("交易失敗");

                #region 交易成功

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

                #endregion

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

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

                #endregion

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

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

                #endregion
            }

        }