健身管理系统【管理员添加,删除,个人信息,项目】

3 篇文章 0 订阅

一,前面网页内容
前面关于健身管理系统的介绍和部分代码,如果没有看第一部分,先点击下方连接,看第一部分哦
https://blog.csdn.net/weixin_46964231/article/details/118277157

二,各个模块代码
体验用户的添加,管理员修改,查询和会员的类似,就不再赘述,这里只发后端管理员删除和增加代码
显示前端

@{
    ViewBag.Title = "Employeeinformation";
    Layout = "~/Views/Default1/Index.cshtml";
}

<div class="page-head">
    <ol class="breadcrumb">
        <li><a href="#">员工管理</a></li>
        <li class="active">员工信息</li>
    </ol>
    <h3>员工信息</h3>
</div>
<div class="wrapper">
    <div class="panel">
        <div class="panel-body">
            <div class="form1 searchbox">
                <ul class="row">
                    <li class="col-xs-3">
                        <span>姓名:</span>
                        <input type="text" class="form-control" name="nameB" id="nameB">
                    </li>
                    <li class="col-xs-3">
                        <span>身份证:</span>
                        <input type="text" class="form-control" name="cardIDB" id="cardIDB">
                    </li>
                    <li class="col-xs-4" style="padding-left: 0"> <button type="submit" onclick="chufa3()" class="btn btn-primary">查询</button> </li>
                </ul>
            </div>
            <div class="line"></div>
            <table id="gaibian" class="table m-t-20">
                <thead>
                    <tr>
                        <th>编号</th>
                        <th>个人照片</th>
                        <th>姓名</th>
                        <th>年龄</th>
                        <th>身份证号</th>
                        <th>密码</th>
                        <th>电话</th>
                        <th>入职时间</th>
                        <th>工资</th>
                        <th>职位</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var item in ViewBag.information)
                    {
                        <tr class="trr">
                            <td class="aa">@item.id</td>
                            <td ><img id="b" width="80" height="80" src="~/img/@item.img" /></td>
                            <td id="bb">@item.name</td>
                            <td id="cc">@item.age</td>
                            <td class="dd">@item.cardID</td>
                            <td>@item.pwd</td>
                            <td id="ff">@item.phone</td>
                            <td id="gg">@item.worktime</td>
                            <td id="hh">@item.salary</td>
                            <td id="ii">@item.rank</td>
                            <td>@*<a href="/Default1/EmployeeContent?id=@item.id">详情</a>&nbsp;*@<a onclick="return confirm('确认删除吗?')" href="/Default1/EmployeeDelete?id=@item.id">删除</a>&nbsp;<a href="/Default1/EmployeeUpdate?id=@item.id">修改</a></td>
                        </tr>
                    }
                </tbody>
            </table>
        </div>
    </div>
</div>
<script src="~/Scripts/jquery-3.4.1.js"></script>
<script>
    //AJAX改变前台数据
    function chufa3() {
        $.ajax({
            url: "/Default1/Employeeinformation",
            type: "POST",
            data: { "nameB": $("#nameB").val(), "cardIDB": $("#cardIDB").val() },
            success: function (dataB) {
                $("#gaibian").html(dataB);
            }
        })
    }
    //老板本人信息不会在员工管理页面显示
    for (var i = 0; i < $(".aa").length; i++) {
        var a = $(".dd")[i].innerHTML;
        if (a=="431026199906040013") {
            $($(".trr")[i]).hide();
        }
    }
</script>

后端
员工删除

        public void EmployeeDelete(int id)
        {
            JianShengEntities1 db = new JianShengEntities1();
            var a = db.Employee.SingleOrDefault(p => p.id == id);
            db.Employee.Remove(a);//删除
            if (db.SaveChanges() > 0)
            {
                Response.Write("<script>alert('删除成功');location.href='/Default1/Employeeinformation'</script>");
            }
        }

效果
在这里插入图片描述

员工添加
前端

@{
    ViewBag.Title = "EmployeeAdd";
    Layout = "~/Views/Default1/Index.cshtml";
}

<div class="page-head">
    <ol class="breadcrumb">
        <li><a href="#">员工管理</a></li>
        <li class="active">员工添加</li>
    </ol>
    <h3>员工添加</h3>
