示例#1
0
        public void Edit(int id, FormCollection collection)
        {
            var msg = new Msg();

            var Dorm = new Dorms();
            var dorm = Dorm.FindById(id);

            try
            {
                if (dorm == null)
                {
                    throw new Exception("该园区不存在");
                }
                dorm.Dorm_nickname  = collection["name"];
                dorm.Dorm_note      = collection["note"];
                dorm.Dorm_is_active = Convert.ToBoolean(collection["is_active"]);
                dorm.Dorm_type      = Convert.ToBoolean(Convert.ToInt32(collection["type"]));
                if (Dorm.Update(dorm))
                {
                    msg.Message = "保存成功!";
                }
                else
                {
                    throw new Exception("发生未知错误!");
                }
            }
            catch (Exception ex)
            {
                msg.Code    = -1;
                msg.Message = "保存失败:" + ex.Message;
            }
            Response.Write(msg.ToJson());
            Response.End();
        }
示例#2
0
        public void Delete(int id)
        {
            var msg  = new Msg();
            var User = new Dorms();
            var user = User.FindById(id);

            try
            {
                if (user == null)
                {
                    throw new Exception("该园区不存在!");
                }
                else
                {
                    if (User.Delete(id))
                    {
                        msg.Message = "删除成功!";
                    }
                    else
                    {
                        throw new Exception("发生未知错误,删除失败!");
                    }
                }
            }
            catch (Exception ex)
            {
                msg.Code    = -1;
                msg.Message = ex.Message;
            }
            Response.Write(msg.ToJson());
            Response.End();
        }
示例#3
0
        public ActionResult Edit(int id)
        {
            var Dorm = new Dorms();

            return(View(Dorm.FindById(id)));
        }