Пример #1
0
        /// <summary>
        ///     修改管理员信息
        /// </summary>
        /// <param name="mod"></param>
        /// <exception cref="MySqlException">更新失败</exception>
        public void AdminModifyInfo(AdminInfoModel mod)
        {
            AdminInfoModel info;

            try
            {
                info = GetAdminInfo(mod.ID);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            info.UpdateInfo(mod);
            var newInfo = new AdminInfo().UpdateInfo(info);

            try
            {
                DbContext.DBstatic.Updateable(newInfo).IgnoreColumns(true, ignoreAllDefaultValue: true)
                .ExecuteCommand();
            }
            catch (MySqlException ex)
            {
                Console.WriteLine(ex.ToString());
                //throw ex;
            }
        }
Пример #2
0
        /// <summary>
        /// ----   begin log in
        /// </summary>
        private void button1_Click(object sender, EventArgs e)
        {
            lblP.Visible = false;
            lblU.Visible = false;
            MainForm main = new MainForm();

            if (this.rdoUser.Checked == true)
            {
                StudentInfoModel student = new StudentInfoModel();

                if (checkStudent(out student))
                {
                    getLoginStudent login = new getLoginStudent(main.getLoginStudent);
                    login(student);
                    main.Show();
                    this.Hide();
                }
            }
            else
            {
                AdminInfoModel admin = new AdminInfoModel();

                if (checkAdmin(out admin))
                {
                    getLoginAdmin login = new getLoginAdmin(main.getLoginAdmin);
                    login(admin);
                    main.Show();

                    this.Hide();
                }
            }
        }
Пример #3
0
        /// <summary>
        /// 管理员登陆
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>

        public SqlDataReader AdminLogin(AdminInfoModel model)
        {
            string        sql = "select * from AdminInfo where Admin_Name=@0 and Admin_Password=@1";
            SqlDataReader dr  = SqlHelper.ExReader(sql, model.Admin_Name, model.Admin_Password);

            return(dr);
        }
Пример #4
0
        /// <summary>
        /// get login admin information by loginID
        /// </summary>
        public AdminInfoModel getAdminInfoByID(string loginID)
        {
            AdminInfoModel admin = null;
            string         comd  = "select * from AdminInfo where loginID = @loginID";

            SqlParameter[] ps = { new SqlParameter("@loginID", SqlDbType.VarChar)
                                  {
                                      Value = loginID
                                  } };
            SQLHelper      h = new SQLHelper();

            using (SqlDataReader read = h.getDataReader(comd, ps))
            {
                if (read.HasRows)
                {
                    read.Read();
                    admin           = new AdminInfoModel();
                    admin.AdminID   = read["adminID"].ToString();
                    admin.AdminName = read["adminName"].ToString();
                    admin.AdminPwd  = read["adminPwd"].ToString();
                    admin.LoginID   = read["loginID"].ToString();
                }
            }
            return(admin);
        }
Пример #5
0
        /// <summary>
        /// 检查管理员权限
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>

        public bool CheckAdminInfo(AdminInfoModel model)
        {
            string        sql = "select * from AdminInfo where Admin_Name=@0";
            SqlDataReader dr  = SqlHelper.ExReader(sql, model.Admin_Name);
            bool          b   = dr.Read();

            dr.Close();
            return(b);
        }
Пример #6
0
        /// <summary>
        /// 检查旧密码
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>

        public bool CheckOldPass(AdminInfoModel model)
        {
            string        sql = "select * from AdminInfo where Admin_ID=@0 and Admin_Password=@1";
            SqlDataReader dr  = SqlHelper.ExReader(sql, model.Admin_ID, model.Admin_Password);
            bool          bo  = dr.Read();

            dr.Close();
            return(bo);
        }
Пример #7
0
 /// <summary>
 /// 获取登录的管理员
 /// </summary>
 /// <param name="admin"></param>
 public void getLoginAdmin(AdminInfoModel admin)
 {
     lblShowID.Text         = "编号:" + admin.AdminID;
     lblShowName.Text       = "用户名:" + admin.AdminName;
     this.btnBorrow.Enabled = false;
     pro = "admin";
     id  = admin.AdminID;
     this.btnInfoList.Visible = true;
 }
Пример #8
0
        /// <summary>
        /// 填充admin对象
        /// </summary>
        /// <param name="list"></param>
        /// <param name="read"></param>
        private static void FillModel(List <AdminInfoModel> list, SqlDataReader read)
        {
            AdminInfoModel admin = new AdminInfoModel();

            admin.AdminID   = read["adminID"].ToString();
            admin.AdminName = read["adminName"].ToString();
            admin.AdminPwd  = read["adminPwd"].ToString();
            admin.LoginID   = read["loginID"].ToString();

            list.Add(admin);
        }
Пример #9
0
 /// <summary>
 ///     初始化一个临时的用户变量,用于更新信息
 /// </summary>
 /// <param name="info"></param>
 /// <returns></returns>
 public AdminInfo UpdateInfo(AdminInfoModel ls)
 {
     if (ls.ID == 0)
     {
         return(null);
     }
     ID      = ls.ID;
     Name    = ls.Name;
     Contact = ls.Contact;
     Gender  = ls.Gender;
     return(this);
 }
Пример #10
0
        public IActionResult ModInfo(string contact            = null, [FromQuery] string name = null,
                                     [FromQuery] string gender = null)
        {
            name   = GlobalFunc.MyUrlDeCode(name, Encoding.UTF8);
            gender = GlobalFunc.MyUrlDeCode(gender, Encoding.UTF8);
            var auth = HttpContext.AuthenticateAsync();
            var id   = Convert.ToInt32(auth.Result.Principal.Claims.First(t => t.Type.Equals(ClaimTypes.NameIdentifier))
                                       ?.Value);

            if (id >= 10000)
            {
                var newInfo = new ReaderInfoModel
                {
                    ID      = id,
                    Name    = name,
                    Contact = contact,
                    Gender  = gender
                };
                try
                {
                    rd.ReaderModifyInfo(newInfo);
                }
                catch (Exception ex)
                {
                    return(Ok(new { error = ex.Message }));
                }
            }
            else if (id < 10000 && id >= 1)
            {
                var newInfo = new AdminInfoModel
                {
                    ID      = id,
                    Name    = name,
                    Contact = contact,
                    Gender  = gender
                };
                try
                {
                    ad.AdminModifyInfo(newInfo);
                }
                catch (Exception ex)
                {
                    return(Ok(new { error = ex.Message }));
                }
            }
            else
            {
                return(Ok(new { error = "Invalid Id" }));
            }

            return(Ok(GlobalFunc.GetBasicInfo(id)));
        }
Пример #11
0
        private List <AdminInfoModel> DateToList(DataTable dt)
        {
            List <AdminInfoModel> lAim = new List <AdminInfoModel>();

            foreach (DataRow dr in dt.Rows)
            {
                AdminInfoModel aim = new AdminInfoModel();
                aim.AdminName = dr["AdminName"].ToString();
                aim.Password  = dr["Password"].ToString();
                lAim.Add(aim);
            }
            return(lAim);
        }
Пример #12
0
        /// <summary>
        ///     获取管理员信息
        /// </summary>
        /// <param name="userID">用户 ID</param>
        /// <returns>信息字典{ 信息类型, 信息内容 }</returns>
        public AdminInfoModel GetAdminInfo(int userID)
        {
            AdminInfoModel info = null;

            if (GlobalFunc.FindPersonById(userID))
            {
                info = DbContext.DBstatic.Queryable <AdminInfo>()
                       .Select(f => new AdminInfoModel
                {
                    ID = f.ID, Contact = f.Contact, Name = f.Name, Gender = f.Gender
                })
                       .Where(it => it.ID == userID).Single();
            }
            return(info);
        }
Пример #13
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (Session != null && Session["admin"] != null)
            {
                CurrentUser = Session["admin"] as AdminInfoModel;
            }
            else
            {
                filterContext.Result = new RedirectResult("/login");;
            }

            OnAppActionExecuting(filterContext);

            base.OnActionExecuting(filterContext);
        }
