Exemple #1
0
        public void EditUser(HttpContext context)
        {
            //context.Response.ContentType = "application/json";
            string token = Request("token");

            string loginName = Request("loginName");
            string password  = Request("password");
            string mobile    = Request("mobile");
            string province  = Request("province");

            if (string.IsNullOrEmpty(token))
            {
                context.Response.Write(js.Serialize(BaseModels.ErrorLogin("登录已失效!")));
                return;
            }

            if (string.IsNullOrEmpty(loginName) || string.IsNullOrEmpty(password))
            {
                context.Response.Write(js.Serialize(BaseModels.Error("账号和密码不能为空!")));
                return;
            }

            context.Response.Write(js.Serialize(BaseModels.OK("修改成功!")));
            return;
        }
        public ActionResult SavePartFunc(int id, string funcIds)
        {
            if (string.IsNullOrEmpty(funcIds))
            {
                return(Json(BaseModels.Error("成功!")));
            }

            SysPartFuncBll bll = new SysPartFuncBll();

            List <SYS_PART_FUNC> allPF = bll.Query(t => t.PF_PART_ID == id).ToList();

            foreach (var pf in allPF)
            {
                bll.Delete(pf);
            }
            //bll.SaverChanges();

            string[] ids = funcIds.Split(',');
            foreach (var item in ids)
            {
                SYS_PART_FUNC model = new SYS_PART_FUNC();

                model.PF_PART_ID = id;
                model.PF_FN_ID   = item.ToInt();

                bll.Add(model, false);
            }
            bll.SaverChanges();

            return(Json(BaseModels.OK("成功!")));
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        public void AddUser(HttpContext context)
        {
            //context.Response.ContentType = "application/json";

            string loginName = Request("loginName");
            string password  = Request("password");
            string mobile    = Request("mobile");
            string province  = Request("province");


            if (string.IsNullOrEmpty(loginName) || string.IsNullOrEmpty(password))
            {
                context.Response.Write(js.Serialize(BaseModels.Error("账号和密码不能为空!")));
                return;
            }

            BLL.TtUsersBll bll  = new BLL.TtUsersBll();
            Model.TT_User  user = new Model.TT_User();

            user.LoginName = loginName;
            user.Password  = password;
            user.Mobile    = mobile;
            user.Province  = province;

            bll.Add(user);

            context.Response.Write(js.Serialize(BaseModels.OK("添加成功!")));
            return;
        }
Exemple #4
0
        /// <summary>
        /// 列表
        /// </summary>
        /// <param name="context"></param>
        public void ListUser(HttpContext context)
        {
            //context.Response.ContentType = "application/json";
            int pageCount = string.IsNullOrEmpty(Request("pageCount")) ? 10 : Request("pageCount").ToInt();
            int pageIndex = string.IsNullOrEmpty(Request("pageIndex")) ? 1 : Request("pageIndex").ToInt();
            int total     = 0;

            string loginName = Request("loginName");

            List <Hashtable> ret = new List <Hashtable>();

            for (int i = 0; i < 10; i++)
            {
                Hashtable ht = new Hashtable();
                ht["id"]        = (pageIndex - 1) * pageCount + i + 1;
                ht["loginName"] = string.IsNullOrEmpty(loginName) ? "张三" : loginName;
                ht["password"]  = "******";
                ht["mobile"]    = "15888888888";
                ht["province"]  = "杭州";
                ret.Add(ht);
            }

            Pager pager = new Pager();

            pager.total     = 88;
            pager.pageCount = pageCount;
            pager.pageIndex = pageIndex;
            context.Response.Write(js.Serialize(BaseModels.OK("查询成功!", ret, pager)));
            return;
        }
Exemple #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        public void GetUser(HttpContext context)
        {
            //context.Response.ContentType = "application/json";
            string token = Request("token");

            string id = Request("id");


            if (string.IsNullOrEmpty(token))
            {
                context.Response.Write(js.Serialize(BaseModels.ErrorLogin("登录已失效!")));
                return;
            }

            if (string.IsNullOrEmpty(id))
            {
                context.Response.Write(js.Serialize(BaseModels.Error("编码不能为空!")));
                return;
            }

            Hashtable ht = new Hashtable();

            ht["Id"]        = id;
            ht["loginName"] = "张双";
            ht["password"]  = "******";
            ht["mobile"]    = "15888888888";
            ht["province"]  = "杭州";

            context.Response.Write(js.Serialize(BaseModels.OK("查询成功!", ht)));
            return;
        }
Exemple #6
0
        /// <summary>
        /// 退出登录,清空cookie
        /// </summary>
        /// <returns></returns>
        public ActionResult Quit()
        {
            HttpCookie cookies = new HttpCookie("UserToken");

            cookies.Expires = DateTime.Now.AddDays(-1);
            Response.Cookies.Add(cookies);

            return(Json(BaseModels.OK("成功!")));
        }
Exemple #7
0
        /// <summary>
        /// file形式的文件上传
        /// </summary>
        /// <param name="context"></param>
        /// <param name="userid"></param>
        /// <param name="timestamp"></param>
        /// <returns></returns>
        public ReturnData UploadFile(HttpContext context, string timestamp)
        {
            HttpRequest    request = context.Request;
            HttpPostedFile file1   = context.Request.Files["file1"];

            if (file1 == null)
            {
                return(BaseModels.Error("上传文件不存在!"));
            }
            if (file1.ContentLength > 1024 * 1024 * 10)
            {
                return(BaseModels.Error("上传文件不可大于10M!"));
            }

            System.IO.BinaryReader reader = new System.IO.BinaryReader(file1.InputStream);
            string fileclass = "";

            for (int i = 0; i < 2; i++)
            {
                fileclass += reader.ReadByte().ToString();
            }
            if (fileclass != "255216" && fileclass != "13780" && fileclass != "6677" && fileclass != "3780" && fileclass != "8297" && fileclass != "8075")
            {
                return(BaseModels.Error("文件格式不正确!"));
            }
            string ext = ".jpg";

            if (fileclass == "3780")
            {
                ext = ".pdf";
            }
            if (fileclass == "8297")
            {
                ext = ".rar";
            }
            if (fileclass == "8075")
            {
                ext = ".zip";
            }

            string dpath    = "/userfile/trademark/" + DateTime.Now.ToString("yyyyMMdd") + "/";
            string filename = timestamp + ext;

            string msg      = "";
            bool   storeImg = StoreImg(context, file1, dpath, filename, out msg);

            if (storeImg)
            {
                return(BaseModels.OK(msg, new { filename = dpath + filename }));
            }
            else
            {
                return(BaseModels.Error(msg));
            }
        }
        public ActionResult FuncDel(int id)
        {
            SysFunctionBll bll   = new SysFunctionBll();
            SYS_FUNCTION   model = bll.Query(t => t.FN_ID == id).FirstOrDefault();

            if (model != null)
            {
                bll.Delete(model, true);
            }
            return(Json(BaseModels.OK("成功!")));
        }
        public ActionResult OrganDel(int id)
        {
            SysOrganizationBll bll   = new SysOrganizationBll();
            SYS_ORGANIZATION   model = bll.Query(t => t.ORG_ID == id).FirstOrDefault();

            if (model != null)
            {
                bll.Delete(model, true);
            }
            return(Json(BaseModels.OK("成功!")));
        }
        public ActionResult PartDel(int id)
        {
            UrPartBll bll   = new UrPartBll();
            UR_PART   model = bll.Query(t => t.PART_ID == id).FirstOrDefault();

            if (model != null)
            {
                bll.Delete(model, true);
            }
            return(Json(BaseModels.OK("成功!")));
        }
Exemple #11
0
        public ActionResult TypeDel(int id)
        {
            PdTypeBll bll   = new PdTypeBll();
            PD_TYPE   model = bll.Query(t => t.Id == id).FirstOrDefault();

            if (model != null)
            {
                bll.Delete(model, true);
            }
            return(Json(BaseModels.OK("成功!")));
        }
Exemple #12
0
        public ActionResult KefuDel(int id)
        {
            TtKefuBll bll   = new TtKefuBll();
            TT_Kefu   model = bll.Query(t => t.Id == id).FirstOrDefault();

            if (model != null)
            {
                bll.Delete(model, true);
            }
            return(Json(BaseModels.OK("成功!")));
        }
Exemple #13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        public void ListUser(HttpContext context)
        {
            //context.Response.ContentType = "application/json";

            int pageCount = string.IsNullOrEmpty(Request("pageCount")) ? 10 : Request("pageCount").ToInt();
            int pageIndex = string.IsNullOrEmpty(Request("pageIndex")) ? 1 : Request("pageIndex").ToInt();
            int total     = 0;

            string loginName = Request("loginName");
            string province  = Request("province");


            var predicate = PredicateBuilder.New <Model.TT_User>(true);

            if (!string.IsNullOrEmpty(loginName))
            {
                predicate = predicate.And(t => t.LoginName.Contains(loginName));
            }
            if (!string.IsNullOrEmpty(province))
            {
                predicate = predicate.And(t => t.Province == province);
            }

            BLL.TtUsersBll       bll     = new BLL.TtUsersBll();
            List <Model.TT_User> allUser = bll.QueryByPage(pageIndex, pageCount, out total, predicate, t => t.Id, false);

            List <Hashtable> ret = new List <Hashtable>();

            if (allUser != null)
            {
                Pager pager = new Pager();
                pager.total     = total;
                pager.pageCount = pageCount;
                pager.pageIndex = pageIndex;

                foreach (var user in allUser)
                {
                    Hashtable ht = new Hashtable();
                    ht["id"]        = user.Id;
                    ht["loginName"] = user.LoginName;
                    ht["password"]  = user.Password;
                    ht["mobile"]    = user.Mobile;
                    ht["province"]  = user.Province;
                    ret.Add(ht);
                }

                context.Response.Write(js.Serialize(BaseModels.OK("查询成功!", ret, pager)));
                return;
            }

            context.Response.Write(js.Serialize(BaseModels.Error("查询失败!")));
            return;
        }
Exemple #14
0
        /// <summary>
        /// 登录系统
        /// </summary>
        /// <param name="context"></param>
        public void LoginSystem(HttpContext context)
        {
            string userName = Request("userName");
            string password = Request("password");

            if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password))
            {
                context.Response.Write(js.Serialize(BaseModels.Error("账号和密码不能为空!")));
                return;
            }
            Hashtable ht = new Hashtable();

            ht["name"]  = "张三";
            ht["token"] = Guid.NewGuid().ToString("n");

            context.Response.Write(js.Serialize(BaseModels.OK("登录成功!", ht)));
            return;
        }
Exemple #15
0
        public void DelUser(HttpContext context)
        {
            //context.Response.ContentType = "application/json";
            string token = Request("token");

            string id = Request("id");


            if (string.IsNullOrEmpty(token))
            {
                context.Response.Write(js.Serialize(BaseModels.ErrorLogin("登录已失效!")));
                return;
            }

            if (string.IsNullOrEmpty(id))
            {
                context.Response.Write(js.Serialize(BaseModels.Error("编码不能为空!")));
                return;
            }

            context.Response.Write(js.Serialize(BaseModels.OK("删除成功!")));
            return;
        }