public string DicsSaveChanges(string jsonString, string action)
        {
            try
            {
                SysDicEntity  entity = JsonConvert.DeserializeObject <SysDicEntity>(jsonString);
                SysDicManager dm     = new SysDicManager();
                if (action == "add")
                {
                    entity.IsDisplay = "T";
                    entity.CreateBy  = SessionHelper.CurrentUser.Code;
                    entity.UpdateBy  = SessionHelper.CurrentUser.Code;

                    dm.Insert(entity);
                }
                else
                {
                    SysDicEntity oldEntity = dm.GetDicByID(entity.ID);

                    oldEntity.Name       = entity.Name;
                    oldEntity.ParentCode = entity.ParentCode;
                    oldEntity.Value      = entity.Value;
                    oldEntity.Type       = entity.Type;

                    oldEntity.UpdateBy   = SessionHelper.CurrentUser.Code;
                    oldEntity.UpdateTime = DateTime.Now;

                    dm.Update(oldEntity);
                }
                return("success");
            }
            catch (Exception e)
            {
                return(e.ToString());
            }
        }
Esempio n. 2
0
        public string PutDic(SysDicEntity entity)
        {
            try
            {
                //DictionaryViewModel model = JsonConvert.DeserializeObject<DictionaryViewModel>(jsonString.ToString());

                if (entity == null)
                {
                    return("error");
                }

                SysDicManager manager = new SysDicManager();

                entity.IsDisplay  = "T";
                entity.CreateTime = DateTime.Now;
                entity.CreateTime = DateTime.Now;

                manager.Update(entity);

                return("success");
            }
            catch (Exception e)
            {
                return(e.ToString());
            }
        }
Esempio n. 3
0
        public string DeleteDic(int id)
        {
            try
            {
                //DictionaryViewModel model = JsonConvert.DeserializeObject<DictionaryViewModel>(jsonString.ToString());

                SysDicManager manager = new SysDicManager();

                SysDicEntity entity = manager.GetDicByID(id);
                if (entity != null)
                {
                    entity.Valid      = "F";
                    entity.CreateTime = DateTime.Now;
                    entity.CreateTime = DateTime.Now;

                    manager.Update(entity);
                }

                return("success");
            }
            catch (Exception e)
            {
                return(e.ToString());
            }
        }
        public void GetAllDics()
        {
            //用于序列化实体类的对象
            JavaScriptSerializer jss = new JavaScriptSerializer();

            //请求中携带的条件
            string order     = HttpContext.Request.Params["order"];
            string sort      = HttpContext.Request.Params["sort"];
            string searchKey = HttpContext.Request.Params["search"];
            int    offset    = Convert.ToInt32(HttpContext.Request.Params["offset"]); //0
            int    pageSize  = Convert.ToInt32(HttpContext.Request.Params["limit"]);

            int                 total = 0;
            SysDicManager       dm    = new SysDicManager();
            List <SysDicEntity> list  = dm.GetSearch(searchKey, sort, order, offset, pageSize, out total);
            //List<DicViewModel> listView = new List<DicViewModel>();
            //foreach (var item in list)
            //{
            //    listView.Add(new DicViewModel { iId = item.iId, iKey = item.iKey, iValue = item.iValue, iType = item.iType, iUpdatedOn = item.iUpdatedOn.ToString("yyyyMMdd HH:mm") });
            //}

            //给分页实体赋值
            PageModels <SysDicEntity> model = new PageModels <SysDicEntity>();

            model.total = total;
            if (total % pageSize == 0)
            {
                model.page = total / pageSize;
            }
            else
            {
                model.page = (total / pageSize) + 1;
            }

            model.rows = list;

            //将查询结果返回
            HttpContext.Response.Write(jss.Serialize(model));
        }
Esempio n. 5
0
        public string GetAllDics(string order, string sort, string searchKey, int offset, int pageSize)
        {
            int                 total   = 0;
            SysDicManager       manager = new SysDicManager();
            List <SysDicEntity> list    = manager.GetSearch(searchKey, sort, order, offset, pageSize, out total);

            //给分页实体赋值
            PageModels <SysDicEntity> model = new PageModels <SysDicEntity>();

            model.total = total;
            if (total % pageSize == 0)
            {
                model.page = total / pageSize;
            }
            else
            {
                model.page = (total / pageSize) + 1;
            }

            model.rows = list;

            //将查询结果返回
            return(new JavaScriptSerializer().Serialize(model));
        }
Esempio n. 6
0
        public string GetDicByName(string name)
        {
            SysDicManager manager = new SysDicManager();

            return(new JavaScriptSerializer().Serialize(manager.GetDicByName(name)));
        }
Esempio n. 7
0
        public string GetDicByCode(string code)
        {
            SysDicManager manager = new SysDicManager();

            return(new JavaScriptSerializer().Serialize(manager.GetDicByCode(code)));
        }
Esempio n. 8
0
        public string GetDicByID(int id)
        {
            SysDicManager manager = new SysDicManager();

            return(new JavaScriptSerializer().Serialize(manager.GetDicByID(id)));
        }