Пример #14
0
        private void button1_Click(object sender, EventArgs e)
        {
            string oldpass = this.txtPass.Text.Trim();
            string newpass = this.newPass.Text.Trim();
            string repass  = this.txtRepass.Text.Trim();

            if (newpass != repass)
            {
                MessageBox.Show("两次密码不一致");
                return;
            }
            //AdminInfoModel adminmodel = new AdminInfoModel();
            //AdminInfoBLL admin=new AdminInfoBLL ();
            //adminmodel.Admin_Password = oldpass;
            //MainForm m = (MainForm)this.Owner;
            //int a = m.adminid;
            //adminmodel.Admin_ID =m.adminid;

            //bool b = admin.CheckOldPass(adminmodel);//检查旧密码是否正确
            //if(b==false)
            //{
            //    MessageBox.Show("原始密码错误");
            //    return;
            //}
            //AdminInfoModel model = new AdminInfoModel();
            //model.Admin_ID = m.adminid;
            //model.Admin_Password = newpass;
            //admin.UpdateAdminInfo(adminmodel);
            MainForm m = (MainForm)this.Owner;
            int      a = m.adminid;

            adminmodel.Admin_ID       = a;
            adminmodel.Admin_Password = oldpass;
            bool b = admin.CheckOldPass(adminmodel);

            if (b == false)
            {
                MessageBox.Show("原密码错误");
                return;
            }
            AdminInfoModel model = new AdminInfoModel();

            adminmodel.Admin_ID       = m.adminid;
            adminmodel.Admin_Password = newpass;
            admin.UpdateAdminInfo(adminmodel);
            this.Close();
        }
