public bool SavePromoAmountDiscount(Model.EventPromoAmountDiscount epadmodel, List<Model.EventPromoDiscount> epdmodels, string condiType)
        {
            ArrayList _list = new ArrayList();
            MySqlCommand mySqlCmd = new MySqlCommand();
            MySqlConnection mySqlConn = new MySqlConnection(conn);
            try
            {
                if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Closed)
                {
                    mySqlConn.Open();
                }
                mySqlCmd.Connection = mySqlConn;
                mySqlCmd.Transaction = mySqlConn.BeginTransaction();
                mySqlCmd.CommandType = System.Data.CommandType.Text;
                if (epadmodel.row_id == 0)//新增
                {
                    epadmodel.event_type = "AB";
                    epadmodel.create_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
                    epadmodel.create_time = DateTime.Now;
                    epadmodel.modify_user = epadmodel.create_user;
                    epadmodel.modify_time = epadmodel.create_time;
                    mySqlCmd.CommandText = IDiscountDao.AddOrUpdate(epadmodel);
                    epadmodel.row_id = Convert.ToInt32(mySqlCmd.ExecuteScalar());
                    epadmodel.event_id = Common.CommonFunction.GetEventId(epadmodel.event_type, epadmodel.row_id.ToString());

                    _list.Add(IDiscountDao.UpdateEventId(epadmodel.row_id, epadmodel.event_id));

                    //處理輔表event_promo_gift
                    EventPromoDiscountDao _epgDao = new EventPromoDiscountDao(conn);
                    foreach (EventPromoDiscount item in epdmodels)
                    {
                        item.event_id = epadmodel.event_id;
                        item.create_user = epadmodel.create_user;
                        item.create_time = epadmodel.create_time;
                        item.modify_user = item.create_user;
                        item.modify_time = item.create_time;
                        _list.Add(_epgDao.AddOrUpdate(item));
                    }

                    //處理輔表活動商品設定
                    _list.AddRange(InsertCondiType(epadmodel, condiType));
                }
                else//編輯 
                {
                    //處理主表event_promo_amount_gift
                    epadmodel.event_type = "AB";
                    epadmodel.modify_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
                    epadmodel.modify_time = DateTime.Now;
                    epadmodel.create_user = epadmodel.modify_user;
                    epadmodel.create_time = epadmodel.modify_time;

                    epadmodel.event_id = Common.CommonFunction.GetEventId(epadmodel.event_type, epadmodel.row_id.ToString());
                    _list.Add(IDiscountDao.AddOrUpdate(epadmodel));

                    //處理輔表event_promo_gift
                    EventPromoDiscountDao _epdDao = new EventPromoDiscountDao(conn);
                    string discount_ids = "";
                    foreach (EventPromoDiscount item in epdmodels)
                    {
                        item.event_id = epadmodel.event_id;
                        item.modify_user = epadmodel.modify_user;
                        item.modify_time = epadmodel.modify_time;

                        _list.Add(_epdDao.AddOrUpdate(item));
                        if (item.discount_id != 0)
                        {
                            discount_ids = discount_ids + item.discount_id + ",";
                        }
                    }

                    discount_ids = discount_ids.TrimEnd(',');
                    var arr_new_g = discount_ids.Split(',');
                    //獲取本次修改刪除的discount_id,先獲取現有的除新增外的discount,那麼原有的不在其中的discount則是刪除的

                    List<EventPromoDiscount> models = _epdDao.GetList(epadmodel.event_id);
                    string del_g = string.Empty;//存放本次刪除的discount
                    foreach (EventPromoDiscount item in models)
                    {
                        if (!arr_new_g.Contains(item.discount_id.ToString()))
                        {
                            del_g = del_g + item.discount_id.ToString() + ",";
                        }
                    }
                    if (!string.IsNullOrEmpty(del_g))
                    {
                        del_g = del_g.TrimEnd(',');
                        _list.Add(_epdDao.Delete(epadmodel.event_id, del_g));

                    }


                    //處理輔表活動商品設定
                    EventPromoBrandDao _epbDao = new EventPromoBrandDao(conn);
                    _list.Add(_epbDao.Delete(epadmodel.event_id));
                    EventPromoCategoryDao _epcateDao = new EventPromoCategoryDao(conn);
                    _list.Add(_epcateDao.Delete(epadmodel.event_id));
                    EventPromoClassDao _epclassDao = new EventPromoClassDao(conn);
                    _list.Add(_epclassDao.Delete(epadmodel.event_id));
                    EventPromoPaymentDao _eppayDao = new EventPromoPaymentDao(conn);
                    _list.Add(_eppayDao.Delete(epadmodel.event_id));
                    EventPromoShoppingcartDao _epcartDao = new EventPromoShoppingcartDao(conn);
                    _list.Add(_epcartDao.Delete(epadmodel.event_id));
                    EventPromoProductDao _epproDao = new EventPromoProductDao(conn);
                    _list.Add(_epproDao.Delete(epadmodel.event_id));

                    _list.AddRange(InsertCondiType(epadmodel, condiType));

                }

                for (int i = 0; i < _list.Count; i++)
                {
                    mySqlCmd.CommandText = _list[i].ToString();
                    mySqlCmd.ExecuteNonQuery();
                }
                mySqlCmd.Transaction.Commit();
                return true;

            }
            catch (Exception ex)
            {
                mySqlCmd.Transaction.Rollback();
                return false;
                throw new Exception("EventPromoAmountDiscountMgr-->SavePromoAmountDiscount" + ex.Message, ex);
            }
            finally
            {
                if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Open)
                {
                    mySqlConn.Close();
                }
            }
        }
       //保存活動
       public bool SaveEventPromoAdditionalPrice(EventPromoAdditionalPrice model, List<EventPromoAdditionalPriceProduct> models, string condiType)
       {
           ArrayList _list = new ArrayList();
           MySqlCommand mySqlCmd = new MySqlCommand();
           MySqlConnection mySqlConn = new MySqlConnection(conn);
           try
           {
               if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Closed)
               {
                   mySqlConn.Open();
               }
               mySqlCmd.Connection = mySqlConn;
               mySqlCmd.Transaction = mySqlConn.BeginTransaction();
               mySqlCmd.CommandType = System.Data.CommandType.Text;
               if (model.row_id == 0)//新增
               {                          
                   model.event_type = "AD";
                   model.create_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
                   model.create_time = DateTime.Now;
                   mySqlCmd.CommandText = dao.AddOrUpdate(model);
                   model.row_id =Convert.ToInt32(mySqlCmd.ExecuteScalar());
                   model.modify_user = model.create_user;
                   model.modify_time = model.create_time;
                   model.event_id = Common.CommonFunction.GetEventId(model.event_type, model.row_id.ToString());
                   _list.Add(dao.AddOrUpdate(model));

                   //處理輔表
                   EventPromoAdditionalPriceProductDao _epgDao = new EventPromoAdditionalPriceProductDao(conn);
                   foreach (EventPromoAdditionalPriceProduct item in models)
                   {
                       item.group_id = model.group_id;
                       item.create_user = model.create_user;
                       item.create_time = model.create_time;
                       item.modify_user = item.create_user;
                       item.modify_time = item.create_time;
                       _list.Add(_epgDao.AddOrUpdate(item));
                   }

                   //處理輔表活動商品設定
                   _list.AddRange(InsertCondiType(model, condiType));
               }
               else//編輯 
               {
                   model.event_type = "AD";
                   model.modify_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
                   model.modify_time = DateTime.Now;
                   model.event_id = Common.CommonFunction.GetEventId(model.event_type, model.row_id.ToString());
                   _list.Add(dao.AddOrUpdate(model));

                   EventPromoAdditionalPriceProductDao _epdDao = new EventPromoAdditionalPriceProductDao(conn);
                   string row_ids = "";
                   foreach (EventPromoAdditionalPriceProduct item in models)
                   {
                       item.modify_user = model.modify_user;
                       item.modify_time = model.modify_time;

                       _list.Add(_epdDao.AddOrUpdate(item));
                       if (item.row_id != 0)
                       {
                           row_ids = row_ids + item.row_id + ",";
                       }
                   }

                   row_ids = row_ids.TrimEnd(',');
                   var row_id = row_ids.Split(',');
                   EventPromoAdditionalPriceProductQuery product = new EventPromoAdditionalPriceProductQuery();
                   product.group_id = model.group_id;
                   List<EventPromoAdditionalPriceProductQuery> product_models = _epdDao.GetList(product);
                   string del_row_ids = string.Empty;//存放本次刪除的
                   foreach (EventPromoAdditionalPriceProduct item in product_models)
                   {
                       if (!row_id.Contains(item.row_id.ToString()))
                       {
                           del_row_ids = del_row_ids + item.row_id.ToString() + ",";
                       }
                   }
                   if (!string.IsNullOrEmpty(del_row_ids))
                   {
                       del_row_ids = del_row_ids.TrimEnd(',');
                       _list.Add(_epdDao.Delete(model.group_id.ToString(), del_row_ids));
                   }


                   //處理輔表活動商品設定
                   EventPromoBrandDao _epbDao = new EventPromoBrandDao(conn);
                   _list.Add(_epbDao.Delete(model.event_id));
                   EventPromoCategoryDao _epcateDao = new EventPromoCategoryDao(conn);
                   _list.Add(_epcateDao.Delete(model.event_id));
                   EventPromoClassDao _epclassDao = new EventPromoClassDao(conn);
                   _list.Add(_epclassDao.Delete(model.event_id));
                   EventPromoPaymentDao _eppayDao = new EventPromoPaymentDao(conn);
                   _list.Add(_eppayDao.Delete(model.event_id));
                   EventPromoShoppingcartDao _epcartDao = new EventPromoShoppingcartDao(conn);
                   _list.Add(_epcartDao.Delete(model.event_id));
                   EventPromoProductDao _epproDao = new EventPromoProductDao(conn);
                   _list.Add(_epproDao.Delete(model.event_id));

                   _list.AddRange(InsertCondiType(model, condiType));

               }

               for (int i = 0; i < _list.Count; i++)
               {
                   mySqlCmd.CommandText = _list[i].ToString();
                   mySqlCmd.ExecuteNonQuery();
               }
               mySqlCmd.Transaction.Commit();
               return true;

           }
           catch (Exception ex)
           {
               mySqlCmd.Transaction.Rollback();
               return false;
               throw new Exception("EventPromoAdditionalPriceMgr-->SaveEventPromoAdditionalPrice" + ex.Message, ex);
           }
           finally
           {
               if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Open)
               {
                   mySqlConn.Close();
               }
           }
       }
        public bool SavePromoAmountFare(EventPromoAmountFare epaFare, string condiType)
        {
            ArrayList _list = new ArrayList();
            MySqlCommand mySqlCmd = new MySqlCommand();
            MySqlConnection mySqlConn = new MySqlConnection(_conn);
            bool isSave = false;
            try
            {
                if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Closed)
                {
                    mySqlConn.Open();
                }
                mySqlCmd.Connection = mySqlConn;
                mySqlCmd.Transaction = mySqlConn.BeginTransaction();
                mySqlCmd.CommandType = System.Data.CommandType.Text;
                if (epaFare.row_id == 0)//新增
                {
                    //處理主表event_promo_amount_fare
                    epaFare.event_type = "AC";
                    epaFare.create_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
                    epaFare.create_time = DateTime.Now;
                    epaFare.modify_user = epaFare.create_user;
                    epaFare.modify_time = epaFare.create_time;

                    mySqlCmd.CommandText = _iepaFareDao.AddOrUpdate(epaFare);
                    epaFare.row_id = Convert.ToInt32(mySqlCmd.ExecuteScalar());
                    epaFare.event_id = Common.CommonFunction.GetEventId(epaFare.event_type, epaFare.row_id.ToString());

                    _list.Add(_iepaFareDao.UpdateEventId(epaFare.row_id, epaFare.event_id));

                    //處理輔表活動商品設定
                    _list.AddRange(InsertCondiType(epaFare, condiType));
                }
                else//編輯 
                {
                    //處理主表event_promo_amount_fare
                    epaFare.event_type = "AC";
                    epaFare.modify_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
                    epaFare.modify_time = DateTime.Now;
                    epaFare.event_id = Common.CommonFunction.GetEventId(epaFare.event_type, epaFare.row_id.ToString());
                    _list.Add(_iepaFareDao.AddOrUpdate(epaFare));


                    //處理輔表活動商品設定
                    EventPromoBrandDao _epbDao = new EventPromoBrandDao(_conn);
                    _list.Add(_epbDao.Delete(epaFare.event_id));
                    EventPromoCategoryDao _epcateDao = new EventPromoCategoryDao(_conn);
                    _list.Add(_epcateDao.Delete(epaFare.event_id));
                    EventPromoClassDao _epclassDao = new EventPromoClassDao(_conn);
                    _list.Add(_epclassDao.Delete(epaFare.event_id));
                    EventPromoPaymentDao _eppayDao = new EventPromoPaymentDao(_conn);
                    _list.Add(_eppayDao.Delete(epaFare.event_id));
                    EventPromoShoppingcartDao _epcartDao = new EventPromoShoppingcartDao(_conn);
                    _list.Add(_epcartDao.Delete(epaFare.event_id));
                    EventPromoProductDao _epproDao = new EventPromoProductDao(_conn);
                    _list.Add(_epproDao.Delete(epaFare.event_id));

                    _list.AddRange(InsertCondiType(epaFare, condiType));

                }

                for (int i = 0; i < _list.Count; i++)
                {
                    mySqlCmd.CommandText = _list[i].ToString();
                    mySqlCmd.ExecuteNonQuery();
                }
                mySqlCmd.Transaction.Commit();
                isSave = true;

            }
            catch (MySqlException ex)
            {
                throw new Exception(ex.Number.ToString() + ":EventPromoAmountFareMgr-->SavePromoAmountFare" + ex.Message, ex);
            }
            catch (Exception ex)
            {
                mySqlCmd.Transaction.Rollback();
                throw new Exception("EventPromoAmountFareMgr-->SavePromoAmountFare" + ex.Message, ex);
            }
            finally
            {

                if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Open)
                {
                    mySqlConn.Close();
                }
            }
            return isSave;
        }