Ejemplo n.º 1
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.º 2
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.º 3
0
        protected void dataBind()
        {
            string usertype = DropUserType.SelectedValue;
            string key = this.TextBox1.Text.Trim();
            Session["AccountsAdminKey"] = key;
            User userAdmin = new User();
            DataSet ds = new DataSet();
            if (usertype != "")
            {
                ds = userAdmin.GetUsersByType(usertype, key);
            }
            else
            {
                ds = userAdmin.GetUserList(key);
            }
            int pageIndex = this.DataGrid1.CurrentPageIndex;
            Session["AccountsAdminPage"] = pageIndex;
            DataGrid1.DataSource = ds.Tables[0].DefaultView;
            int record_Count = ds.Tables[0].Rows.Count;
            int page_Size = DataGrid1.PageSize;
            int totalPages = int.Parse(Math.Ceiling((double)record_Count / page_Size).ToString());
            if (totalPages > 0)
            {
                if (pageIndex > totalPages - 1)
                    pageIndex = totalPages - 1;
            }
            else
            {
                pageIndex = 0;
            }
            DataGrid1.CurrentPageIndex = pageIndex;
            DataGrid1.DataBind();

            //显示数量
            if (this.DataGrid1.CurrentPageIndex == 0)
            {
                btnFirst.Enabled = false;
                btnPrev.Enabled = false;
                if (this.DataGrid1.PageCount == 1)
                {
                    btnLast.Enabled = false;
                    btnNext.Enabled = false;
                }
            }
            else if (this.DataGrid1.CurrentPageIndex == this.DataGrid1.PageCount - 1)
            {
                btnLast.Enabled = false;
                btnNext.Enabled = false;
            }
            this.lblpagesum.Text = totalPages.ToString();
            this.lblpage.Text = (pageIndex + 1).ToString();
            this.lblrowscount.Text = record_Count.ToString();
        }
Ejemplo n.º 4
0
 public void BtnOk_Click(object sender, System.Web.UI.ImageClickEventArgs e)
 {
     string UserName = DropUserlist.SelectedItem.Text;
     currentUser = new User(UserName);
     foreach (ListItem item in chkboxRolelist.Items)
     {
         if (item.Selected == true)
         {
             currentUser.AddToRole(Convert.ToInt32(item.Value));
         }
         else
         {
             currentUser.RemoveRole(Convert.ToInt32(item.Value));
         }
     }
     lblTip.Text = "保存成功!";
 }
Ejemplo n.º 5
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.º 6
0
        protected void btnAdd_Click(object sender, System.EventArgs e)
        {
            User newUser = new User();
            string strErr="";
            //			if(this.Dropdepart.SelectedIndex==0)
            //			{
            //				strErr+="请选择部门!";
            //			}
            if(newUser.HasUser(txtUserName.Text))
            {
                strErr+="该用户名已存在!";
            }

            if(strErr!="")
            {
                Maticsoft.Common.MessageBox.Show(this,strErr);
                return;
            }
            newUser.UserName=txtUserName.Text;
            newUser.Password=AccountsPrincipal.EncryptPassword(txtPassword.Text);
            newUser.TrueName=txtTrueName.Text;
            if(RadioButton1.Checked)
                newUser.Sex="男";
            else
                newUser.Sex="女";

            newUser.Phone=this.txtPhone.Text.Trim();
            newUser.Email=txtEmail.Text;
            newUser.EmployeeID=0;
            //newUser.DepartmentID=this.Dropdepart.SelectedValue;
            newUser.Activity=true;
            newUser.UserType = "AA";
            newUser.Style=1;
            int userid=newUser.Create();
            if (userid == -100)
            {
                this.lblMsg.Text = "该用户名已存在!";
                this.lblMsg.Visible = true;
            }
            else
            {
                Response.Redirect("Admin/RoleAssignment.aspx?UserID="+userid);
            }
        }
