/// <summary>
 /// DataGrid选择项响应事件方法
 /// </summary>
 /// <param name="source"></param>
 /// <param name="e"></param>
 public void DataOperate(object source, DataGridCommandEventArgs e)
 {
     if (e.CommandName == "Delete")
     {
         //创建用户数据表操作类对象
         OperatorAuthorization operate = new OperatorAuthorization();
         string UserId = ((Label)e.Item.Cells[0].Controls[1]).Text;
         //删除用户数据
         if (operate.DelOperater(UserId))
         {
             Common.ShowMsg("删除成功!");
             //记录操作员操作
             RecordOperate.SaveRecord(Session["UserID"].ToString(), "系统管理", "删除用户信息;用户ID:" + UserId);
         }
         Server.Transfer("System_UserAuthorization_Index.aspx");
     }
     else
     {
         string Url = "System_UserAuthorization_Admin.aspx?UserID=" + ((Label)e.Item.Cells[0].Controls[1]).Text;
         Server.Transfer(Url);
     }
 }
示例#2
0
        /// <summary>
        /// 填充数据到表单文本控件,下拉框控件
        /// </summary>
        /// <param name="IsFill"></param>
        private void FillDataToCtrl(bool IsFill)
        {
            UserAuthorizationDB clsUserDB;                               //创建用户权限表类对象
            GroupAuthorization  clsGroupUser = new GroupAuthorization(); //创建用户组权限表操作类对象
            DataTable           dt           = clsGroupUser.GetGroName();

            //DataRow dr = dt.NewRow();
            //dr["GroupID"] = "";
            //dr["GroupName"] = "--请选择--";
            //dt.Rows.Add(dr);
            this.ddlGroupID.DataTextField  = "GroupName";
            this.ddlGroupID.DataValueField = "GroupID";
            this.ddlGroupID.DataSource     = dt.DefaultView;
            this.ddlGroupID.DataBind();

            string    strSql = "select userid,username from Sys_User";
            DBManager db     = DBManager.Instance();
            DataTable dt1    = db.GetDataTable(strSql);
            DataRow   df     = dt1.NewRow();

            df["UserName"] = "******";
            df["UserId"]   = "0";
            dt1.Rows.InsertAt(df, 0);
            ddlFather.DataSource     = dt1;
            ddlFather.DataTextField  = "UserName";
            ddlFather.DataValueField = "UserId";
            ddlFather.DataBind();

            this.ddlSex.Items.Clear();
            //this.ddlSex.Items.Add("---请选择---");
            this.ddlSex.Items.Add("男");
            this.ddlSex.Items.Add("女");
            this.ddlSex.SelectedIndex = 0;

            this.ddlStatus.Items.Clear();
            this.ddlStatus.Items.Add("禁用");
            this.ddlStatus.Items.Add("激活");
            this.ddlStatus.SelectedIndex = 0;

            if (IsFill)
            {
                OperatorAuthorization clsUser = new OperatorAuthorization();
                clsUserDB              = clsUser.FindUser((string)ViewState["UserID"]);
                this.txtUserID.Text    = ViewState["UserID"].ToString();
                this.txtUserID.Enabled = false;

                txtPassword.Text = Common.CCToEmpty(clsUserDB.Pwd);
                txtUserName.Text = Common.CCToEmpty(clsUserDB.UserName);
                txtAge.Text      = Common.CCToEmpty(clsUserDB.Age);
                txtBirthday.Text = Common.CCToEmpty(clsUserDB.Birthday);
                txtJob.Text      = Common.CCToEmpty(clsUserDB.Job);
                txtMobile.Text   = Common.CCToEmpty(clsUserDB.Mobile);
                txtAddr.Text     = Common.CCToEmpty(clsUserDB.Addr);
                txtTel.Text      = Common.CCToEmpty(clsUserDB.Tel);
                if (clsUserDB.Sex.Trim() == "男")
                {
                    ddlSex.SelectedIndex = 0;
                }
                else if (clsUserDB.Sex.Trim() == "女")
                {
                    ddlSex.SelectedIndex = 1;
                }

                if (clsUserDB.Status.ToString() == "0")
                {
                    ddlStatus.SelectedIndex = 0;
                }
                else if (clsUserDB.Status.ToString() == "1")
                {
                    ddlStatus.SelectedIndex = 1;
                }

                for (int i = 0; i < ddlGroupID.Items.Count; i++)
                {
                    if (this.ddlGroupID.Items[i].Value == clsUserDB.GroupID)
                    {
                        ddlGroupID.SelectedIndex = i;
                        break;
                    }
                }

                for (int i = 0; i < ddlFather.Items.Count; i++)
                {
                    if (this.ddlFather.Items[i].Value == clsUserDB.Father)
                    {
                        ddlFather.SelectedIndex = i;
                        break;
                    }
                }
            }
            else
            {
                clsUserDB              = new UserAuthorizationDB();
                this.txtUserID.Text    = "";
                this.txtUserID.Enabled = true;
            }
        }
