//管理员角色绑定
        private void AdminRoleBind(int AdminID)
        {
            AdminInfoBLL _AdminInfoBLL = new AdminInfoBLL();
            bool         IsSys         = _AdminInfoBLL.IsSys(AdminID);

            if (IsSys)
            {
                this.DropDownRole.Items.Clear();
                ListItem item = new ListItem("系统管理员");
                this.DropDownRole.Items.Add(item);
                this.DropDownRole.Enabled = false;
            }
            else
            {
                //与角色表中的数据绑定
                RoleBLL   _RoleBLL = new RoleBLL();
                DataTable DT       = _RoleBLL.GetAllRoleInfo();
                DropDownRole.Items.Clear();
                DropDownRole.DataSource     = DT;
                DropDownRole.DataTextField  = "RoleName";
                DropDownRole.DataValueField = "RoleID";
                DropDownRole.DataBind();

                //获得当前编辑对象的管理角色个数
                AdminRoleBLL _AdminRoleBLL  = new AdminRoleBLL();
                int          AdminRoleCount = _AdminRoleBLL.GetCountByAdminID(AdminID);
                if (AdminRoleCount > 0)
                {
                    int RoleID = _RoleBLL.GetRoleIDByAdminID(AdminID);
                    DropDownRole.SelectedValue = RoleID.ToString();
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                bool IsSysAdmin = true;
                bool IsSceAdmin = true;

                if (null == Session["IsSYS"] || (Boolean)Session["IsSYS"] != true)
                {
                    IsSysAdmin = false;
                    IsSceAdmin = false;

                    AdminInfoBLL _AdminInfoBLL = new AdminInfoBLL();
                    RoleBLL      _RoleBLL      = new RoleBLL();
                    int          AdminID       = int.Parse(Session["AdminID"].ToString());
                    int          RoleID        = _RoleBLL.GetRoleIDByAdminID(AdminID);
                    IsSceAdmin = _AdminInfoBLL.CheckFunction(RoleID, "酒店管理");
                }

                if (!(IsSysAdmin || IsSceAdmin))
                {
                    Response.Redirect("../../NotAllowed.aspx");
                }
                else
                {
                    CityBind();
                }
            }
        }
예제 #3
0
    protected void btn_Register_Click(object sender, EventArgs e)
    {
        AdminInfoBLL               aib   = new AdminInfoBLL();
        SuperAdminInfoBLL          saib  = new SuperAdminInfoBLL();
        List <AdminInfoModel>      lAim  = aib.GetAdminInfon();
        List <SuperAdminInfoModel> lSaim = saib.GetSuperAdminInfo();
        //用于判断用户是否存在
        bool isRegistered = false;

        //信息不为空
        if (tb_AdminName.Text != "" && tb_Password.Text != "" && tb_Confirm.Text != "" && tb_SAdminName.Text != "" && tb_SPassword.Text != "")
        {
            //判断用户名是否存在
            for (int i = 0; i < lAim.Count; i++)
            {
                if (tb_AdminName.Text == lAim[i].AdminName)
                {
                    isRegistered = true;
                }
            }
            //用户不存在
            if (!isRegistered)
            {
                //两次密码一致
                if (tb_Password.Text == tb_Confirm.Text)
                {
                    for (int j = 0; j < lSaim.Count; j++)
                    {
                        //超级管理员用户和密码正确
                        if (tb_SAdminName.Text == lSaim[j].SAdminName && tb_SPassword.Text == lSaim[j].SPassword)
                        {
                            aib.AddAdmin(tb_AdminName.Text, tb_Password.Text);
                            Response.Write(@"<script>alert('注册成功');</script>");
                            Response.Write(@"<script>location.href='Login.aspx';</script>");
                        }
                        //超级管理员用户和密码错误
                        else
                        {
                            Response.Write(@"<script>alert('超级管理员用户或密码错误');</script>");
                        }
                    }
                }
                //两次密码不一致
                else
                {
                    Response.Write(@"<script>alert('两次输入的密码不一致');</script>");
                }
            }
            //用户存在
            else
            {
                Response.Write(@"<script>alert('该用户已存在');</script>");
            }
        }
        //信息为空
        else
        {
            Response.Write(@"<script>alert('请将输入完整信息');</script>");
        }
    }
        //管理员账号密码绑定
        private void AdminInfoBind(int AdminID)
        {
            AdminInfoBLL _AdminInfoBLL = new AdminInfoBLL();
            DataTable    DT            = _AdminInfoBLL.GetAdminInfoByID(AdminID);

            this.txtAccount.Text = DT.Rows[0]["AdminAccount"].ToString();
            this.txtPass.Text    = DT.Rows[0]["AdminPass"].ToString();
        }
예제 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {                  //////判断权限
                bool IsSysAdmin = true;
                bool IsSceAdmin = true;

                if (null == Session["IsSYS"] || (Boolean)Session["IsSYS"] != true)
                {
                    IsSysAdmin = false;
                    IsSceAdmin = false;

                    AdminInfoBLL _AdminInfoBLL = new AdminInfoBLL();
                    RoleBLL      _RoleBLL      = new RoleBLL();
                    int          AdminID       = int.Parse(Session["AdminID"].ToString());
                    int          RoleID        = _RoleBLL.GetRoleIDByAdminID(AdminID);
                    IsSceAdmin = _AdminInfoBLL.CheckFunction(RoleID, "餐馆管理");
                }

                if (!(IsSysAdmin || IsSceAdmin))
                {
                    Response.Redirect("../../NotAllowed.aspx");
                }

                ////////////////
                this.CityBind();
                CityID = int.Parse(this.DrpDownCity.SelectedValue.ToString());
                this.RestaurantBind(CityID);
                if (this.DropDownRes.SelectedValue != "")
                {
                    RestaurantID = int.Parse(this.DropDownRes.SelectedValue.ToString());
                    this.FoodBind(RestaurantID);
                    if (this.DrpDownFood.SelectedValue != "")
                    {
                        FoodID = int.Parse(this.DrpDownFood.SelectedValue.ToString());
                    }
                }

                if (Request.QueryString["CityID"] != "" && Request.QueryString["CityID"] != null)
                {
                    CityID = int.Parse(Request.QueryString["CityID"].ToString());
                    this.DrpDownCity.SelectedValue = CityID.ToString();
                    this.RestaurantBind(CityID);
                    if (Request.QueryString["RestaurantID"] != "" && Request.QueryString["RestaurantID"] != null)
                    {
                        RestaurantID = int.Parse(Request.QueryString["RestaurantID"].ToString());
                        this.FoodBind(RestaurantID);
                        this.DropDownRes.SelectedValue = RestaurantID.ToString();
                        if (Request.QueryString["FoodID"] != "" && Request.QueryString["FoodID"] != null)
                        {
                            FoodID = int.Parse(Request.QueryString["FoodID"].ToString());
                            this.DrpDownFood.SelectedValue = FoodID.ToString();
                        }
                    }
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                bool IsSysAdmin = true;
                bool IsSceAdmin = true;

                if (null == Session["IsSYS"] || (Boolean)Session["IsSYS"] != true)
                {
                    IsSysAdmin = false;
                    IsSceAdmin = false;

                    AdminInfoBLL _AdminInfoBLL = new AdminInfoBLL();
                    RoleBLL      _RoleBLL      = new RoleBLL();
                    int          AdminID       = int.Parse(Session["AdminID"].ToString());
                    int          RoleID        = _RoleBLL.GetRoleIDByAdminID(AdminID);
                    IsSceAdmin = _AdminInfoBLL.CheckFunction(RoleID, "娱乐场所管理");
                }

                if (!(IsSysAdmin || IsSceAdmin))
                {
                    Response.Redirect("../../NotAllowed.aspx");
                }
                else
                {
                    this.CityBind();
                    if (this.DrpDownCity.SelectedValue != "" && this.DrpDownCity.SelectedValue != null)
                    {
                        CityID = int.Parse(this.DrpDownCity.SelectedValue.ToString());
                    }
                    if (CityID != 0)
                    {
                        this.EntertainmentBind(CityID);
                        if (this.DropDownEntertainment.SelectedValue != "" && this.DropDownEntertainment.SelectedValue != null)
                        {
                            EntertainmentID = int.Parse(this.DropDownEntertainment.SelectedValue.ToString());
                        }
                    }
                    if (Request.QueryString["CityID"] != null && Request.QueryString["CityID"] != "")
                    {
                        CityID = int.Parse(Request.QueryString["CityID"]);
                        this.DrpDownCity.SelectedValue = CityID.ToString();
                        this.EntertainmentBind(CityID);
                        if (Request.QueryString["EntertainmentID"] != null && Request.QueryString["EntertainmentID"] != "")
                        {
                            this.DropDownEntertainment.SelectedValue = Request.QueryString["EntertainmentID"].ToString();
                            EntertainmentID = int.Parse(Request.QueryString["EntertainmentID"].ToString());
                        }
                    }
                }
            }
        }
예제 #7
0
파일: Form_Login.cs 프로젝트: m66rk9t/SIMS
        private void btn_Login_Click(object sender, EventArgs e)
        {
            AdminInfoBLL          aib  = new AdminInfoBLL();
            List <AdminInfoModel> lAim = aib.GetAdminInfon();

            //用于判断用户名是否正确
            bool isAdminExit = false;
            //用于判断密码是否正确
            bool isPasswordRight = false;

            //用户名和密码不为空
            if (tb_AdminName.Text != "" && tb_Password.Text != "")
            {
                for (int i = 0; i < lAim.Count; i++)
                {   //判断用户名是否正确
                    if (tb_AdminName.Text == lAim[i].AdminName)
                    {
                        isAdminExit = true;
                    }
                }
                if (isAdminExit)    //用户名存在(用户名填写正确)
                {
                    for (int j = 0; j < lAim.Count; j++)
                    {
                        if (tb_Password.Text == lAim[j].Password)   //判断密码是否正确
                        {
                            isPasswordRight = true;
                        }
                    }
                    if (isPasswordRight)//密码正确
                    {
                        this.Hide();
                        new Form_StdInfo().ShowDialog();
                        Application.ExitThread();
                    }
                    else//密码错误
                    {
                        MessageBox.Show("密码错误");
                    }
                }
                else                //用户名不存在(用户名填写错误)
                {
                    MessageBox.Show("该用户不存在,请检查用户名是否正确");
                }
            }
            else    //用户名或密码为空
            {
                MessageBox.Show("请输入用户名或密码");
            }
        }
예제 #8
0
파일: Login.aspx.cs 프로젝트: m66rk9t/SIMS
    protected void btn_Login_Click(object sender, EventArgs e)
    {
        AdminInfoBLL          aib  = new AdminInfoBLL();
        List <AdminInfoModel> lAim = aib.GetAdminInfon();

        //用于判断用户名是否正确
        bool isAdminExit = false;
        //用于判断密码是否正确
        bool isPasswordRight = false;

        //用户名和密码不为空
        if (tb_AdminName.Text != "" && tb_Password.Text != "")
        {
            for (int i = 0; i < lAim.Count; i++)
            {   //判断用户名是否正确
                if (tb_AdminName.Text == lAim[i].AdminName)
                {
                    isAdminExit = true;
                }
            }
            if (isAdminExit)    //用户名存在(用户名填写正确)
            {
                for (int j = 0; j < lAim.Count; j++)
                {
                    if (tb_Password.Text == lAim[j].Password)   //判断密码是否正确
                    {
                        isPasswordRight = true;
                    }
                }
                if (isPasswordRight)//密码正确
                {
                    Response.Write(@"<script>location.href='Handler_ShowStdInfo.ashx';</script>");
                }
                else//密码错误
                {
                    Response.Write(@"<script>alert('密码错误');</script>");
                }
            }
            else                //用户名不存在(用户名填写错误)
            {
                Response.Write(@"<script>alert('该用户不存在,请检查用户名是否正确');</script>");
            }
        }
        else    //用户名或密码为空
        {
            Response.Write(@"<script>alert('请输入用户名或密码');</script>");
        }
    }
예제 #9
0
        //check admin whether exist
        private bool checkAdmin(out AdminInfoModel admin)
        {
            AdminInfoBLL bll = new AdminInfoBLL();

            admin = bll.getAdminInfoByID(txtUser.Text.Trim());
            if (admin == null)
            {
                lblU.Visible = true;
                return(false);
            }
            else if (admin.AdminPwd == txtPwd.Text.Trim())
            {
                return(true);
            }
            else
            {
                lblP.Visible = true;
                return(false);
            }
        }
예제 #10
0
        /// <summary>
        /// 删除管理员
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button4_Click(object sender, EventArgs e)
        {
            AdminInfoBLL   admin      = new AdminInfoBLL();
            AdminInfoModel adminmodel = new AdminInfoModel();
            string         id         = this.dataGridView1.SelectedRows[0].Cells["管理员编号"].Value.ToString();
            //adminmodel.Admin_ID = Convert.ToInt32(this.dataGridView1.SelectedRows[0].Cells["管理员编号"].Value);
            string name = this.dataGridView1.SelectedRows[0].Cells["管理员权限"].Value.ToString();

            //admin.DelAdminInfo(adminmodel);
            if (name != "超级管理员")
            {
                adminmodel.Admin_ID = Convert.ToInt32(id);
                admin.DelAdminInfo(adminmodel);
                BindAdmin();
            }
            else
            {
                MessageBox.Show("不能删除超级管理员");
                return;
            }
        }
예제 #11
0
        //注册
        private void btnRegist_Click(object sender, EventArgs e)
        {
            if (txtLoginID.Text.Trim() == "")
            {
                MessageBox.Show("用户名不能为空");
                return;
            }
            if (txtName.Text.Trim() == "")
            {
                MessageBox.Show("姓名不能为空");
                return;
            }
            if (txtpwd.Text.Trim() == "")
            {
                MessageBox.Show("密码不能为空");
                return;
            }
            if (txtpwd.Text.Trim() != txtpwds.Text.Trim())
            {
                MessageBox.Show("两次密码不一致");
                return;
            }
            AdminInfoModel admin = new AdminInfoModel();

            admin.LoginID   = txtLoginID.Text.Trim();
            admin.AdminName = txtName.Text.Trim();
            admin.AdminPwd  = txtpwd.Text.Trim();
            AdminInfoBLL bll = new AdminInfoBLL();

            if (bll.insertAdminInfo(admin) == 1)
            {
                MessageBox.Show("注册成功");
            }
            else
            {
                MessageBox.Show("注册失败");
            }
            this.Close();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                bool IsSysAdmin = true;
                bool IsSceAdmin = true;

                if (null == Session["IsSYS"] || (Boolean)Session["IsSYS"] != true)
                {
                    IsSysAdmin = false;
                    IsSceAdmin = false;

                    AdminInfoBLL _AdminInfoBLL = new AdminInfoBLL();
                    RoleBLL      _RoleBLL      = new RoleBLL();
                    int          AdminID       = int.Parse(Session["AdminID"].ToString());
                    int          RoleID        = _RoleBLL.GetRoleIDByAdminID(AdminID);
                    IsSceAdmin = _AdminInfoBLL.CheckFunction(RoleID, "购物场所管理");
                }

                if (!(IsSysAdmin || IsSceAdmin))
                {
                    Response.Redirect("../../NotAllowed.aspx");
                }
                else
                {
                    this.CityBind();
                    CityID = int.Parse(this.DropDownCity.SelectedValue.ToString());
                    if (Request.QueryString["CityID"] != null && Request.QueryString["CityID"] != "")
                    {
                        CityID = int.Parse(Request.QueryString["CityID"].ToString());
                        this.DropDownCity.SelectedValue = CityID.ToString();
                    }
                    MallInfoBLL _MallInfoBLL = new MallInfoBLL();
                    DT = _MallInfoBLL.GetCityMallSplit(CityID, this.AspNetPager4.PageSize, PageStart);
                }
            }
        }
