Пример #1
0
        public JsonResult UpdateActiveFare()
        {
            try
            {
                int currentUser = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
                int activeValue = Convert.ToInt32(Request.Params["active"]);
                if (Convert.ToInt32(Request.Params["mo_user"]) == currentUser && activeValue == 1)
                {
                    return Json(new { success = "stop" });
                }
                else
                {


                    string event_id = Request.Params["event_id"].ToString();
                    EventPromoAmountFare model = new EventPromoAmountFare();
                    model.modify_user = currentUser;
                    model.modify_time = DateTime.Now;
                    model.event_id = event_id;
                    model.event_status = activeValue;
                    model.condition_type = Convert.ToInt32(Request.Params["type"]);
                    iepaFareMgr = new EventPromoAmountFareMgr(mySqlConnectionString);

                    if (iepaFareMgr.UpdateActive(model))
                    {
                        return Json(new { success = "true" });
                    }
                    else
                    {
                        return Json(new { success = "false" });
                    }
                }
            }
            catch (Exception ex)
            {
                //加入資料庫異常捕捉

                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                return Json(new { success = "false", error = BLL.gigade.Common.CommonFunction.MySqlException(ex) });
            }

        }
Пример #2
0
        public HttpResponseBase GetPromoAmountFare()
        {
            string jsonStr = "{success:false}";

            try
            {
                EventPromoAmountFare query = new EventPromoAmountFare();
                query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");
                query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "0");

                if (!string.IsNullOrEmpty(Request.Params["event_id"]))
                {
                    query.event_id = Request.Params["event_id"];
                }
                if (!string.IsNullOrEmpty(Request.Params["event_name"]))
                {
                    query.event_name = Request.Params["event_name"];
                }
                int totalCount = 0;

                iepaFareMgr = new EventPromoAmountFareMgr(mySqlConnectionString);
                List<EventPromoAmountFare> _list = iepaFareMgr.GetList(query, out totalCount);

                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                jsonStr = "{success:true,totalCount:" + totalCount + ",item:" + JsonConvert.SerializeObject(_list, Formatting.Indented, timeConverter) + "}";//返回json數據
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                jsonStr = "{success:false,error:\"" + BLL.gigade.Common.CommonFunction.MySqlException(ex) + "\"}";

            }
            this.Response.Clear();
            this.Response.Write(jsonStr.ToString());
            this.Response.End();
            return this.Response;
        }
Пример #3
0
        public bool UpdateActive(EventPromoAmountFare model)
        {
            ArrayList _list = new ArrayList();
            try
            {
                _list.Add(_iepaFareDao.UpdateActive(model));
                //處理輔表活動商品設定
                if (model.condition_type == 1)
                {
                    EventPromoBrandDao _epbDao = new EventPromoBrandDao(_conn);
                    _list.Add(_epbDao.UpdateActive(new EventPromoBrand { event_status = model.event_status, modify_user = model.modify_user, modify_time = model.modify_time, event_id = model.event_id }));
                }
                else if (model.condition_type == 2)
                {
                    EventPromoCategoryDao _epcateDao = new EventPromoCategoryDao(_conn);
                    _list.Add(_epcateDao.UpdateActive(new EventPromoCategory { event_status = model.event_status, modify_user = model.modify_user, modify_time = model.modify_time, event_id = model.event_id }));
                }
                else if (model.condition_type == 3)
                {
                    EventPromoClassDao _epclassDao = new EventPromoClassDao(_conn);
                    _list.Add(_epclassDao.UpdateActive(new EventPromoClass { event_status = model.event_status, modify_user = model.modify_user, modify_time = model.modify_time, event_id = model.event_id }));
                }
                else if (model.condition_type == 4)
                {
                    EventPromoProductDao _epproDao = new EventPromoProductDao(_conn);
                    _list.Add(_epproDao.UpdateActive(new EventPromoProduct { event_status = model.event_status, modify_user = model.modify_user, modify_time = model.modify_time, event_id = model.event_id }));

                }
                else if (model.condition_type == 5)
                {
                    EventPromoShoppingcartDao _epcartDao = new EventPromoShoppingcartDao(_conn);
                    _list.Add(_epcartDao.UpdateActive(new EventPromoShoppingcart { event_status = model.event_status, modify_user = model.modify_user, modify_time = model.modify_time, event_id = model.event_id }));
                }
                else if (model.condition_type == 6)
                {
                    EventPromoPaymentDao _eppayDao = new EventPromoPaymentDao(_conn);
                    _list.Add(_eppayDao.UpdateActive(new EventPromoPayment { event_status = model.event_status, modify_user = model.modify_user, modify_time = model.modify_time, event_id = model.event_id }));

                }
                MySqlDao _mySqlDao = new MySqlDao(_conn);
                return _mySqlDao.ExcuteSqls(_list);

            }
            catch (MySqlException ex)
            {
                throw new Exception(ex.Number.ToString() + ":EventPromoAmountFareMgr-->UpdateActive-->" + ex.Message, ex);
            }
            catch (Exception ex)
            {
                throw new Exception("EventPromoAmountFareMgr-->UpdateActive-->" + ex.Message, ex);
            }
        }
Пример #4
0
        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;
        }
