Ejemplo n.º 1
0
        protected void btnAdd_Click(object sender, System.EventArgs e)
        {
            string username=this.lblName.Text.Trim();
            AccountsPrincipal user=new AccountsPrincipal(username);
            User currentUser=new JiaJiao.Bus.User(user);

            currentUser.UserName=username;
            currentUser.TrueName=txtTrueName.Text.Trim();
            if (txtPassword.Text.Trim() != "")
            {
                currentUser.Password = AccountsPrincipal.EncryptPassword(txtPassword.Text.Trim());
            }
            if(RadioButton1.Checked)
                currentUser.Sex="男";
            else
                currentUser.Sex="女";
            currentUser.Phone=this.txtPhone.Text.Trim();
            currentUser.Email=txtEmail.Text.Trim();
            //currentUser.EmployeeID=0;
            //currentUser.DepartmentID=this.Dropdepart.SelectedValue;
            int style=int.Parse(this.dropStyle.SelectedValue);
            currentUser.Style=style;
            if (!currentUser.Update())
            {
                this.lblMsg.ForeColor=Color.Red;
                this.lblMsg.Text = "更新用户信息发生错误!";
            }
            else
            {
                Response.Redirect("Admin/useradmin.aspx");
            }
        }
Ejemplo n.º 2
0
        private void BindRoles()
        {
            if (DropUserlist.SelectedItem == null)
            {
                return;
            }

            string UserName = DropUserlist.SelectedItem.Text;
            currentUser = new User(UserName);
            AccountsPrincipal newUser = new AccountsPrincipal(UserName);

            DataSet dsRole = AccountsTool.GetRoleList();
            chkboxRolelist.DataSource = dsRole.Tables[0].DefaultView;
            chkboxRolelist.DataTextField = "Description";
            chkboxRolelist.DataValueField = "RoleID";
            chkboxRolelist.DataBind();

            if (newUser.Roles.Count > 0)
            {
                ArrayList roles = newUser.Roles;
                for (int i = 0; i < roles.Count; i++)
                {
                    //RoleList.Text += "<li>" + roles[i] + "</li>";
                    foreach (ListItem item in chkboxRolelist.Items)
                    {
                        if (item.Text == roles[i].ToString()) item.Selected = true;
                    }
                }
            }
        }
Ejemplo n.º 3
0
 public User(AccountsPrincipal existingPrincipal)
 {
     this.dataUser = new JiaJiao.Data.User();
     this.departmentID = "-1";
     this.userID = ((SiteIdentity) existingPrincipal.Identity).UserID;
     this.LoadFromID();
 }
Ejemplo n.º 4
0
        protected void btnAdd_Click(object sender, System.EventArgs e)
        {
            if (Page.IsValid)
            {
                string username=this.lblName.Text.Trim();
                AccountsPrincipal user=new AccountsPrincipal(username);
                User currentUser=new JiaJiao.Bus.User(user);
                currentUser.UserName=username;
                currentUser.TrueName=txtTrueName.Text.Trim();
                if(RadioButton1.Checked)
                    currentUser.Sex="男";
                else
                    currentUser.Sex="女";
                currentUser.Phone=this.txtPhone.Text.Trim();
                currentUser.Email=txtEmail.Text.Trim();
                //currentUser.UserType = dropUserType.SelectedValue;
                int style=int.Parse(this.dropStyle.SelectedValue);
                currentUser.Style=style;
                if (!currentUser.Update())
                {
                    this.lblMsg.ForeColor=Color.Red;
                    this.lblMsg.Text = "更新用户信息发生错误!";
                }
                else
                {
                    this.lblMsg.ForeColor=Color.Blue;
                    this.lblMsg.Text = "用户信息更新成功!";
                }
                string virtualPath=ConfigurationManager.AppSettings.Get("VirtualPath");
                Session["Style"]=style;
                Response.Clear();
                Response.Write("<SCRIPT LANGUAGE=\"JavaScript\">\n");
                Response.Write("<!--\n");
                Response.Write("parent.topFrame.location=\""+virtualPath+"/Admin/top.aspx\";\n");
                Response.Write("parent.leftFrame.location=\""+virtualPath+"/Admin/left.aspx\";\n");
                Response.Write("parent.spliterFrame.location=\""+virtualPath+"/Admin/spliter.aspx\";\n");
                Response.Write("parent.mainFrame.location=\"userinfo.aspx\";\n");
            //				Response.Write("parent.mainFrame.location=\"userinfo.aspx?id="+userName+"\";\n");
                Response.Write("//-->\n");
                Response.Write("</SCRIPT>");
                Response.End();

            }
        }