예제 #13
0
        protected void btAdd_Click(object sender, EventArgs e)
        {
            //管理员表与管理员角色表都需要更新
            AdminInfo    _AdminInfo    = new AdminInfo();
            AdminRole    _AdminRole    = new AdminRole();
            AdminRoleBLL _AdminRoleBLL = new AdminRoleBLL();
            RoleBLL      _RoleBLL      = new RoleBLL();
            AdminInfoBLL _AdminInfoBLL = new AdminInfoBLL();
            int          Num           = _AdminInfoBLL.AdminExist(this.txtAccount.Text.Trim());

            if (Num > 0)
            {
                Response.Write("<script language='javascript'>");
                Response.Write("alert('该账号已存在');");
                Response.Write("</script>");
                return;
            }

            _AdminInfo.AdminAccount = this.txtAccount.Text.Trim();
            _AdminInfo.PassWord     = this.txtPass.Text.Trim();
            _AdminInfo.IsSYS        = false;

            bool StepOne = _AdminInfoBLL.AddAdminInfo(_AdminInfo);


            _AdminRole.AdminID = _AdminInfoBLL.GetAdminID(txtAccount.Text.Trim());
            _AdminRole.RoleID  = int.Parse(this.DropDownRole.SelectedValue.ToString());
            bool StepTwo = _AdminRoleBLL.AddAdminRole(_AdminRole);

            if (StepOne && StepTwo)
            {
                Response.Write("<script language='javascript'>");
                Response.Write("alert('添加成功');");
                Response.Write("document.location.href='AdminList.aspx';");
                Response.Write("</script>");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                bool IsSysAdmin = true;
                bool IsSceAdmin = true;

                if (null == Session["IsSYS"] || (Boolean)Session["IsSYS"] != true)
                {
                    IsSysAdmin = false;
                    IsSceAdmin = false;

                    AdminInfoBLL _AdminInfoBLL = new AdminInfoBLL();
                    RoleBLL      _RoleBLL      = new RoleBLL();
                    int          AdminID       = int.Parse(Session["AdminID"].ToString());
                    int          RoleID        = _RoleBLL.GetRoleIDByAdminID(AdminID);
                    IsSceAdmin = _AdminInfoBLL.CheckFunction(RoleID, "景点管理");
                }

                if (!(IsSysAdmin || IsSceAdmin))
                {
                    Response.Redirect("../../NotAllowed.aspx");
                }
                else
                {
                    DropDownBind();
                    if (Request.QueryString["CityID"] != null)
                    {
                        this.DrpDownCity.SelectedValue = Request.QueryString["CityID"].ToString();
                    }
                    if (Request.QueryString["SceneryID"] != null)
                    {
                        this.DropDownScenery.SelectedValue = Request.QueryString["SceneryID"].ToString();
                    }
                }
            }
        }
