Example #1
0
        public void Post()
        {
            string Data = DataObj.GetData();

            if (Data.IsNullOrEmpty())
            {
                DataObj.OutError("1000");
                return;
            }
            JObject json = new JObject();

            try
            {
                json = (JObject)JsonConvert.DeserializeObject(Data);
            }
            catch (Exception Ex)
            {
                Log.Write("[BasicDistrict]:", "【Data】" + Data, Ex);
            }
            if (json == null)
            {
                DataObj.OutError("1000");
                return;
            }
            BasicDistrict BasicDistrict = new BasicDistrict();

            BasicDistrict = JsonToObject.ConvertJsonToModel(BasicDistrict, json);

            IList <BasicDistrict> BasicDistrictList = Entity.BasicDistrict.Where(n => n.State == 1 && n.CId == BasicDistrict.CId).ToList();

            DataObj.Data = BasicDistrictList.EntityToJson();
            DataObj.Code = "0000";
            DataObj.OutString();
        }
        public void Save(BasicDistrict BasicDistrict)
        {
            BasicDistrict baseBasicDistrict = Entity.BasicDistrict.FirstOrDefault(n => n.Id == BasicDistrict.Id);

            baseBasicDistrict = Request.ConvertRequestToModel <BasicDistrict>(baseBasicDistrict, BasicDistrict);
            Entity.SaveChanges();
            BaseRedirect();
        }
        public void ChangeStatus(BasicDistrict BasicDistrict, string InfoList, string Clomn, string Value)
        {
            if (string.IsNullOrEmpty(InfoList))
            {
                InfoList = BasicDistrict.Id.ToString();
            }
            int Ret = Entity.ChangeEntity <BasicDistrict>(InfoList, Clomn, Value);

            Entity.SaveChanges();
            Response.Write(Ret);
        }
        public void Delete(BasicDistrict BasicDistrict, string InfoList, int?IsDel)
        {
            if (string.IsNullOrEmpty(InfoList))
            {
                InfoList = BasicDistrict.Id.ToString();
            }
            int Ret = Entity.MoveToDeleteEntity <BasicDistrict>(InfoList, IsDel, AdminUser.UserName);

            Entity.SaveChanges();
            Response.Write(Ret);
        }
 public ActionResult Edit(BasicDistrict BasicDistrict)
 {
     if (BasicDistrict.Id != 0)
     {
         BasicDistrict = Entity.BasicDistrict.FirstOrDefault(n => n.Id == BasicDistrict.Id);
     }
     if (BasicDistrict == null)
     {
         ViewBag.ErrorMsg = "数据不存在";
         return(View("Error"));
     }
     ViewBag.BasicDistrict     = BasicDistrict;
     ViewBag.BasicProvinceList = Entity.BasicProvince.Where(n => n.State == 1).ToList();
     ViewBag.BasicCityList     = Entity.BasicCity.Where(n => n.State == 1).ToList();
     if (Request.UrlReferrer != null)
     {
         Session["Url"] = Request.UrlReferrer.ToString();
     }
     return(View());
 }
        public ActionResult Index(BasicDistrict BasicDistrict, EFPagingInfo <BasicDistrict> p, int IsFirst = 0)
        {
            IPageOfItems <BasicDistrict> BasicDistrictList = null;

            if (!BasicDistrict.CId.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.CId == BasicDistrict.CId);
            }
            if (!BasicDistrict.Name.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.Name.Contains(BasicDistrict.Name));
            }
            if (!BasicDistrict.State.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.State == (BasicDistrict.State == 99 ? 0 : BasicDistrict.State));
            }
            p.OrderByList.Add("Id", "DESC");
            if (IsFirst == 0)
            {
                BasicDistrictList = new PageOfItems <BasicDistrict>(new List <BasicDistrict>(), 0, 10, 0, new Hashtable());
            }
            else
            {
                BasicDistrictList = Entity.Selects <BasicDistrict>(p);
            }

            ViewBag.BasicDistrictList = BasicDistrictList;
            ViewBag.BasicDistrict     = BasicDistrict;
            ViewBag.BasicProvinceList = Entity.BasicProvince.Where(n => n.State == 1).ToList();
            ViewBag.BasicCityList     = Entity.BasicCity.Where(n => n.State == 1).ToList();
            ViewBag.Add    = this.checkPower("Add");
            ViewBag.Edit   = this.checkPower("Edit");
            ViewBag.Delete = this.checkPower("Delete");
            ViewBag.Save   = this.checkPower("Save");
            return(View());
        }
 public void Add(BasicDistrict BasicDistrict)
 {
     Entity.BasicDistrict.AddObject(BasicDistrict);
     Entity.SaveChanges();
     BaseRedirect();
 }