Ejemplo n.º 5
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            userID=int.Parse(Request.Params["UserID"]);
            currentUser = new User(userID);

            Label1.Text="为用户: "+currentUser.UserName+" 分配角色";
            if(!Page.IsPostBack)
            {
            //获取并显示所有角色
            DataSet dsRole=AccountsTool.GetRoleList();
            CheckBoxList1.DataSource=dsRole.Tables[0].DefaultView;
            CheckBoxList1.DataTextField="Description";
            CheckBoxList1.DataValueField="RoleID";
            CheckBoxList1.DataBind();

            //获取用户已经拥有的角色,遍历CheckBoxList控件设置选中状态
            AccountsPrincipal newUser = new AccountsPrincipal(currentUser.UserName);
            if (newUser.Roles.Count > 0 )
            {
                ArrayList roles = newUser.Roles;
                for(int i=0; i<roles.Count; i++)
                {
                    foreach(ListItem item in CheckBoxList1.Items)
                    {
                        if(item.Text==roles[i].ToString())
                            item.Selected=true;
                    }
                }
            }

            if (newUser.Permissions.Count > 0)
            {
                RoleList.Visible = true;
                ArrayList Permissions = newUser.Permissions;
                RoleList.Text = "用户拥有的权限列表:<ul>";
                for (int i = 0; i < Permissions.Count; i++)
                {
                    RoleList.Text += "<li>" + Permissions[i] + "</li>";
                }
                RoleList.Text += "</ul>";
            }
            }
        }
Ejemplo n.º 6
0
        protected void btnAdd_Click(object sender, System.EventArgs e)
        {
            if (Page.IsValid)
            {
                SiteIdentity SID=new SiteIdentity(User.Identity.Name);
                if(SID.TestPassword(txtOldPassword.Text)==0)
                {
                    this.lblMsg.ForeColor=Color.Red;
                    this.lblMsg.Text = "原密码输入错误!";
                }
                else
                    if(this.txtPassword.Text.Trim()!=this.txtPassword1.Text.Trim())
                {
                    this.lblMsg.ForeColor=Color.Red;
                    this.lblMsg.Text="密码输入的不一致!请重试!";
                }
                else
                {
                    AccountsPrincipal user=new AccountsPrincipal(Context.User.Identity.Name);
                    User currentUser=new JiaJiao.Bus.User(user);

                    currentUser.Password=AccountsPrincipal.EncryptPassword(txtPassword.Text);

                    if (!currentUser.Update())
                    {
                        this.lblMsg.ForeColor=Color.Red;
                        this.lblMsg.Text = "更新用户信息发生错误!";
                        //日志
                        //UserLog.AddLog(currentUser.UserName, currentUser.UserType, Request.UserHostAddress, Request.Url.AbsoluteUri, "用户密码更新失败");
                    }
                    else
                    {
                        this.lblMsg.ForeColor=Color.Blue;
                        this.lblMsg.Text = "用户信息更新成功!";
                        //日志
                        //UserLog.AddLog(currentUser.UserName, currentUser.UserType, Request.UserHostAddress, Request.Url.AbsoluteUri, "用户密码更新成功");
                    }

                }
            }
        }
Ejemplo n.º 7
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!Page.IsPostBack)
            {

                if (Context.User.Identity.IsAuthenticated)
                {
                    AccountsPrincipal user=new AccountsPrincipal(Context.User.Identity.Name);
                    User currentUser=new JiaJiao.Bus.User(user);

                    this.lblName.Text=currentUser.UserName;
                    txtTrueName.Text=currentUser.TrueName;
                    if(currentUser.Sex=="男")
                        RadioButton1.Checked=true;
                    else
                        RadioButton2.Checked=true;
                    this.txtPhone.Text=currentUser.Phone;
                    txtEmail.Text=currentUser.Email;

            //					for(int i=0;i<this.Dropdepart.Items.Count;i++)
            //					{
            //						if(this.Dropdepart.Items[i].Value==currentUser.DepartmentID)
            //						{
            //							this.Dropdepart.Items[i].Selected=true;
            //						}
            //					}

                    //for (int i = 0; i < this.dropUserType.Items.Count; i++)
                    //{
                    //    if (this.dropUserType.Items[i].Value == currentUser.UserType)
                    //    {
                    //        this.dropUserType.Items[i].Selected = true;
                    //    }
                    //}

                    this.dropStyle.SelectedIndex=currentUser.Style-1;

            //					BindRoles(user);
                }
            }
        }