Пример #5
0
        public ArrayList InsertCondiType(EventPromoAmountFare epaFare, string condiType)
        {
            ArrayList _list = new ArrayList();
            if (!string.IsNullOrEmpty(condiType))
            {
                var arryType = condiType.Split(',');
                if (epaFare.condition_type == 1)//按品牌
                {
                    foreach (string iType in arryType)
                    {
                        EventPromoBrand epb = new EventPromoBrand();
                        epb.event_type = epaFare.event_type;
                        epb.site_id = epaFare.site_id;
                        epb.brand_id = Convert.ToInt32(iType);
                        epb.event_id = epaFare.event_id;
                        epb.event_status = epaFare.event_status;
                        epb.create_user = epaFare.modify_user;
                        epb.create_time = epaFare.modify_time;
                        epb.modify_user = epb.create_user;
                        epb.modify_time = epb.create_time;
                        epb.event_start = epaFare.event_start;
                        epb.event_end = epaFare.event_end;
                        EventPromoBrandDao _epbDao = new EventPromoBrandDao(_conn);
                        _list.Add(_epbDao.AddOrUpdate(epb));

                    }
                }
                else if (epaFare.condition_type == 2)//類別
                {
                    foreach (string iType in arryType)
                    {
                        EventPromoCategory epcate = new EventPromoCategory();
                        epcate.event_type = epaFare.event_type;
                        epcate.site_id = epaFare.site_id;
                        epcate.category_id = Convert.ToInt32(iType);
                        epcate.event_id = epaFare.event_id;
                        epcate.event_status = epaFare.event_status;
                        epcate.create_user = epaFare.modify_user;
                        epcate.create_time = epaFare.modify_time;
                        epcate.modify_user = epcate.create_user;
                        epcate.modify_time = epcate.create_time;
                        epcate.event_start = epaFare.event_start;
                        epcate.event_end = epaFare.event_end;
                        EventPromoCategoryDao _epcateDao = new EventPromoCategoryDao(_conn);
                        _list.Add(_epcateDao.AddOrUpdate(epcate));

                    }
                }
                else if (epaFare.condition_type == 3)//館別
                {
                    foreach (string iType in arryType)
                    {
                        EventPromoClass epclass = new EventPromoClass();
                        epclass.event_type = epaFare.event_type;
                        epclass.site_id = epaFare.site_id;
                        epclass.class_id = Convert.ToInt32(iType);
                        epclass.event_id = epaFare.event_id;
                        epclass.event_status = epaFare.event_status;
                        epclass.create_user = epaFare.modify_user;
                        epclass.create_time = epaFare.modify_time;
                        epclass.modify_user = epclass.create_user;
                        epclass.modify_time = epclass.create_time;
                        epclass.event_start = epaFare.event_start;
                        epclass.event_end = epaFare.event_end;
                        EventPromoClassDao _epclassDao = new EventPromoClassDao(_conn);
                        _list.Add(_epclassDao.AddOrUpdate(epclass));

                    }
                }
                else if (epaFare.condition_type == 4)//商品
                {
                    foreach (string iType in arryType)
                    {
                        var arryPro = iType.Split('&');
                        EventPromoProduct eppro = new EventPromoProduct();
                        eppro.event_type = epaFare.event_type;
                        eppro.site_id = epaFare.site_id;
                        eppro.product_id = Convert.ToInt32(arryPro[0]);
                        eppro.product_num_limit = Convert.ToInt32(arryPro[1]);
                        eppro.event_id = epaFare.event_id;
                        eppro.event_status = epaFare.event_status;
                        eppro.create_user = epaFare.modify_user;
                        eppro.create_time = epaFare.modify_time;
                        eppro.modify_user = eppro.create_user;
                        eppro.modify_time = eppro.create_time;
                        eppro.event_start = epaFare.event_start;
                        eppro.event_end = epaFare.event_end;
                        EventPromoProductDao _epproDao = new EventPromoProductDao(_conn);
                        _list.Add(_epproDao.AddOrUpdate(eppro));

                    }
                }
                else if (epaFare.condition_type == 5)//購物車
                {

                    foreach (string iType in arryType)
                    {
                        EventPromoShoppingcart epcart = new EventPromoShoppingcart();
                        epcart.event_type = epaFare.event_type;
                        //epcart.site_id = epaFare.site_id;
                        epcart.cart_id = Convert.ToInt32(iType);
                        epcart.event_id = epaFare.event_id;
                        epcart.event_status = epaFare.event_status;
                        epcart.create_user = epaFare.modify_user;
                        epcart.create_time = epaFare.modify_time;
                        epcart.modify_user = epcart.create_user;
                        epcart.modify_time = epcart.create_time;
                        epcart.event_start = epaFare.event_start;
                        epcart.event_end = epaFare.event_end;
                        EventPromoShoppingcartDao _epcartDao = new EventPromoShoppingcartDao(_conn);
                        _list.Add(_epcartDao.AddOrUpdate(epcart));

                    }
                }
                else if (epaFare.condition_type == 6)//付款方式
                {

                    foreach (string iType in arryType)
                    {
                        EventPromoPayment eppay = new EventPromoPayment();
                        eppay.event_type = epaFare.event_type;
                        eppay.site_id = epaFare.site_id;
                        eppay.payment_id = Convert.ToInt32(iType);
                        eppay.event_id = epaFare.event_id;
                        eppay.event_status = epaFare.event_status;
                        eppay.create_user = epaFare.modify_user;
                        eppay.create_time = epaFare.modify_time;
                        eppay.modify_user = eppay.create_user;
                        eppay.modify_time = eppay.create_time;
                        eppay.event_start = epaFare.event_start;
                        eppay.event_end = epaFare.event_end;
                        EventPromoPaymentDao _eppayDao = new EventPromoPaymentDao(_conn);
                        _list.Add(_eppayDao.AddOrUpdate(eppay));

                    }
                }

            }
            return _list;
        }