Exemplo n.º 1
0
        public ActionResult SavePromoAmountFare()
        {
            try
            {
                string promoAmountFareStr = Request.Params["promoAmountFareStr"];
                string condiType = Request.Params["condiType"];
                EventPromoAmountFare promoAmountFareModel = JsonConvert.DeserializeObject<EventPromoAmountFare>(promoAmountFareStr);
                iepaFareMgr = new EventPromoAmountFareMgr(mySqlConnectionString);
                return Json(new { success = iepaFareMgr.SavePromoAmountFare(promoAmountFareModel, condiType) });
            }
            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) });
            }

        }
Exemplo n.º 2
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) });
            }

        }
Exemplo n.º 3
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;
        }