예제 #15
0
        //根据管理员信息 管理员角色信息
        protected void deleteThis()
        {
            try
            {
                Array delWitch = rqid.Split('|');
                bool  isTrue   = false;
                for (int i = 0; i < delWitch.Length - 1; i++)
                {
                    int delid = Convert.ToInt32(delWitch.GetValue(i));

                    AdminInfoBLL _AdminInfoBLL = new AdminInfoBLL();
                    AdminRoleBLL _AdminRoleBLL = new AdminRoleBLL();


                    int AdminRoleCount = _AdminRoleBLL.GetCountByAdminID(delid);
                    if (AdminRoleCount > 0)
                    {
                        if (_AdminRoleBLL.DeleteAdminRole(delid))
                        {
                            isTrue = true;
                        }
                        else
                        {
                            isTrue = false;
                        }
                    }

                    if (_AdminInfoBLL.DeleteAdminInfo(delid))
                    {
                        isTrue = true;
                    }
                    else
                    {
                        isTrue = false;
                    }

                    if (isTrue == false)
                    {
                        break;
                    }
                }
                if (!(isTrue == false))
                {
                    Response.Write("<script language='javascript'>");
                    Response.Write("alert('删除成功!');");
                    Response.Write("document.location.href='AdminList.aspx';");
                    Response.Write("</script>");
                }
                else
                {
                    Response.Write("<script language='javascript'>");
                    Response.Write("alert('删除失败!');");
                    Response.Write("document.location.href='AdminList.aspx';");
                    Response.Write("</script>");
                }
            }
            catch
            {
                Response.Write("<script language='javascript'>");
                Response.Write("alert('删除失败!');");
                Response.Write("document.location.href='AdminList.aspx';");
                Response.Write("</script>");
            }
        }
