Пример #1
0
		public ActionResult Add_Admin_User()
		{
			this.Response.ContentType = "text/plain";

			NModel.Admin_User model = new NModel.Admin_User();
			BLL.Admin_User dal = new BLL.Admin_User();

			String JsonStr = "";

			bool isGet = Tool.NStr.PostForSetVal<NModel.Admin_User>(ref model, ref JsonStr, "");

			// 下面代码编写
			if (isGet && !string.IsNullOrEmpty(model.User_Name) &&
					!string.IsNullOrEmpty(model.User_PassWord) &&
					 model.User_PassWord.Length > 5 &&
					 model.User_Name.Length > 1

				)
			{
				if (dal.ExistsName(model.User_Name) > 0)
				{
					this.Response.Write(Tool.NMsg.SetMsg("用户存在", "0"));

					this.Response.End();
				}
				else
				{
					model.User_AddTime = DateTime.Parse(DateTime.Now.ToString("s"));
					model.User_EditTime = DateTime.Parse(DateTime.Now.ToString("s"));
					model.User_LoginTime = DateTime.Parse(DateTime.Now.ToString("s"));
					model.User_PassWord = Tool.NMd5.GetMd5Hash(model.User_PassWord);
					//
					bool isAdd = dal.Add(model) > 0 ? true : false;

					if (isAdd)
					{
						this.Response.Write(Tool.NMsg.SetMsg("增加成功", "1"));
						this.Response.End();
					}
					else
					{
						this.Response.Write(Tool.NMsg.SetMsg("增加失败", "1"));
						this.Response.End();
					}
				}

				dal.Close();
			}
			else
			{
				this.Response.Write(Tool.NMsg.SetMsg("提交失败/填写数据不完整", "0"));
			}

			return View();
		}