示例#3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                //创建用户权限数据表操作类对象
                OperatorAuthorization clsUser = new OperatorAuthorization();

                if (ViewState["OperateStatus"].ToString() == "AddData")
                {
                    UserAuthorizationDB clsUserDB = clsUser.FindUser((string)ViewState["UserID"]);
                    string userid   = this.txtUserID.Text.Trim();
                    string pwd      = this.txtPassword.Text.Trim();
                    string username = this.txtUserName.Text.Trim();
                    string groupid  = this.ddlGroupID.Items.Count > 0 ? ddlGroupID.SelectedItem.Value : "";
                    string Sex      = this.ddlSex.Items.Count > 0 ? ddlSex.SelectedItem.Value : "";
                    string Tel      = this.txtTel.Text.Trim();
                    string Age      = this.txtAge.Text.Trim();
                    string Job      = this.txtJob.Text.Trim();
                    string Mobile   = this.txtMobile.Text.Trim();
                    string Birthday = this.txtBirthday.Text.Trim();
                    string Addr     = this.txtAddr.Text.Trim();
                    string Status   = this.ddlStatus.SelectedIndex.ToString();
                    string Father   = this.ddlFather.SelectedItem.Value;
                    //增加用户数据

                    if (clsUser.AddUser(userid, pwd, username, groupid, Sex, Tel, Age, Job, Mobile, Birthday, Addr, Status, Father))
                    {
                        Common.ShowMsg("添加成功!");
                        //记录操作员操作
                        RecordOperate.SaveRecord(Session["UserID"].ToString(), "权限设置", "增加用户权限信息;卡号:" + (string)ViewState["UserID"]);
                    }
                    else
                    {
                        return;
                    }
                }

                if (ViewState["OperateStatus"].ToString() == "EditData")
                {
                    UserAuthorizationDB clsUserDB = clsUser.FindUser((string)ViewState["UserID"]);
                    string userid   = ViewState["UserID"].ToString();
                    string pwd      = Common.CCToEmpty(clsUserDB.Pwd);
                    string username = this.txtUserName.Text.Trim();
                    string groupid  = this.ddlGroupID.Items.Count > 0 ? ddlGroupID.SelectedItem.Value : "";
                    string Sex      = this.ddlSex.Items.Count > 0 ? ddlSex.SelectedItem.Value : "";
                    string Tel      = this.txtTel.Text.Trim();
                    string Age      = this.txtAge.Text.Trim();
                    string Job      = this.txtJob.Text.Trim();
                    string Mobile   = this.txtMobile.Text.Trim();
                    string Birthday = this.txtBirthday.Text.Trim();
                    string Addr     = this.txtAddr.Text.Trim();
                    string Status   = this.ddlStatus.SelectedIndex.ToString();
                    string Father   = this.ddlFather.SelectedItem.Value;
                    //更新用户数据
                    if (clsUser.UpdateUser(userid, pwd, username, groupid, Sex, Tel, Age, Job, Mobile, Birthday, Addr, Status, Father))
                    {
                        Common.ShowMsg("更新成功!");
                        //记录操作员操作
                        RecordOperate.SaveRecord(Session["UserID"].ToString(), "权限设置", "修改用户权限信息;用户ID:" + (string)ViewState["UserID"]);
                    }
                }
            }
            Server.Transfer("System_UserAuthorization_Index.aspx");
        }