예제 #16
0
        private void btn_Register_Click(object sender, EventArgs e)
        {
            AdminInfoBLL               aib   = new AdminInfoBLL();
            SuperAdminInfoBLL          saib  = new SuperAdminInfoBLL();
            List <AdminInfoModel>      lAim  = aib.GetAdminInfon();
            List <SuperAdminInfoModel> lSaim = saib.GetSuperAdminInfo();
            //用于判断用户是否存在
            bool isRegistered = false;

            //信息不为空
            if (tb_AdminName.Text != "" && tb_Password.Text != "" && tb_Confirm.Text != "" && tb_SAdminName.Text != "" && tb_SPassword.Text != "")
            {
                //判断用户名是否存在
                for (int i = 0; i < lAim.Count; i++)
                {
                    if (tb_AdminName.Text == lAim[i].AdminName)
                    {
                        isRegistered = true;
                    }
                }
                //用户不存在
                if (!isRegistered)
                {
                    //两次密码一致
                    if (tb_Password.Text == tb_Confirm.Text)
                    {
                        for (int j = 0; j < lSaim.Count; j++)
                        {
                            //超级管理员用户和密码正确
                            if (tb_SAdminName.Text == lSaim[j].SAdminName && tb_SPassword.Text == lSaim[j].SPassword)
                            {
                                aib.AddAdmin(tb_AdminName.Text, tb_Password.Text);
                                MessageBox.Show("注册成功");
                                this.Hide();
                                new Form_Login().ShowDialog();
                                Application.ExitThread();
                            }
                            //超级管理员用户和密码错误
                            else
                            {
                                MessageBox.Show("超级管理员用户或密码错误");
                            }
                        }
                    }
                    //两次密码不一致
                    else
                    {
                        MessageBox.Show("两次输入的密码不一致");
                    }
                }
                //用户存在
                else
                {
                    MessageBox.Show("该用户已存在");
                }
            }
            //信息为空
            else
            {
                MessageBox.Show("请将输入完整信息");
            }
        }