Ejemplo n.º 7
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.º 8
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.º 9
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.º 10
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.º 11
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.º 12
0
 protected void DataGrid1_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
 {
     string btn = e.CommandName;
     switch (btn)
     {
         case "BtnEdit":
             int userID1 = int.Parse(e.Item.Cells[9].Text.Trim());
             Response.Redirect("../userupdate.aspx?userid=" + userID1);
             break;
         case "BtnDel":
             int userID2 = int.Parse(e.Item.Cells[9].Text.Trim());
             User currentUser2 = new User(userID2);
             currentUser2.Delete();
             break;
     }
     dataBind();
 }
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
        private void btnLogin_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            if ((Session["PassErrorCountAdmin"] != null) && (Session["PassErrorCountAdmin"].ToString() != ""))
            {
                int PassErroeCount = Convert.ToInt32(Session["PassErrorCountAdmin"]);
                if (PassErroeCount > 3)
                {
                    txtUsername.Disabled = true;
                    txtPass.Disabled = true;
                    btnLogin.Enabled = false;
                    this.lblMsg.Text = "对不起,你错误登录了三次,系统登录锁定!";
                    return;
                }

            }

            #region 检查验证码
            if ((Session["CheckCode"] != null) && (Session["CheckCode"].ToString() != ""))
            {
                if (Session["CheckCode"].ToString().ToLower() != this.CheckCode.Value.ToLower())
                {
                    this.lblMsg.Text = "所填写的验证码与所给的不符 !";
                    Session["CheckCode"] = null;
                    return;
                }
                else
                {
                    Session["CheckCode"] = null;
                }
            }
            else
            {
                Response.Redirect("login.aspx");
            }
            #endregion

            string userName = Maticsoft.Common.PageValidate.InputText(txtUsername.Value.Trim(), 30);
            string Password = Maticsoft.Common.PageValidate.InputText(txtPass.Value.Trim(), 30);

            //验证登录信息,如果验证通过则返回当前用户对象的安全上下文信息
            AccountsPrincipal newUser = AccountsPrincipal.ValidateLogin(userName, Password);
            if (newUser == null)//登录信息不对
            {
                this.lblMsg.Text = "登陆失败: " + userName;
                if ((Session["PassErrorCountAdmin"] != null) && (Session["PassErrorCountAdmin"].ToString() != ""))
                {
                    int PassErroeCount = Convert.ToInt32(Session["PassErrorCountAdmin"]);
                    Session["PassErrorCountAdmin"] = PassErroeCount + 1;
                }
                else
                {
                    Session["PassErrorCountAdmin"] = 1;
                }
            }
            else
            {

                //根据用户对象的上下文得到用户对象信息,用于得到其他信息
                User currentUser = new JiaJiao.Bus.User(newUser);
                //if (currentUser.UserType != "AA")
                //{
                //    this.lblMsg.Text = "你非管理员用户,你没有权限登录后台系统!";
                //    return;
                //}

                //把当前用户对象实例赋给Context.User,这样做将会把完整的用户信息加载到ASP.NET提供的验证体系中
                Context.User = newUser;
                //验证当前用户密码
                if (((SiteIdentity)User.Identity).TestPassword(Password) == 0)
                {
                    this.lblMsg.Text = "你的密码无效!";
                    if ((Session["PassErrorCountAdmin"] != null) && (Session["PassErrorCountAdmin"].ToString() != ""))
                    {
                        int PassErroeCount = Convert.ToInt32(Session["PassErrorCountAdmin"]);
                        Session["PassErrorCountAdmin"] = PassErroeCount + 1;
                    }
                    else
                    {
                        Session["PassErrorCountAdmin"] = 1;
                    }
                }
                else
                {
                    //保存当前用户对象信息
                    FormsAuthentication.SetAuthCookie(userName, false);
                    Session["UserInfo"] = currentUser;
                    Session["Style"] = currentUser.Style;
                    if (Session["returnPage"] != null)
                    {
                        string returnpage = Session["returnPage"].ToString();
                        Session["returnPage"] = null;
                        Response.Redirect(returnpage);
                    }
                    else
                    {
                        Response.Redirect("main.htm");
                    }
                }
            }
        }
Ejemplo n.º 15
0
 private void LoadUsers()
 {
     string usertype = "AA";
     User userAdmin = new User();
     DataSet ds = userAdmin.GetUsersByType(usertype, "");
     DropUserlist.DataSource = ds.Tables[0];
     DropUserlist.DataTextField = "UserName";
     DropUserlist.DataValueField = "UserID";
     DropUserlist.DataBind();
 }
Ejemplo n.º 16
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.º 17
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;
         }
     }
 }