Пример #2
0
        public static bool Get_model_user(long?id)
        {
            NModel.Admin_User _rlAndUsModel = HttpContext.Current.Session[NModel.EnObject.CurrentLoginSessionName] as NModel.Admin_User;

            if (_rlAndUsModel != null && !string.IsNullOrEmpty(_rlAndUsModel.Role_Menu))
            {
                string[] arrStr = _rlAndUsModel.Role_Menu.Split(',');
                long[]   Arr    = Tool.NTool.ArrayToAll <long, string>(arrStr);
                int      i      = Arr.Where(a => a.Equals(id)).ToList().Count;
                if (i > 0)
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #3
0
        public ActionResult Data_Left_Admin_Menu()
        {
            this.Response.ContentType = "text/plain";

            // this.Response.ContentType = "text/plain";
            // this.Response.ContentType = "text/plain";
            BLL.Admin_Menu           dal   = new BLL.Admin_Menu();
            List <NModel.Admin_Menu> _menu = null;

            try
            {
                NModel.Admin_User mdl   = this.Session[NModel.EnObject.CurrentLoginSessionName] as NModel.Admin_User;
                string[]          arrid = (mdl.Role_Menu + "").Split(',');

                int[] lg = Tool.NTool.ArrayToAll <int, string>(arrid);

                string[] keys = this.Request.Form.AllKeys;

                _menu = dal.GetIDList(lg);
            }
            catch (Exception ex)
            {
            }

            StringBuilder sbStr = new StringBuilder();

            Tool.NJson <NModel.Admin_Menu> jstr = new Tool.NJson <NModel.Admin_Menu>();

            sbStr.Append(jstr.JsonNoLevel(SetRtMenu, SetProcessResult, _menu));

            NModel.PageData <NModel.Admin_Menu> outModel = new NModel.PageData <NModel.Admin_Menu>();
            outModel.TotalPage = 1;
            // outModel.OutData = inModel;

            outModel.OutStr = sbStr.ToString();

            dal.Close();

            return(View(outModel));
        }
Пример #4
0
        public static NModel.Admin_User Current_Login_Admin_User()
        {
            NModel.Admin_User nAdmin_User = HttpContext.Current.Session[NModel.EnObject.CurrentLoginSessionName] as NModel.Admin_User;

            return(nAdmin_User);
        }
Пример #5
0
		public ActionResult Edit_Admin_User()
		{
			this.Response.ContentType = "text/plain";

			NModel.Admin_User model = new NModel.Admin_User();
			BLL.Admin_User dal = new BLL.Admin_User();

			String JsonStr = "";

			bool isGet = Tool.NStr.PostForSetVal<NModel.Admin_User>(ref model, ref JsonStr, "");

			if (isGet &&
			   !string.IsNullOrEmpty(model.User_Name) &&
				model.User_Role_ID > 0

			   )
			{
				//取默认值

				NModel.Admin_User oldModel = dal.GetModel(model.User_ID);
				model.User_AddTime = oldModel.User_AddTime;
				//post 请求过来密码为空,设置数据库原密码
				if (string.IsNullOrEmpty(model.User_PassWord))
				{
					model.User_PassWord = oldModel.User_PassWord;
				}
				else
				{
					model.User_PassWord = Tool.NMd5.GetMd5Hash(model.User_PassWord);
				}

				model.User_EditTime = DateTime.Parse(DateTime.Now.ToString("s"));
				model.User_LoginTime = DateTime.Parse(DateTime.Now.ToString("s"));
				if (model.User_PassWord.Length > 5)
				{
					bool isEdit = dal.Edit(model) > 0 ? true : false;

					string msg = dal.Msg;
					if (!string.IsNullOrEmpty(msg))
					{
						msg = "原因:" + msg;
					}

					if (isEdit)
					{
						this.Response.Write(Tool.NMsg.SetMsg("修改成功", "1"));
						this.Response.End();
					}
					else
					{
						this.Response.Write(Tool.NMsg.SetMsg("修改失败" + msg, "0"));
						this.Response.End();
					}
				}
				else
				{
					this.Response.Write(Tool.NMsg.SetMsg("提交失败/填写数据不完整", "0"));
					this.Response.End();
				}

				dal.Close();
			}
			else
			{
				this.Response.Write(Tool.NMsg.SetMsg("提交失败/填写数据不完整", "0"));
				this.Response.End();
			}

			return View();
		}
Пример #6
0
		public ActionResult Edit_Admin_User_Pw()
		{
			this.Response.ContentType = "text/plain";

			NModel.Admin_User model = new NModel.Admin_User();
			BLL.Admin_User dal = new BLL.Admin_User();            //admin_user_pw
			long? l_admin_user_name = BLL.Fun.GetCookieUserID();

			model = dal.GetModel(l_admin_user_name);
			string admin_user_pw = this.Request.Form["admin_user_pw"];

			string r_admin_user_pw = this.Request.Form["r_admin_user_pw"];

			string o_admin_user_pw = this.Request.Form["o_admin_user_pw"];

			// 下面代码编写
			if (model != null && !string.IsNullOrEmpty(admin_user_pw) && !string.IsNullOrEmpty(o_admin_user_pw) &&
						 !string.IsNullOrEmpty(r_admin_user_pw) && admin_user_pw.Length > 5 && admin_user_pw.Equals(r_admin_user_pw)
						   && o_admin_user_pw.Length > 5

				)
			{
				NModel.Admin_User cModel_User = dal.ExistsNamePw((model.User_Name + "").ToLower(), Tool.NMd5.GetMd5Hash(o_admin_user_pw).ToLower());
				if (cModel_User != null && cModel_User.User_ID > 0)
				{
					bool isEdit = dal.EditPW(model.User_Name, r_admin_user_pw);

					string msg = dal.ErrorMsg;
					if (!string.IsNullOrEmpty(msg))
					{
						msg = "原因:" + msg;
					}

					if (isEdit)
					{
						bool isLogin = BLL.Fun.ClearLogin();

						this.Response.Write(Tool.NMsg.SetMsg("修改成功", "1"));
						this.Response.End();
					}
					else
					{
						this.Response.Write(Tool.NMsg.SetMsg("修改失败" + msg, "0"));
						this.Response.End();
					}
				}
				else
				{
					this.Response.Write(Tool.NMsg.SetMsg("修改失败,旧密码不正确", "0"));
					this.Response.End();
				}

				dal.Close();
			}
			else
			{
				this.Response.Write(Tool.NMsg.SetMsg("提交失败/填写数据不完整", "0"));
				this.Response.End();
			}
			dal.Close();
			return View();

			;
		}