</div>
<div class="wrapper">
    <div class="panel">
        <div class="panel-body">
            <form action="/Default1/EmployeeAdd" method="post" enctype="multipart/form-data">
                <div class="modal-body">
                    <div class="form1 form2">
                        <ul class="row">
                            <li class="col-xs-12">
                                <span>个人照片:</span>
                                <input name="img" type="file" />
                            </li>
                            <li class="col-xs-12">
                                <span>姓名:</span>
                                <input type="text" name="name" class="form-control">
                            </li>
                            <li class="col-xs-12">
                                <span>年龄:</span>
                                <input type="text" name="age" class="form-control">
                            </li>
                            <li class="col-xs-12">
                                <span>身份证号:</span>
                                <input type="text" name="cardID" class="form-control">
                            </li>
                            <li class="col-xs-12">
                                <span>电话:</span>
                                <input type="text" name="phone" class="form-control">
                            </li>
                            <li class="col-xs-12">
                                <span>密码:</span>
                                <input type="text" name="pwd" class="form-control">
                            </li>
                            <li class="col-xs-12">
                                <span onclick="ruzhishijian()">入职时间:</span>
                                <input type="text" readonly name="worktime" id="ruzhiTime" class="form-control">
                            </li>
                            <li class="col-xs-12">
                                <span>工资:</span>
                                <input type="text" name="salary" class="form-control">
                            </li>
                            <li class="col-xs-12">
                                <span>职位:</span>
                                <select name="rank" class="form-control">
                                    <option>前台</option>
                                    <option>健身教练</option>
                                    <option>清洁人</option>
                                    <option>煮饭人</option>
                                    <option>其他</option>
                                </select>
                            </li>
                        </ul>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="submit" class="btn btn-primary">提交</button>
                </div>
            </form>
        </div>
    </div>
</div>
<script>
    var d = new Date();
    function ruzhishijian() {
        $("#ruzhiTime").val(d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate())
    }
</script>

后端

        //员工添加
        public ActionResult EmployeeAdd()
        {
            ViewBag.name = System.Web.HttpContext.Current.Session["result"];
            return View();
        }
        [HttpPost]
        public void EmployeeAdd(Employee employee, HttpPostedFileBase img)
        {
            JianShengEntities1 db = new JianShengEntities1();
            img.SaveAs(Server.MapPath("~/img/" + img.FileName));
            employee.img = img.FileName;
            if (db.Employee.Where(p => p.cardID == employee.cardID).Count() == 0)
            {
                //添加管理员到数据库
                db.Employee.Add(employee);
                //判断是否添加成功
                if (db.SaveChanges() > 0)
                {
                    Response.Write("<script>alert('员工信息添加成功!');location.href='/Default1/EmployeeAdd'</script>");
                }
            } 
            
        }

效果
在这里插入图片描述

个人信息
个人信息这里的点就是管理员有一个管理人数这个选项,这样老板知道每个管理员管理了多少会员,可以作为给员工评选,加工资这些的依据,当然也方便裁掉能力不足的员工【狗头保命】
前端

@{
    ViewBag.Title = "EmployeeContent1";
    Layout = "~/Views/Default1/Index.cshtml";
}
<div class="page-head">
    <ol class="breadcrumb">
        <li><a href="#">个人信息管理</a></li>
        <li class="active">个人信息</li>
    </ol>
    <h3>个人信息</h3>
</div>
<div class="content-body">
    <section class="file-browser">
        <div class="card" style="">
            <div class="card-header">
                <label class="card-title"></label>
            </div>
            <div class="card-body">


                <div class="inputbox" style="width: 100%; max-width:800px; margin: 0 auto;">
                    <ul class="row">
                        <li class="col-md-9">
                            <ul class="row">
                                <li class="col-md-6">
                                    <h5 class="mt-2">编号</h5>
                                    <fieldset class="form-group">
                                        <input type="text" class="form-control" placeholder="" readonly value="@ViewBag.id">
                                    </fieldset>
                                </li>
                                <li class="col-md-6">
                                    <h5 class="mt-2">姓名</h5>
                                    <fieldset class="form-group">
                                        <input type="text" class="form-control" readonly placeholder="" value="@ViewBag.name">
                                    </fieldset>
                                </li>

                                <li class="col-md-6">
                                    <h5 class="mt-2">年龄</h5>
                                    <fieldset class="form-group">
                                        <input type="text" class="form-control" readonly placeholder="" value="@ViewBag.age">
                                    </fieldset>
                                </li>


                                <li class="col-md-6">
                                    <h5 class="mt-2">职位</h5>
                                    <fieldset class="form-group">
                                        <input type="text" class="form-control" readonly placeholder="" value="@ViewBag.rank">
                                    </fieldset>
                                </li>
                                <li class="col-md-6">
                                    <h5 class="mt-2">电话</h5>
                                    <fieldset class="form-group">
                                        <input type="text" class="form-control" readonly placeholder="" value="@ViewBag.phone">
                                    </fieldset>
                                </li>


                                <li class="col-md-6">
                                    <h5 class="mt-2">身份证号</h5>
                                    <fieldset class="form-group">
                                        <input type="text" class="form-control" readonly placeholder="" value="@ViewBag.cardID">
                                    </fieldset>
                                </li>

                                <li class="col-md-6">
                                    <h5 class="mt-2">入职时间</h5>
                                    <fieldset class="form-group">
                                        <input type="text" class="form-control" readonly value="@ViewBag.worktime">
                                    </fieldset>
                                </li>
                                <li class="col-md-6">
                                    <h5 class="mt-2">管理人数</h5>
                                    <fieldset class="form-group">
                                        <input type="text" class="form-control" value="@ViewBag.count" readonly>
                                    </fieldset>
                                </li>
                                <li class="col-md-12">
                                    <h5 class="mt-2">工资</h5>
                                    <fieldset class="form-group">
                                        <input type="text" class="form-control" readonly value="@ViewBag.salary">
                                    </fieldset>
                                </li>

                            </ul>
                        </li>
                        <li class="col-md-3">
                            <div class="headedit text-center">
                                <strong>个人照片</strong>
                                <div class="imgbox"> <img class="roundimg" src="~/img/@ViewBag.img" width="100"> </div>
                            </div>
                        </li>
                    </ul>
                </div>
                <div class="text-center mt-2">
                </div>
            </div>
        </div>
    </section>