Пример #15
0
        public RESTfulModel Login(LoginModel model)
        {
            try
            {
                // 字段验证

                AdminInfoModel adminInfoModel = adminInfoDAL.GetModel(model.Mobile);
                if (adminInfoModel != null)
                {
                    string pwd = EncryptHelper.MD5Encrypt(ConfigHelper.Salt + EncryptHelper.MD5Encrypt(model.Password));

                    if (adminInfoModel.Password == pwd)
                    {
                        return(new RESTfulModel()
                        {
                            Code = (int)CodeEnum.成功, Msg = string.Format(codeMsgDAL.GetByCode((int)CodeEnum.成功), "登陆成功"), Data = adminInfoModel
                        });
                    }
                    else
                    {
                        return(new RESTfulModel()
                        {
                            Code = (int)CodeEnum.密码错误, Msg = codeMsgDAL.GetByCode((int)CodeEnum.密码错误)
                        });
                    }
                }
                else
                {
                    return(new RESTfulModel()
                    {
                        Code = (int)CodeEnum.账号不存在, Msg = codeMsgDAL.GetByCode((int)CodeEnum.账号不存在)
                    });
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
                return(new RESTfulModel()
                {
                    Code = (int)CodeEnum.系统异常, Msg = codeMsgDAL.GetByCode((int)CodeEnum.系统异常)
                });
            }
        }
Пример #16
0
 private AdminInfoModel EntityToModel(DataRow dr)
 {
     if (dr != null)
     {
         AdminInfoModel model = new AdminInfoModel();
         model.ID              = dr["id"].ToInt();
         model.BusinessID      = dr["business_id"].ToString();
         model.Mobile          = dr["mobile"].ToString();
         model.Salt            = dr["salt"].ToString();
         model.Password        = dr["password"].ToString();
         model.RealName        = dr["real_name"].ToString();
         model.UserStat        = dr["user_stat"].ToInt();
         model.LoginErrorTimes = dr["login_error_times"].ToInt();
         model.CreateTime      = dr["create_time"].ToDateTime();
         model.UpdateTime      = dr["update_time"].ToDateTime();
         return(model);
     }
     return(null);
 }
Пример #17
0
        /// <summary>
        /// delete admin by model
        /// </summary>
        public int deleteAdminInfo(AdminInfoModel admin)
        {
            string comd = "delete from AdminInfo where adminPwd=@adminPwd and loginID = @loginID  ";

            SqlParameter[] ps =
            {
                new SqlParameter("@adminPwd", SqlDbType.NVarChar)
                {
                    Value = admin.AdminPwd
                },
                new SqlParameter("@loginID", SqlDbType.NVarChar)
                {
                    Value = admin.LoginID
                }
            };
            SQLHelper h = new SQLHelper();

            return(h.ExecuteNonQuery(comd));
        }
Пример #18
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);
            }
        }
Пример #19
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;
            }
        }
Пример #20
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();
        }
Пример #21
0
        //获取所有用户对应的信息
        public static AdminInfoModel getUserInfo(IMemoryCache _cache, string token, basisContext _context)
        {
            string a = _cache.Get <string>(token);
            //获取当前用户
            Admin admin = ConvertJson.JsonStringToObj <Admin>(a);
            //获取当前用户权限
            var adminscope = _context.AdminScopes.Where(sa => sa.Identifier == admin.AdminScopeIdentifier).SingleOrDefault();

            AdminInfoModel user = new AdminInfoModel
            {
                Id                   = admin.Id,
                RealName             = admin.RealName,
                UserName             = admin.UserName,
                AdminScopeIdentifier = admin.AdminScopeIdentifier,
                OneLevelScopeName    = adminscope.OneLevelScopeName,
                TwoLevelScopeName    = adminscope.TwoLevelScopeName,
                OneLevelScopeId      = adminscope.OneLevelScopeId,
                TwoLevelScopeId      = adminscope.TwoLevelScopeId
            };

            return(user);
        }
Пример #22
0
        /// <summary>
        /// update admin information by model
        /// </summary>
        /// <param name="admin"></param>
        /// <returns></returns>
        public int updateAdminInfo(AdminInfoModel admin)
        {
            string comd = "update AdminInfo set adminName=@adminName,adminPwd=@adminPwd    where  adminID=@adminID    ";

            SqlParameter[] ps =
            {
                new SqlParameter("@adminName", SqlDbType.NVarChar)
                {
                    Value = admin.AdminName
                },
                new SqlParameter("@adminPwd", SqlDbType.NVarChar)
                {
                    Value = admin.AdminPwd
                },
                new SqlParameter("@adminID", SqlDbType.NVarChar)
                {
                    Value = admin.AdminID
                }
            };
            SQLHelper h = new SQLHelper();

            return(h.ExecuteNonQuery(comd));
        }