예제 #17
0
        protected void btAdd_Click(object sender, EventArgs e)
        {
            AdminInfoBLL _AdminInfoBLL = new AdminInfoBLL();
            AdminInfo    _AdminInfo    = new AdminInfo();

            _AdminInfo.AdminAccount = this.txtAccount.Text;
            _AdminInfo.PassWord     = this.txtPass.Text;
            string _AdminID = Request.QueryString["AdminID"].ToString();
            int    AdminID  = int.Parse(_AdminID);


            _AdminInfo.IsSYS = _AdminInfoBLL.IsSys(AdminID);

            if (_AdminInfo.IsSYS)
            {
                if (_AdminInfoBLL.UpdateAdminInfo(AdminID, _AdminInfo))
                {
                    Response.Write("<script language='javascript'>");
                    Response.Write("alert('更新成功');");
                    Response.Write("document.location.href='AdminList.aspx';");
                    Response.Write("</script>");
                }
            }
            else
            {
                int          RoleID        = int.Parse(DropDownRole.SelectedValue.ToString());
                AdminRoleBLL _AdminRoleBLL = new AdminRoleBLL();

                bool StepOne = false;
                bool StepTwo = false;
                if (_AdminInfoBLL.UpdateAdminInfo(AdminID, _AdminInfo))
                {
                    StepOne = true;
                }


                int AdminRoleCount = _AdminRoleBLL.GetCountByAdminID(AdminID);

                if (AdminRoleCount > 0)
                {
                    if (_AdminRoleBLL.UpdateAdminRole(AdminID, RoleID))
                    {
                        StepTwo = true;
                    }
                }
                else
                {
                    AdminRole _AdminRole = new AdminRole();
                    _AdminRole.AdminID = AdminID;
                    _AdminRole.RoleID  = RoleID;
                    if (_AdminRoleBLL.AddAdminRole(_AdminRole))
                    {
                        StepTwo = true;
                    }
                }


                if (StepOne && StepTwo)
                {
                    Response.Write("<script language='javascript'>");
                    Response.Write("alert('更新成功');");
                    Response.Write("document.location.href='AdminList.aspx';");
                    Response.Write("</script>");
                }
            }
        }
