예제 #1
0
        public DataTable QuerySwitch(QueryType QT,
                                     ArrayList ParameterList
                                     )
        {
            DBO.MKT_GiftDBO dbo = new MKT_GiftDBO(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;
            }
        }
예제 #2
0
 public DataTable QueryGiftByCode(ArrayList ParameterList)
 {
     try
     {
         DBO.MKT_GiftDBO dbo = new MKT_GiftDBO(ref USEDB);
         return dbo.doQueryByCode(ParameterList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #3
0
 public DataTable QueryGiftByALL()
 {
     try
     {
         DBO.MKT_GiftDBO dbo = new MKT_GiftDBO(ref USEDB);
         return dbo.doQueryAll();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #4
0
        /// <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.MKT_GiftDBO dbo = new MKT_GiftDBO(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
            }

        }
예제 #5
0
        public void UpdateGiftDetail(DataTable Dt_Gift, DbTransaction RootDBT, string UID)
        {
            bool IsRootTranscation = false;

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

                //DataTable DtD_A = Dt_Gift.GetChanges(DataRowState.Added);
                DataTable DtD_M = Dt_Gift.GetChanges(DataRowState.Modified);
                DataTable DtD_D = Dt_Gift.GetChanges(DataRowState.Deleted);

                ArrayList arrayList = new ArrayList();

                #region Delete

                if (DtD_D != null)
                {
                    for (int i = 0; i <= DtD_D.Rows.Count - 1; i++)
                    {
                        arrayList.Clear();

                        arrayList.Add(DtD_D.Rows[i]["ITEM", DataRowVersion.Original].ToString());
                        arrayList.Add(DtD_D.Rows[i]["PERIOD", DataRowVersion.Original].ToString());
                        arrayList.Add(DtD_D.Rows[i]["VIRTUAL_CODE", DataRowVersion.Original].ToString());
                        arrayList.Add(DtD_D.Rows[i]["UPDATEDATE", DataRowVersion.Original].ToString());
                        arrayList.Add(DtD_D.Rows[i]["UPDATEUID", DataRowVersion.Original].ToString());
                        arrayList.Add(DateTime.Now);
                        arrayList.Add(UID);

                        dbo.DeleteGift(arrayList, DBT);
                    }
                    DtD_D.Clear();
                }

                #endregion

                #region Insert

                //if (DtD_A != null)
                //{
                //    for (int i = 0; i <= DtD_A.Rows.Count - 1; i++)
                //    {
                //        arrayList.Clear();

                //        arrayList.Add(M_ID);
                //        arrayList.Add(DtD_A.Rows[i]["FULLBARCODE"]);
                //        arrayList.Add(DtD_A.Rows[i]["BARCODE"]);
                //        arrayList.Add(DtD_A.Rows[i]["PERIOD_BARCODE"]);
                //        arrayList.Add(DtD_A.Rows[i]["ITEM"]);
                //        arrayList.Add(DtD_A.Rows[i]["ITEM_NAME"]);
                //        arrayList.Add(DtD_A.Rows[i]["PERIOD"]);
                //        arrayList.Add(DtD_A.Rows[i]["ITEM_MAP"]);
                //        arrayList.Add(int.Parse(DtD_A.Rows[i]["P_QTY"].ToString()));
                //        arrayList.Add(DtD_A.Rows[i]["P_CLASS"]);
                //        arrayList.Add(DtD_A.Rows[i]["P_NOTES"]);
                //        arrayList.Add(UID);

                //        dbo.InsertDetail(arrayList, DBT);
                //    }
                //    DtD_A.Clear();
                //}

                #endregion

                #region Update

                if (DtD_M != null)
                {
                    for (int i = 0; i <= DtD_M.Rows.Count - 1; i++)
                    {
                        arrayList.Clear();

                        arrayList.Add(DtD_M.Rows[i]["ITEM", DataRowVersion.Original].ToString());
                        arrayList.Add(DtD_M.Rows[i]["PERIOD", DataRowVersion.Original].ToString());
                        arrayList.Add(DtD_M.Rows[i]["VIRTUAL_CODE", DataRowVersion.Original].ToString());
                        arrayList.Add(DtD_M.Rows[i]["VIRTUAL_NAME", DataRowVersion.Original].ToString());
                        arrayList.Add(DtD_M.Rows[i]["PLAN_QTY", DataRowVersion.Original].ToString());
                        arrayList.Add(DtD_M.Rows[i]["UPDATEDATE", DataRowVersion.Original].ToString());
                        arrayList.Add(DtD_M.Rows[i]["UPDATEUID", DataRowVersion.Original].ToString());
                        arrayList.Add(DtD_M.Rows[i]["VIRTUAL_NAME", DataRowVersion.Current].ToString());
                        arrayList.Add(DtD_M.Rows[i]["PLAN_QTY", DataRowVersion.Current].ToString());
                        arrayList.Add(DateTime.Now);
                        arrayList.Add(UID);

                        dbo.UpdateGift(arrayList, DBT);
                    }
                    DtD_M.Clear();
                }

                #endregion

                #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

            }
        }
예제 #6
0
        /// <summary>
        /// 刪除VDS_MKT_STOREGIFT
        /// </summary>
        /// <param name="ParameterList">刪除變數</param>        
        public void DeleteStoreGift(ArrayList ParameterList)
        {
            try
            {
                MKT_GiftDBO dbo = new MKT_GiftDBO(ref USEDB);

                Conn = USEDB.CreateConnection();
                Conn.Open();
                DBT = Conn.BeginTransaction();

                dbo.doDeleteStoreGift(ParameterList, DBT);

                DBT.Commit();
            }
            catch (Exception ex)
            {
                if (DBT != null)
                    DBT.Rollback();

                throw ex;
            }
            finally
            {
                //獨立呼叫Transcation,關閉連線
                if (Conn.State == ConnectionState.Connecting)
                {
                    Conn.Close();
                }
            }
        }
예제 #7
0
        public void InsertGift(string strItem, string strPeriod, string strUID, DataTable Dt, DbTransaction RootDBT)
        {
            bool IsRootTranscation = false;
            ArrayList al = new ArrayList();
            string strVirtualCode = string.Empty;

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

                for (int i = 0; i < Dt.Rows.Count; i++)
                {
                    al.Clear();
                    al.Add(strItem);
                    al.Add(strPeriod);

                    DataTable dt_Code = NextVirtualCode(al, DBT);

                    if (dt_Code.Rows.Count == 0)
                    {
                        throw new Exception("查無此商品");
                    }
                    else
                    {

                        strVirtualCode = dt_Code.Rows[0][0].ToString();

                        al.Clear();

                        al.Add(strVirtualCode);
                        al.Add(Dt.Rows[i]["VIRTUAL_NAME"].ToString());
                        al.Add(strItem);
                        al.Add(strPeriod);
                        al.Add(strUID);
                        al.Add(Dt.Rows[i]["PLAN_QTY"].ToString());

                        dbo.InsertGift(al, DBT);

                        //al.Clear();
                        //al.Add(strVirtualCode);
                        //al.Add(Dt.Rows[i]["VIRTUAL_NAME"].ToString());
                        //al.Add(strItem);
                        //al.Add(strPeriod);
                        //al.Add(strUID);

                        //dbo.InsertGiftProfile(al, DBT);
                    }

                }

                #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

            }
        }
예제 #8
0
 public DataTable NextVirtualCode(ArrayList ParameterList, DbTransaction RootDBT)
 {
     try
     {
         DBO.MKT_GiftDBO dbo = new MKT_GiftDBO(ref USEDB);
         return dbo.NextVirtualCode(ParameterList, RootDBT);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #9
0
 //檢查是否配本過了 true:有 false:沒有
 public int ChkDis(ArrayList ParameterList)
 {
     try
     {
         DBO.MKT_GiftDBO dbo = new MKT_GiftDBO(ref USEDB);
         return dbo.ChkDis(ParameterList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #10
0
        public int CheckApprove(ArrayList ParameterList)
        {
            try
            {
                int intCnt = 0;

                DBO.MKT_GiftDBO dbo = new MKT_GiftDBO(ref USEDB);
                intCnt = dbo.CheckApprove(ParameterList);

                return intCnt;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #11
0
 /// <summary>
 /// 取得ItemData
 /// </summary>
 /// <param name="ParameterList"></param>
 /// <returns></returns>
 public DataTable GetItemDataByItem(ArrayList ParameterList)
 {
     try
     {
         DBO.MKT_GiftDBO dbo = new MKT_GiftDBO(ref USEDB);
         return dbo.GetItemDataByItem(ParameterList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #12
0
 /// <summary>
 /// 取得下一個虛擬品號流水號
 /// </summary>
 /// <param name="ParameterList"></param>
 /// <returns></returns>
 public DataTable GetNextVirtualCode(ArrayList ParameterList)
 {
     try
     {
         DBO.MKT_GiftDBO dbo = new MKT_GiftDBO(ref USEDB);
         return dbo.GetNextVirtualCode(ParameterList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #13
0
        public DataTable QueryUnionItemByLikeForSLP(ArrayList ParameterList)
        {
            try
            {
                DBO.MKT_GiftDBO dbo = new MKT_GiftDBO(ref USEDB);

                //modify by jsy 2009/05/27 
                if (ParameterList[0].ToString().Trim() != "")
                {
                    ParameterList[0] = "%" + ParameterList[0] + "%";//ITEM
                }
                if (ParameterList[1].ToString().Trim() != "")
                {
                    ParameterList[1] = "%" + ParameterList[1] + "%"; //PERIOD
                }

                if (ParameterList[2].ToString().Trim() != "")
                {
                    ParameterList[2] = "%" + ParameterList[2] + "%"; //VIRTUAL_NAME
                }
                /* 
                ParameterList[0] = ParameterList[0] + "%"; 
                ParameterList[1] = ParameterList[1] + "%"; 
                ParameterList[2] = ParameterList[2] + "%"; //VIRTUAL_NAME
                 */

                ParameterList[3] = ParameterList[3]; //ROWNUM
                return dbo.doQueryUnionItemByLikeForSLP(ParameterList);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }