一,前面网页内容:
前面关于健身管理系统的介绍和部分代码,如果没有看第一部分,先点击下方连接,看第一部分哦
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> *@<a onclick="return confirm('确认删除吗?')" href="/Default1/EmployeeDelete?id=@item.id">删除</a> <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
如果觉得文章对你有帮助的话,可以给我一个打赏哦,谢谢~