Ejemplo n.º 8
0
		protected void Page_Load(object sender, System.EventArgs e)
		{            			
			if (!Context.User.Identity.IsAuthenticated )
			{
				Session["message"]="你没有通过权限审核!";
				Session["returnPage"]=Request.RawUrl;
				Response.Redirect("../Login.aspx",true);
			}
            
            AccountsPrincipal user=new AccountsPrincipal(Context.User.Identity.Name);			
			if(!user.HasPermission("帐户管理"))
			{
				Session["message"]="你没有帐户管理的权限!";
				Session["returnPage"]=Request.RawUrl;
				Response.Redirect("../Login.aspx",true);
			}

//			int i=user.Roles.Count;
//			string s=user.Roles[0].ToString();
//			bool b=user.Roles.Contains("管理员");
//			i=user.Permissions.Count;
//			s=user.Permissions[0].ToString();
//			b=user.Permissions.Contains("帐户管理");



/*
			Context.User = new AccountsPrincipal(Context.User.Identity.Name);
			if(!((AccountsPrincipal)Context.User).HasPermission("帐户管理"))
			{
				Session["message"]="你没有帐户管理的权限!";
				Session["returnPage"]=Request.RawUrl;
				Response.Redirect("../Login.aspx",true);
			}
*/



		}
Ejemplo n.º 9
0
        private void InitializeComponent()
        {
            if (!Page.IsPostBack)
            {
                string virtualPath = ConfigurationManager.AppSettings.Get("VirtualPath");
                string loginPage = ConfigurationManager.AppSettings.Get("LoginPage");
                if (Context.User.Identity.IsAuthenticated)
                {
                    AccountsPrincipal user = new AccountsPrincipal(Context.User.Identity.Name);
                    if (Session["UserInfo"] == null)
                    {
                        JiaJiao.Bus.User currentUser = new JiaJiao.Bus.User(user);
                        Session["UserInfo"] = currentUser;
                        Session["Style"] = currentUser.Style;
                        Response.Write("<script defer>location.reload();</script>");
                    }
                    if ((PermissionID != -1) && (!user.HasPermissionID(PermissionID)))
                    {
                        Response.Clear();
                        Response.Write("<script defer>window.alert('您没有权限进入本页!\\n请重新登录或与管理员联系');history.back();</script>");
                        Response.End();
                    }

                }
                else
                {
                    FormsAuthentication.SignOut();
                    Session.Clear();
                    Session.Abandon();
                    Response.Clear();
                    Response.Write("<script defer>window.alert('您没有权限进入本页或当前登录用户已过期!\\n请重新登录或与管理员联系!');parent.location='" + virtualPath + "/" + loginPage + "';</script>");
                    Response.End();
                }

            }
        }
Ejemplo n.º 10
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if(!Page.IsPostBack)
            {
                user=new AccountsPrincipal(Context.User.Identity.Name);
                if(Session["UserInfo"]==null)
                {
                    return ;
                }
                currentUser=(JiaJiao.Bus.User)Session["UserInfo"];
                Maticsoft.BLL.SysManage sm=new Maticsoft.BLL.SysManage();
                DataSet ds;
                ds=sm.GetTreeList("");
                BindTreeView("mainFrame",ds.Tables[0]);

                if(this.TreeView1.Nodes.Count==0)
                {
                    strWelcome+="<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;但你没有任何模块的访问权";
                }

            }
        }