Пример #23
0
        /// <summary>
        /// insert one admin
        /// </summary>
        /// <param name="admin"></param>
        /// <returns></returns>
        public int insertAdminInfo(AdminInfoModel admin)
        {
            string comd = "insert into AdminInfo(loginID,adminName,adminPwd) values( @loginID ,@adminName,@adminPwd  )";

            SqlParameter[] ps =
            {
                new SqlParameter("@loginID", SqlDbType.NVarChar)
                {
                    Value = admin.LoginID
                },
                new SqlParameter("@adminName", SqlDbType.NVarChar)
                {
                    Value = admin.AdminName
                },
                new SqlParameter("@adminPwd", SqlDbType.NVarChar)
                {
                    Value = admin.AdminPwd
                }
            };
            SQLHelper h = new SQLHelper();

            return(h.ExecuteNonQuery(comd));
        }
Пример #24
0
        /// <summary>
        /// delete admin by model
        /// </summary>
        public int deleteAdminInfo(AdminInfoModel admin)
        {
            AdminInfoDAL dal = new AdminInfoDAL();

            return(dal.deleteAdminInfo(admin));
        }
Пример #25
0
        /// <summary>
        /// update admin information by model
        /// </summary>
        /// <param name="admin"></param>
        /// <returns></returns>
        public int updateAdminInfo(AdminInfoModel admin)
        {
            AdminInfoDAL dal = new AdminInfoDAL();

            return(dal.insertAdminInfo(admin));
        }
Пример #26
0
        public ActionResult Save(AdminInfoModel model)
        {
            bool showlayout = RequestBool("showlayout");
            var  mod        = new Mng_User();

            if (model.id == 0 && string.IsNullOrEmpty(model.password))
            {
                if (showlayout)
                {
                    return(MessageBoxAndReturn("请填写密码!"));
                }
                else
                {
                    return(LayerAlertErrorAndReturn("请填写密码!"));
                }
            }
            if (!string.IsNullOrEmpty(model.password))
            {
                mod.Password = Tools.Security.Md5Helper.GetMd5Hash(model.password);
            }
            if (model.departid == 0)
            {
                if (showlayout)
                {
                    return(MessageBoxAndReturn("请选择部门!"));
                }
                else
                {
                    return(LayerAlertErrorAndReturn("请选择部门!"));
                }
            }
            mod.UserName       = model.username.Trim2();
            mod.RealName       = model.realname.Trim2();
            mod.DepartId       = model.departid;
            mod.DepartMentName = Bll.BllMng_DepartmentClass.Instance().GetClassName(model.departid);
            mod.GroupId        = model.groupid;
            mod.ParUserId      = model.paruserid;
            mod.Sex            = model.sex;

            int result = 0;

            if (model.id > 0)
            {
                result = Bll.BllMng_User.UpdateInfo(mod, model.id);
                if (result > 0)
                {
                    AdminData.Reload();
                    return(LayerAlertSuccessAndRefresh("保存成功!"));
                }
            }
            else
            {
                mod.LoginIp    = "127.0.0.1";
                mod.LoginTime  = DateTime.Parse("1999-01-01");
                mod.LoginTimes = 0;
                mod.Pic        = "";
                mod.InJob      = true;
                result         = Bll.BllMng_User.AddNoReturn(mod);
                if (result > 0)
                {
                    if (showlayout)
                    {
                        AdminData.Reload();
                        return(MessageBoxAndJump("保存成功!", "/admin/adminmanage/add?layout=true"));
                    }
                    else
                    {
                        return(LayerAlertSuccessAndRefresh("保存成功!"));
                    }
                }
            }
            if (result == -1)
            {
                if (showlayout)
                {
                    return(MessageBoxAndReturn("用户名已存在!"));
                }
                else
                {
                    return(LayerAlertErrorAndReturn("用户名已存在!"));
                }
            }
            else
            {
                if (showlayout)
                {
                    return(MessageBoxAndReturn("保存失败!"));
                }
                else
                {
                    return(LayerAlertErrorAndReturn("保存失败!"));
                }
            }
        }
Пример #27
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;
                }
            }
        }
Пример #28
0
 /// <summary>
 /// 检查旧密码
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool CheckOldPass(AdminInfoModel model)
 {
     return(admin.CheckOldPass(model));
 }
Пример #29
0
 /// <summary>
 /// 检查管理员权限
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool CheckAdminInfo(AdminInfoModel model)
 {
     return(admin.CheckAdminInfo(model));
 }
Пример #30
0
 /// <summary>
 /// 管理员登陆
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public SqlDataReader AdminLogin(AdminInfoModel model)
 {
     return(admin.AdminLogin(model));
 }