예제 #18
0
        /// <summary>
        /// 管理员权限登陆
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            string name = this.txtName.Text.Trim();
            string pass = this.txtPass.Text.Trim();

            if (string.IsNullOrEmpty(name))
            {
                MessageBox.Show("请输入姓名");
                return;
            }
            if (string.IsNullOrEmpty(pass))
            {
                MessageBox.Show("请输入密码");
                return;
            }
            if (this.textBox1.Text.ToLower() != Ccode.ToLower())
            {
                CreateImage();
                MessageBox.Show("验证码输入错误");
                return;
            }
            //学生登陆
            StudentsModel stumodel = new StudentsModel();
            StudentsBLL   student  = new StudentsBLL();

            if (this.checkBox1.Checked)
            {
                stumodel.Student_Name = this.txtName.Text;
                try
                {
                    DataRow row = student.GetStudentByName(stumodel).Rows[0];

                    string num  = row["StudentNum"].ToString().Substring(10, 4);
                    string cnum = this.txtPass.Text;
                    if (num == cnum)
                    {
                        int          id = Convert.ToInt32(row["Student_ID"]);
                        PropertyForm fm = new PropertyForm(id);
                        fm.Show();
                    }
                    else
                    {
                        MessageBox.Show("用户名或密码错误");
                        return;
                    }
                }
                catch
                {
                    MessageBox.Show("用户名或密码不匹配");
                }
            }
            else
            {
                AdminInfoModel adminmodel = new AdminInfoModel();
                AdminInfoBLL   admininfo  = new AdminInfoBLL();
                adminmodel.Admin_Name     = name;
                adminmodel.Admin_Password = pass;
                SqlDataReader dr = admininfo.AdminLogin(adminmodel);
                if (dr.Read())                            //如果登陆成功
                {
                    MainForm main = (MainForm)this.Owner; //实例化主窗体
                    //将管理员的ID和权限保存到主窗体全局字段
                    main.adminid = Convert.ToInt32(dr["Admin_ID"]);
                    main.level   = dr["Admin_Level"].ToString();
                    islog        = true; //将是否登陆成功的标识改为true
                    dr.Close();          //关闭阅读器
                    this.Close();        //关闭主窗体
                }
                else
                {
                    dr.Close();
                    MessageBox.Show("用户名或密码错误");
                    return;
                }
            }
        }