Ejemplo n.º 11
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                //BindSuppData();
                User currentUser;
                if(Request["userid"]!=null)
                {
                    int userid=int.Parse(Request["userid"]);
                    currentUser=new User(userid);
                    if(currentUser==null)
                    {
                        Response.Write("<script language=javascript>window.alert('该用户不存在!\\');history.back();</script>");
                        return;
                    }

                    this.lblName.Text=currentUser.UserName;
                    txtTrueName.Text=currentUser.TrueName;
                    if(currentUser.Sex=="男")
                        RadioButton1.Checked=true;
                    else
                        RadioButton2.Checked=true;
                    this.txtPhone.Text=currentUser.Phone;
                    txtEmail.Text=currentUser.Email;

                    //for(int i=0;i<this.Dropdepart.Items.Count;i++)
                    //{
                    //    if(this.Dropdepart.Items[i].Value==currentUser.DepartmentID)
                    //    {
                    //        this.Dropdepart.Items[i].Selected=true;
                    //    }
                    //}

                    this.dropStyle.SelectedIndex=currentUser.Style-1;

                    AccountsPrincipal user=new AccountsPrincipal(userid);
                    BindRoles(user);

                }
            }
        }
Ejemplo n.º 12
0
 private void BindRoles(AccountsPrincipal user)
 {
     if(user.Permissions.Count>0)
     {
         RoleList.Visible = true;
         ArrayList Permissions = user.Permissions;
         RoleList.Text = "权限列表:<ul>";
         for(int i=0;i<Permissions.Count;i++)
         {
             RoleList.Text+="<li>" + Permissions[i] + "</li>";
         }
         RoleList.Text += "</ul>";
     }
 }
Ejemplo n.º 13
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!Page.IsPostBack)
            {

                if (Context.User.Identity.IsAuthenticated)
                {

                    AccountsPrincipal user=new AccountsPrincipal(Context.User.Identity.Name);
                    User currentUser=new JiaJiao.Bus.User(user);

                    this.lblName.Text=currentUser.UserName;
                    this.lblTruename.Text=currentUser.TrueName;
                    this.lblSex.Text=currentUser.Sex;
                    this.lblPhone.Text=currentUser.Phone;
                    this.lblEmail.Text=currentUser.Email;

                    lblUserIP.Text = Request.UserHostAddress;

                    //if(currentUser.DepartmentID=="-1")
                    //{
                    //    string herosoftmana=Maticsoft.Common.ConfigHelper.GetConfigString("AdManager");
                    //    this.lblDepart.Text=herosoftmana;
                    //}
                    //else
                    //{

                    //        if(Maticsoft.Common.PageValidate.IsNumber(currentUser.DepartmentID))
                    //        {
                    //            Maticsoft.BLL.ADManage.AdSupplier supp=new Maticsoft.BLL.ADManage.AdSupplier();
                    //            Maticsoft.Model.ADManage.AdSupplier suppmodel=supp.GetModel(int.Parse(currentUser.DepartmentID));
                    //            this.lblDepart.Text=suppmodel.SupplierName;
                    //            this.lblModeys.Text=suppmodel.Moneys.ToString();
                    //        }

                    //}
                    switch(currentUser.Style)
                    {
                        case 1:
                            this.lblStyle.Text="默认蓝";
                            break;
                        case 2:
                            this.lblStyle.Text="橄榄绿";
                            break;
                        case 3:
                            this.lblStyle.Text="深红";
                            break;
                        case 4:
                            this.lblStyle.Text="深绿";
                            break;
                    }

            //					if(user.Roles.Count>0)
            //					{
            //						RoleList.Visible = true;
            //						ArrayList roles = user.Roles;
            //						RoleList.Text = "角色列表:<ul>";
            //						for(int i=0;i<roles.Count;i++)
            //						{
            //							RoleList.Text+="<li>" + roles[i] + "</li>";
            //						}
            //						RoleList.Text += "</ul>";
            //					}

            //					if(user.Permissions.Count>0)
            //					{
            //						RoleList.Visible = true;
            //						ArrayList Permissions = user.Permissions;
            //						RoleList.Text = "权限列表:<ul>";
            //						for(int i=0;i<Permissions.Count;i++)
            //						{
            //							RoleList.Text+="<li>" + Permissions[i] + "</li>";
            //						}
            //						RoleList.Text += "</ul>";
            //					}

                }

            }
        }
Ejemplo n.º 14
0
 protected void Page_Load(object sender, System.EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         if (Context.User.Identity.IsAuthenticated)
         {
             AccountsPrincipal user=new AccountsPrincipal(Context.User.Identity.Name);
             User currentUser=new JiaJiao.Bus.User(user);
             this.lblName.Text=currentUser.UserName;
         }
     }
 }