123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- namespace LYFZ.WeixinServers.WeiXinAPP
- {
- public partial class AddUser : System.Web.UI.Page
- {
- public string usreName = "";
- public string account = "";
- public string phone = "";
- public string email = "";
- public string sex = "";
- public int Competence = 0;
- public int eid = -1;
- LYFZ.WeixinServiceDate.DAL.DAL_AdminUser userDal = new WeixinServiceDate.DAL.DAL_AdminUser();
- protected void Page_Load(object sender, EventArgs e)
- {
- CommonHandler.CheckLoginJump(this);
- if (!IsPostBack)
- {
- if (Request.QueryString["eid"] != null && Request.QueryString["eid"].ToString().Trim().Length > 0)
- {
- try
- {
- if (CommonHandler.CheckAdmin(this))
- {
- eid = Convert.ToInt32(Request.QueryString["eid"].ToString().Trim());
- LYFZ.WeixinServiceDate.Model.Model_AdminUser userModel = userDal.GetModel(eid);
- usreName = userModel.UserName;
- account = userModel.Account;
- phone = userModel.Phone;
- email = userModel.Email;
- sex = userModel.Sex;
- Competence = userModel.Competence;
- }
- }
- catch { }
- }
- else if (Request.QueryString["s"] != null && Request.QueryString["s"].ToString().Trim() == "edit")
- {
- if (CommonHandler.CheckAdmin(this))
- {
- getEditID();
- AddOrEditUserInfo();
- }
- }
- else if (Request.QueryString["s"] != null && Request.QueryString["s"].ToString().Trim() == "spwd")
- {
- getEditID();
- UpdatePassword();
- }
- }
- }
- void getEditID()
- {
- try
- {
- eid = Convert.ToInt32(Request.QueryString["id"].ToString().Trim());
- }
- catch { }
- }
- void AddOrEditUserInfo()
- {
- LYFZ.WeixinServiceDate.Model.Model_AdminUser userModel = new WeixinServiceDate.Model.Model_AdminUser();
- if (eid > 0)
- {
- userModel = userDal.GetModel(eid);
- }
- userModel.UserName = Request.Form["usreName"].ToString();
- userModel.Account = Request.Form["account"].ToString();
- userModel.Phone = Request.Form["phone"].ToString();
- userModel.Email = Request.Form["email"].ToString();
- userModel.Sex = Request.Form["sex"].ToString();
- userModel.Competence = Convert.ToInt32(Request.Form["Competence"].ToString());
- bool ret = false;
- if (eid > 0)
- {
- ret = userDal.Update(userModel);
- }
- else
- {
- userModel.Password = "ly1234";
- int result = userDal.Add(userModel);
- if (result > 0)
- {
- UserMsegesBox("操作成功");
- }
- else
- {
- UserMsegesBox("操作失败,请重试");
- }
- }
- }
- void UserMsegesBox(string msg)
- {
- Response.Write("<script>alert('" + msg + "');document.location='UserList.aspx';</script>"); return;
- }
- void UpdatePassword()
- {
- LYFZ.WeixinServiceDate.Model.Model_AdminUser userModel = userDal.GetModel(eid);
- userModel.Password = Request.Form["pwd"].ToString();
- if (userModel.Password.Trim().Length > 0 && eid > 0)
- {
- if (userDal.Update(userModel))
- {
- UserMsegesBox("密码修改成功!"); return;
- }
- else
- {
- showMsegesBox("密码修改失败,请重试。");
- }
- }
- else
- {
- showMsegesBox("密码不能为空");
- }
- }
- void showMsegesBox(string msg)
- {
- Response.Write("<script>alert('" + msg + "');document.location='Adduser.aspx?eid=" + eid + "';</script>"); return;
- }
- }
- }
|