</div>

后端

       //员工个人信息
       public ActionResult EmployeeContent1()
        {
            //接收登录页的个人信息并传值到视图
            ViewBag.id= System.Web.HttpContext.Current.Session["id"].ToString();
            ViewBag.name = System.Web.HttpContext.Current.Session["result"].ToString();
            string cardID = System.Web.HttpContext.Current.Session["cardID"].ToString();
            string age = System.Web.HttpContext.Current.Session["age"].ToString();
            string phone = System.Web.HttpContext.Current.Session["phone"].ToString();
            string rank = System.Web.HttpContext.Current.Session["rank"].ToString();
            string salary = System.Web.HttpContext.Current.Session["salary"].ToString();
            string worktime = System.Web.HttpContext.Current.Session["wordtime"].ToString();
            string img = System.Web.HttpContext.Current.Session["img"].ToString();
            string count= System.Web.HttpContext.Current.Session["count"].ToString();
            ViewBag.cardID = cardID;
            ViewBag.age = age;
            ViewBag.phone = phone;
            ViewBag.rank = rank;
            ViewBag.salary = salary;
            ViewBag.worktime = worktime;
            ViewBag.img = img;
            ViewBag.count=count;
            return View();
        }
        [HttpPost]
        public void EmployeeContent1(string b)
        {
            //接收后台传过来的管理员管理的数量值
            System.Web.HttpContext.Current.Session["count"] = b;
        }

效果 在这里插入图片描述
三,项目源码
链接:https://pan.baidu.com/s/1TYPBPF5VRk6nkoOY5apGWQ
提取码:fanc

如果觉得文章对你有帮助的话,可以给我一个打赏哦,谢谢~
在这里插入图片描述

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
健身管理系统管理员登录实现的代码需要包括以下几个方面: 1. 实体类:管理员实体类,包括管理员ID,管理员姓名,管理员密码等属性。 2. 数据访问层:管理员数据访问层,包括对管理员信息进行增加、删除、修改、查询等操作的方法。 3. 业务逻辑层:管理员业务逻辑层,包括管理员登录验证的方法。 4. 控制器层:管理员登录控制器层,包括管理员登录页面的跳转、管理员登录验证的调用等操作。 下面是一个基于SSM框架的健身管理系统管理员登录实现的代码分析。 1. 实体类 管理员实体类Admin.java: ``` public class Admin { private Integer adminId; //管理员ID private String adminName; //管理员姓名 private String adminPwd; //管理员密码 //省略getter和setter方法 } ``` 2. 数据访问层 管理员数据访问层AdminMapper.java: ``` public interface AdminMapper { //添加管理员 public void addAdmin(Admin admin) throws Exception; //删除管理员 public void deleteAdmin(Integer adminId) throws Exception; //修改管理员信息 public void updateAdmin(Admin admin) throws Exception; //根据管理员ID查询管理员信息 public Admin findAdminById(Integer adminId) throws Exception; //根据管理员姓名查询管理员信息 public List<Admin> findAdminByName(String adminName) throws Exception; } ``` 3. 业务逻辑层 管理员业务逻辑层AdminService.java: ``` public interface AdminService { //管理员登录验证 public boolean checkLogin(String adminName, String adminPwd) throws Exception; } ``` 管理员业务逻辑层实现类AdminServiceImpl.java: ``` @Service("adminService") public class AdminServiceImpl implements AdminService { @Resource private AdminMapper adminMapper; //管理员登录验证 public boolean checkLogin(String adminName, String adminPwd) throws Exception { Admin admin = adminMapper.findAdminByName(adminName).get(0); if (admin != null && admin.getAdminPwd().equals(adminPwd)) { return true; } return false; } } ``` 4. 控制器层 管理员登录控制器层AdminLoginController.java: ``` @Controller public class AdminLoginController { @Resource private AdminService adminService; //管理员登录页面跳转 @RequestMapping("/adminlogin") public String adminLogin() throws Exception { return "adminlogin"; } //管理员登录验证 @RequestMapping("/checklogin") public String checkLogin(HttpServletRequest request, Model model) throws Exception { String adminName = request.getParameter("adminName"); String adminPwd = request.getParameter("adminPwd"); boolean result = adminService.checkLogin(adminName, adminPwd); if (result) { return "adminindex"; } else { model.addAttribute("msg", "用户名或密码错误!"); return "adminlogin"; } } } ``` 以上就是一个基于SSM框架的健身管理系统管理员登录实现的代码分析,其中实体类、数据访问层、业务逻辑层分别完成了对管理员信息的封装、数据库操作和业务逻辑处理,控制器层完成了管理员登录页面跳转和登录验证的操作。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值