Ejemplo n.º 1
0
        public HttpResponseBase AreaSave()
        {
            string json = string.Empty;
            try
            {
                PageAreaQuery ba = new PageAreaQuery();
                _pageAreaMgr = new PageAreaMgr(mySqlConnectionString);
                if (string.IsNullOrEmpty(Request.Params["id"]))
                {
                    if (!string.IsNullOrEmpty(Request.Params["name"]))
                    {
                        ba.area_name = Request.Params["name"].ToString();
                    }
                    if (!string.IsNullOrEmpty(Request.Params["element_type"]))
                    {
                        ba.element_type = Convert.ToInt32(Request.Params["element_type"]);
                    }

                    if (!string.IsNullOrEmpty(Request.Params["area_desc"]))
                    {
                        ba.area_desc = Request.Params["area_desc"].ToString();
                    }
                    if (!string.IsNullOrEmpty(Request.Params["show_number"]))
                    {
                        ba.show_number = Convert.ToInt32(Request.Params["show_number"]);
                    }
                    if (!string.IsNullOrEmpty(Request.Params["area_element_id"]))
                    {
                        ba.area_element_id = Request.Params["area_element_id"].ToString();
                    }
                    ba.create_userid = (Session["caller"] as Caller).user_id;
                    ba.update_userid = (Session["caller"] as Caller).user_id;
                    ba.area_updatedate = DateTime.Now;
                    ba.area_createdate = DateTime.Now;
                    IPageAreaImplMgr _ibamgr = new PageAreaMgr(mySqlConnectionString);
                    int i = _ibamgr.AreaSave(ba);
                    if (i > 0)
                    {
                        json = "{success:true}";
                    }
                }
                else
                {
                    PageAreaQuery oldBa = _pageAreaMgr.GetBannerByAreaId(Convert.ToInt32(Request.Params["id"]));
                    ba.area_id = Convert.ToInt32(Request.Params["id"]);

                    ba.area_name = Request.Params["name"].ToString();

                    if (!string.IsNullOrEmpty(Request.Params["element_type"]))
                    {
                        ba.element_type = Convert.ToInt32(Request.Params["element_type"]);
                    }

                    ba.area_desc = Request.Params["area_desc"].ToString();


                    ba.show_number = Convert.ToInt32(Request.Params["show_number"]);


                    ba.area_element_id = Request.Params["area_element_id"].ToString();

                    ba.update_userid = (Session["caller"] as Caller).user_id;
                    ba.area_updatedate = DateTime.Now;
                    ba.area_status = oldBa.area_status;
                    int j = _pageAreaMgr.Update(ba);
                    if (j > 0)
                    {
                        json = "{success:true}";
                    }
                }


            }
            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);
                json = "{success:true,data:[]}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Ejemplo n.º 2
0
        public HttpResponseBase PageAreaList()
        {
            List<PageAreaQuery> stores = new List<PageAreaQuery>();

            string json = string.Empty;
            try
            {
                PageAreaQuery query = new PageAreaQuery();
                query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
                query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "20");//用於分頁的變量
                if (!string.IsNullOrEmpty(Request["serchcontent"]))
                {
                    query.serchcontent = Request["serchcontent"];
                }
                if (!string.IsNullOrEmpty(Request["search_type"]))
                {
                    query.element_type = Convert.ToInt32(Request["search_type"]);
                }
                _pageAreaMgr = new PageAreaMgr(mySqlConnectionString);
                int totalCount = 0;
                query.create_userid = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
                stores = _pageAreaMgr.QueryAll(query, out totalCount);
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                //listUser是准备转换的对象
                json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(stores, 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);
                json = "{success:true,totalCount:0,data:[]}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }