借贷系统(后端)2

上次我们讲到首页中的“修改密码”,这次我们要讲的是认证管理中的学历认证。学历认证中比较难的是让图片以二进制的形式存入数据库中,并显示在图表中。

学历认证中由两个按钮以及一张图表组成,分别是“修改”,“审核”

修改需要可以修改图片,修改后的图片以二进制的形式保存到数据库中。


<!DOCTYPE html>

<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>学历认证</title>
    <link rel="shortcut icon" href="~/Content/images/重庆邮电.ico" />
    <link href="~/Content/Plugins/layui/css/layui.css" rel="stylesheet" />
    <link href="~/Content/Courseware/css/SetExaminee.css?=0.1" rel="stylesheet" />
    <link href="~/Content/Plugins/bootstrap-4.6.0/dist/css/bootstrap.min.css" rel="stylesheet" />
    <style>
        .layui-btn-xs {
            height: 28px;
            padding: 2px 16px;
            font-size: 12px;
        }

        .col-form-label {
            font-size: 14px;
        }
    </style>
</head>
<body>
    <!-- 查询条件&表格 -->
    <div class="container-fluid">
        <!--查询条件-->
        <div class="row">
            <div class="col-sm-8">
                <form action="/" method="post" id="formSearch">
                    <div class="form-row">
                        <div class="row mt-3">
                            <label class="col-form-label col-auto" for="searchText">搜索:</label>
                            <input type="text" class="form-control col" style="width:500px" id="searchText" name="searchText" placeholder="模糊搜索用户名" oninput="searchStudent()">
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <!--table 表格-->
        <div class="row mt-1">
            <div class="col">
                <table class="layui-hide" id="tabStudents" lay-filter="tabStudents"></table>
            </div>
        </div>
        <!-- 修改模态框-->
        <div class="modal fade" id="modStudent" data-backdrop="static">
            <div class="modal-dialog modal-dialog-centered modal-lg">
                <div class="modal-content">
                    <div class="modal-header bg-green">
                        <h4 class="modal-title">修改材料认证</h4>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <div class="modal-body">
                        <div class="container-fluid">
                            <form action="/" method="post" id="frmStuInfor">
                                <div class="row">
                                    <div class="col-sm-3">
                                        <img src="" alt="学生图片" id="StuPicture" class="d-block" ondblclick="openFileInput()" />
                                        <input type="file" id="fileImage" name="imgFile" multiple="multiple" accept="image/png,image/jpg,image/bmp,image/gif,image/jpeg" hidden />
                                    </div>
                                    <div class="col-sm-9 px-0">
                                        <input type="hidden" id="AuthenticateEducationEackgroundID1" name="AuthenticateEducationEackgroundID" />
                                        <input type="hidden" id="UserID1" name="UserID" />
                                        <input type="hidden" id="UserDetailID" name="UserDetailID" />
                                        <div class="form-row text-right">
                                            <label class="col-sm-2 col-form-label text-right">用户名</label>
                                            <div class="col-sm-4">
                                                <input type="text" class="form-control form-control-sm" name="UserName" id="UserName" value="" />
                                            </div>
                                            <label class="col-sm-2 col-form-label text-right">学校</label>
                                            <div class="col-sm-4">
                                                <input type="text" class="form-control form-control-sm" name="EackgroundSchool" id="EackgroundSchool" value="" />
                                            </div>
                                        </div>
                                        <div class="form-row mt-2 text-right">
                                            <label class="col-sm-2 col-form-label text-right">专业</label>
                                            <div class="col-sm-4">
                                                <input type="text" class="form-control form-control-sm" name="EackgroundSpecialty" id="EackgroundSpecialty" value=""/>
                                            </div>
                                            <label class="col-sm-2 col-form-label text-right">学历</label>
                                            <div class="col-sm-4">
                                                <input type="text" class="form-control form-control-sm" name="EducationEackground" id="EducationEackground" value="" />
                                            </div>
                                        </div>
                                        <div class="form-row mt-2">
                                            <label class="col-sm-2 col-form-label text-right">审核状态</label>
                                            <div class="col-sm-4">
                                                <select class="form-control form-control-sm" name="EackgroundStatus" id="EackgroundStatus">
                                                    <option value="0">---请选择---</option>
                                                    <option value="审核中">审核中</option>
                                                    <option value="成功">成功</option>
                                                    <option value="失败">失败</option>
                                                </select>
                                            </div>
                                            <label class="col-sm-2 col-form-label  text-right">备注</label>
                                            <div class="col-sm-4">
                                                <input type="text" class="form-control form-control-sm" name="EackgroundRemark" id="EackgroundRemark" value="" />
                                            </div>
                                        </div>
                                        <div class="form-row mt-2">
                                            <label class="col-sm-2 col-form-label text-right">真实姓名</label>
                                            <div class="col-sm-4">
                                                <input type="text" class="form-control form-control-sm" name="DetailName" id="DetailName" />
                                            </div>
                                            <label class="col-sm-2 col-form-label text-right">入学时间</label>
                                            <div class="col-sm-4">
                                                <input type="text" class="form-control form-control-sm" name="EnrollmentTime" id="EnrollmentTime" />
                                            </div>
                                            <label class="col-sm-2 col-form-label text-right">毕业时间</label>
                                            <div class="col-sm-4">
                                                <input type="text" class="form-control form-control-sm" name="GraduationDate" id="GraduationDate" />
                                            </div>
                                        </div>
                                        <div class="col-sm-4 offset-sm-2">
                                            <button type="button" class="btn btn-outline-primary btn-sm" onclick="saveStudent()">保存</button>
                                            <button type="button" class="btn btn-outline-secondary btn-sm" data-dismiss="modal">关闭</button>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--审核模态框-->
        <div class="modal fade" id="studentModal1" data-backdrop="static" data-keyboard="false">
            <div class="modal-dialog modal-dialog-centered modal-lg">
                <div class="modal-content">
                    <!-- 顶部 标题 关闭按钮 -->
                    <div class="modal-header">
                        <!--标题-->
                        <h5 class="modal-title" id="modalTitle">人工审核</h5>
                        <!--关闭按钮-->
                        <button type="button" class="close" data-dismiss="modal">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <!-- 内容部分 表单-->
                    <div class="modal-body">
                        <form id="formStudent1">
                            <!--隐藏域  用户id-->
                            <input type="hidden" id="AuthenticateEducationEackgroundID" name="AuthenticateEducationEackgroundID" value="" />
                            <input type="hidden" id="UserID" name="UserID" value="" />
                            <!--状态-->
                            <div class="form-row col-12 col-xl-12 mb-2">
                                <label class="col-sm-4 col-form-label text-right">审核状态:</label>
                                <div class="form-check form-check-inline">
                                    <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio0" value="审核中">
                                    <label class="form-check-label" for="inlineRadio0">审核中</label>
                                </div>
                                <div class="form-check form-check-inline">
                                    <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio1" value="成功">
                                    <label class="form-check-label" for="inlineRadio1">通过审核</label>
                                </div>
                                <div class="form-check form-check-inline">
                                    <input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio2" value="失败">
                                    <label class="form-check-label" for="inlineRadio2">不通过审核</label>
                                </div>
                            </div>
                            <!--审核备注-->
                            <div class="form-row col-12 col-xl-12 mb-2">
                                <label for="IdentifyingCode" class="col-sm-4 col-form-label text-right">审核备注:</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control" id="Review" name="Review" autocomplete="off" />
                                </div>
                            </div>
                            <!--验证码-->
                            <div class="form-row col-12 col-xl-12 mb-2">
                                <label for="IdentifyingCode" class="col-sm-4 col-form-label text-right">验证码:</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control" id="IdentifyingCode" name="validCode" placeholder="请您输入验证码" autocomplete="off">
                                </div>
                                <div class="input-group-prepend col-sm-3">
                                    <img src="/Index/ValidCode" class="input-group-text p-0" id="ValidateCode" />
                                </div>
                            </div>
                        </form>
                    </div>
                    <!-- 底部 按钮 取消 确定 -->
                    <div class="modal-footer">
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
                        <button type="button" class="btn btn-primary" onclick="saveStudentInfor()">保存</button>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="~/Content/Plugins/jquery-3.2.1.min.js"></script>
    <script src="~/Content/Plugins/bootstrap-4.6.0/dist/js/bootstrap.min.js"></script>
    <script src="~/Content/Plugins/layui/layui.js"></script>
    <script src="~/Content/Courseware/js/customfuntion.js"></script>
    <script>
        //全局变量声明
        var tabStudents;//公告 table
        var layer, layuiTable;//保存layui模块以便全局使用

        $(document).ready(function () {
            appendOption("typeName", "SelectNoticeType");
            //加载&初始化layui模块
            layui.use(['layer', 'table'], function () {
                layer = layui.layer;
                layuiTable = layui.table;
                //渲染表格
                tabStudents = layuiTable.render({
                    elem: '#tabStudents',
                    data: [],
                    cols: [[
                        { title: '用户名', field: 'UserName', align: 'center' },
                        { title: '真实姓名', field: 'DetailName', align: 'center' },
                        { title: '学校', field: 'EackgroundSchool', align: 'center' },
                        { title: '专业', field: 'EackgroundSpecialty', align: 'center' },
                        { title: '学历', field: 'EducationEackground', align: 'center' },
                        { title: '入学时间', field: 'Enrollment', align: 'center',width:166 },
                        { title: '毕业时间', field: 'Graduation', align: 'center',width:166 },
                        { title: '学历照片',templet:setPicture, field: 'Thumbnail', align: 'center' },
                        { title: '状态', field: 'EackgroundStatus', align: 'center' },
                        { title: '操作', templet: setOperate, align: 'center' ,width:160}
                    ]],
                    page: true,
                });
                //重载数据表
                searchStudent();
            });
        });

       
        //1.2自定义操作列
        function setOperate(data) {
            //用户类型id
            var noticeId = data.AuthenticateEducationEackgroundID;
            if (data.EackgroundStatus == "审核中") {
                btns = '<button type="button" class="layui-btn layui-btn-xs" onclick=Notice(' + noticeId + ')>审核</button>';
            }
            else if (data.EackgroundStatus == "成功" || data.EackgroundStatus == "失败") {
                btns = '<button type="button" class="layui-btn layui-btn-normal layui-btn-xs" onclick=amend(' + noticeId + ')>修改</button>';
            }
                return btns;
        }
        //条件查询
        function searchStudent() {
            var searchText = $("#searchText").val();
            tabStudents.reload({
                url: "/authentication/RecordOFFormalSchooling/MaterialReviewInquire",
                where: {
                    searchText: searchText
                },
                page: {
                    curr: 1 //重新从第 1 页开始
                },
            });
        }
        //1.6打开修改模态框
        function amend(userid) {
            $("#modStudent").modal("show");
            $("#StuPicture").attr("src", "");//清除图片
            //重置表单
            $("#frmStuInfor")[0].reset()
            //1.1 公告数据回填
            $.post("/authentication/RecordOFFormalSchooling/MaterialReviewIDQuery?userid=" + userid, function (data) {
                if (data != null) {
                    $("#UserID1").val(data.UserID);
                    $("#UserName").val(data.UserName);
                    $("#AuthenticateEducationEackgroundID1").val(data.AuthenticateEducationEackgroundID);
                    $("#UserDetailID").val(data.UserDetailID);
                    $("#EackgroundSchool").val(data.EackgroundSchool);
                    $("#EackgroundSpecialty").val(data.EackgroundSpecialty);
                    $("#EnrollmentTime").val(data.Enrollment);//入学时间
                    $("#GraduationDate").val(data.Graduation);//毕业时间
                    $("#EackgroundStatus").val(data.EackgroundStatus);//状态
                    $("#DetailName").val(data.DetailName);//真实姓名
                    $("#EducationEackground").val(data.EducationEackground);//学历
                    $("#EackgroundRemark").val(data.EackgroundRemark);//备注
                    $("#StuPicture").attr("src", "/authentication/RecordOFFormalSchooling/picture?AuthenticateEducationEackgroundID=" + userid);
                }
            });
        };
        //1.7在表格中显示图片
        function setPicture(data) {
            var AuthenticateEducationEackgroundID = data.AuthenticateEducationEackgroundID;

            var img = "<img src='picture?AuthenticateEducationEackgroundID=" + AuthenticateEducationEackgroundID + "' alt='Alternate Text' style='width:100px;height:40px;'/>";
            return img;

        };
        /**************************修改保存图片***************************************/
        //保存修改
        function saveStudent() {
            //序列化表单元素
            var ExamineeInfor = $("#frmStuInfor").serializeArray();
            console.log(ExamineeInfor)
            //将数组转化为json对象
            var jsonExamineeInfor = {};
            //遍历数组中的每一条数据
            for (var i = 0; i < ExamineeInfor.length; i++) {
                jsonExamineeInfor[ExamineeInfor[i].name] = ExamineeInfor[i].value;
            }

            //数据验证,判断数据是否为空
            if (jsonExamineeInfor.AuthenticateEducationEackgroundID > 0 && jsonExamineeInfor.UserID > 0 && jsonExamineeInfor.UserName != "" && jsonExamineeInfor.EackgroundSchool != ""
                && jsonExamineeInfor.EackgroundSpecialty != "" && jsonExamineeInfor.EducationEackground != "" && jsonExamineeInfor.EackgroundStatus != ""
                && jsonExamineeInfor.DetailName != "" && jsonExamineeInfor.EnrollmentTime != "" && jsonExamineeInfor.GraduationDate != "" ) {

                //创建FormData对象(使用已有的表单初始化FormData对象)
                var fmExaminee = new FormData(document.getElementById("frmStuInfor"));
                var strUrl = "/authentication/RecordOFFormalSchooling/MaterialReviewUpdate";
                //加载层
                var index = layer.load();
                //发送请求
                $.ajax({
                    url: strUrl,
                    type: "post",
                    data: fmExaminee,
                    contentType: false,//让Ajax不指定数据类型
                    processData: false,//让Ajax不对数据进行处理
                    dataType: "json",
                    success: function (rtMsg) {
                        //关闭加载层
                        layer.close(index);
                        layer.alert(rtMsg.Text, { icon: 1, skin: 'layui-layer-molv' }, function () {
                            //点击确定按钮之后,如果是新增成功则关闭加载层,刷新页面
                            if (rtMsg.State) {
                                //关闭模态框
                                $("#modStudent").modal("hide");
                                //刷新页面
                                window.location.reload();
                            }
                        });
                    }
                });
            }
            else {
                layer.alert("考生信息不完整,请检查!", { icon: 0, skin: 'layui-layer-molv' });
            }
        }

        //双击图片框,弹出文件选择框
        function openFileInput() {
            //调用选择文件按钮的点击事件
            $("#fileImage").click();
        }

        //图片文件 正则表达式过滤image/jpeg,image/png,image/jpg,image/gif,image/bmp
        var regexImageFilter = /^(?:image\/jpg|image\/jpeg|image\/png|image\/gif|image\/bmp)$/i;

        //图片框显示图片,预览效果
        //文件读取器
        var imgReader = new FileReader();

        //获取读取的文件,在图片框显示
        imgReader.onload = function (event) {
            var strUrl = event.target.result;
            //页面预览图片
            $("#StuPicture").attr("src", strUrl);
        }

        //选择图片文件,触发文件选择表单的改变事件
        $("#fileImage").change(function () {
            //获取选择的文件
            var file = $(this).get(0).files[0];
            //判断文件类型
            if (regexImageFilter.test(file.type)) {
                //读取文件转换成URL
                imgReader.readAsDataURL(file);
            }
            else {
                layer.alert("请选择图片文件");
            }
        });
        /**********************************审核****************************************/
        //自定义按钮
        var EackgroundStatus = "";//状态
        function Notice(userid) {
            $("#formStudent1")[0].reset();
            $("#studentModal1").modal();
            $('input:radio[name="inlineRadioOptions"]').change(function () {
                if ($("#inlineRadio0").is(":checked")) {
                    EackgroundStatus = $("#inlineRadio0").val();
                }
                if ($("#inlineRadio1").is(":checked")) {
                    EackgroundStatus = $("#inlineRadio1").val();
                }
                if ($("#inlineRadio2").is(":checked")) {
                    EackgroundStatus = $("#inlineRadio2").val();
                }
                return EackgroundStatus;
            });
            $.post("/authentication/RecordOFFormalSchooling/MaterialReviewIDQuery", { userid: userid }, function (date) {
                $("#AuthenticateEducationEackgroundID").val(date.AuthenticateEducationEackgroundID);
                $("#UserID").val(date.UserID);
            });
        };

        //审核
        function saveStudentInfor() {
            var AuthenticateEducationEackgroundID = $('#AuthenticateEducationEackgroundID').val();//学历认证ID
            var ReviewRemarks = $('#Review').val();//审核备注
            var UserID = $('#UserID').val();//用户ID
            var validCode = $('#formStudent1 [name="validCode"]').val();//验证码

            if (IdentifyingCode != "") {
                var fd = new FormData();
                fd.append("AuthenticateEducationEackgroundID", AuthenticateEducationEackgroundID);
                fd.append("UserID", UserID);
                fd.append("validCode", validCode);
                fd.append("ReviewRemarks", ReviewRemarks);//审核备注
                fd.append("EackgroundStatus", EackgroundStatus);
                var xhr = new XMLHttpRequest();
                var layerIndex = layer.load();
                xhr.open("POST", "MaterialReviewReview");
                xhr.send(fd);
                xhr.onreadystatechange = function (jsonMsg) {
                    if (xhr.readyState == 4 && xhr.status == 200) {
                        var jsonMsg = JSON.parse(xhr.responseText);
                        layer.close(layerIndex);
                        layer.alert(jsonMsg.Text);
                        if (jsonMsg.State) {
                            searchStudent();//刷新表格
                            $("#studentModal1").modal("hide");
                            //清空验证码
                            $("#ValidateCode").val("");
                            //刷新验证码
                            //$("#ValidateCode").click();
                        }
                    }
                }
            } else {
                layer.alert("请填写完整", { icon: 0 });
            }
        }
    </script>
</body>
</html>

以上是HTML以及JavaScript的代码。

之后就是控制器中修改,保存以及审核的代码了,代码量比较多。

 /// <summary>
        /// 1.1 查询公告类型
        /// </summary>
        /// <returns></returns>
        public ActionResult SelectNoticeType()
        {
            var list = myModel.PW_AuthenticateEducationEackground.Select(m => new { id = m.AuthenticateEducationEackgroundID, text = m.EackgroundStatus }).ToList();
            return Json(list, JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 学历认证查询
        /// </summary>
        /// <param name="layuiTablePage"></param>
        /// <param name="searchText"></param>
        /// <returns></returns>
        public ActionResult MaterialReviewInquire(LayuiTablePage layuiTablePage, string searchText)
        {
            List<AuthenticatePhone> linqUserID = (from tbUser in myModel.PW_User
                                                  join tbAuthenticateEducationEackground in myModel.PW_AuthenticateEducationEackground on tbUser.UserID equals tbAuthenticateEducationEackground.UserID
                                                  join tbEducationEackground in myModel.SYS_EducationEackground on tbAuthenticateEducationEackground.EducationEackgroundID equals tbEducationEackground.EducationEackgroundID
                                                  join tbUserDetail in myModel.SYS_UserDetail on tbEducationEackground.EducationEackgroundID equals tbUserDetail.UserDetailID
                                                  select new AuthenticatePhone
                                                  {
                                                      UserID=tbUser.UserID,//用户ID
                                                      UserName=tbUser.UserName,//用户名
                                                      AuthenticateEducationEackgroundID = tbAuthenticateEducationEackground.AuthenticateEducationEackgroundID,//学历认证ID
                                                      EackgroundSchool= tbAuthenticateEducationEackground.EackgroundSchool,//学校
                                                      EackgroundSpecialty = tbAuthenticateEducationEackground.EackgroundSpecialty,//专业
                                                      EackgroundStatus = tbAuthenticateEducationEackground.EackgroundStatus,//状态
                                                      EackgroundRemark = tbAuthenticateEducationEackground.EackgroundRemark,//备注
                                                      Enrollment = tbAuthenticateEducationEackground.EnrollmentTime.ToString(),//入学时间
                                                      Graduation = tbAuthenticateEducationEackground.GraduationDate.ToString(),//毕业时间
                                                      DetailName = tbUserDetail.DetailName,//真实姓名
                                                      EducationEackground = tbEducationEackground.EducationEackground,//学历
                                                  }).ToList();

            //条件拼接
            if (!string.IsNullOrEmpty(searchText))
            {
                searchText = searchText.Trim();//去空格
                linqUserID = linqUserID.Where(o => o.UserName.Contains(searchText)
                || o.EackgroundStatus.Contains(searchText)).ToList();
            }
            //统计数据条数
            int dataCount = linqUserID.Count();

            //分页
            List<AuthenticatePhone> listUserID = linqUserID
                                         .OrderBy(m => m.UserID)
                                         .Skip(layuiTablePage.GetStartIndex())
                                         .Take(layuiTablePage.limit)
                                         .ToList();

            //创建对象,返回视图层
            LayuiTableData<AuthenticatePhone> layuiTableData = new LayuiTableData<AuthenticatePhone>
            {
                count = dataCount,
                data = listUserID
            };

            return Json(layuiTableData, JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 学历认证ID查询
        /// </summary>
        /// <param name="olent"></param>
        /// <returns></returns>
        public ActionResult MaterialReviewIDQuery(int userid)
        {

            try
            {
                AuthenticatePhone msg = (from tbUser in myModel.PW_User
                                         join tbAuthenticateEducationEackground in myModel.PW_AuthenticateEducationEackground on tbUser.UserID equals tbAuthenticateEducationEackground.UserID
                                         join tbEducationEackground in myModel.SYS_EducationEackground on tbAuthenticateEducationEackground.EducationEackgroundID equals tbEducationEackground.EducationEackgroundID
                                         join tbUserDetail in myModel.SYS_UserDetail on tbEducationEackground.EducationEackgroundID equals tbUserDetail.UserDetailID
                                         where tbAuthenticateEducationEackground.AuthenticateEducationEackgroundID==userid
                                         select new AuthenticatePhone
                                         {
                                             UserID = tbUser.UserID,//用户ID
                                             UserName = tbUser.UserName,//用户名
                                             UserDetailID = tbUserDetail.UserDetailID,//用户详细表ID
                                             ReviewRemarks = tbUser.ReviewRemarks,//审核备注
                                             AuthenticateEducationEackgroundID = tbAuthenticateEducationEackground.AuthenticateEducationEackgroundID,//学历认证ID
                                             EackgroundSchool = tbAuthenticateEducationEackground.EackgroundSchool,//学校
                                             EackgroundSpecialty = tbAuthenticateEducationEackground.EackgroundSpecialty,//专业
                                             EackgroundStatus = tbAuthenticateEducationEackground.EackgroundStatus,//状态
                                             EackgroundRemark = tbAuthenticateEducationEackground.EackgroundRemark,//备注
                                             Enrollment = tbAuthenticateEducationEackground.EnrollmentTime.ToString(),//入学时间
                                             Graduation = tbAuthenticateEducationEackground.GraduationDate.ToString(),//毕业时间
                                             DetailName = tbUserDetail.DetailName,//真实姓名
                                             EducationEackground = tbEducationEackground.EducationEackground,//学历
                                         }).Single();
                return Json(msg, JsonRequestBehavior.AllowGet);
            }
            catch (Exception)
            {
                return Json("数据异常");
            }
        }

        /// <summary>
        /// 根据材料ID查询图片信息
        /// </summary>
        /// <returns></returns>
        public ActionResult picture(int AuthenticateEducationEackgroundID)
        {
            try
            {
                var PaymentLogimg = (from tbAuthenticateEducationEackground in myModel.PW_AuthenticateEducationEackground

                                     where tbAuthenticateEducationEackground.AuthenticateEducationEackgroundID == AuthenticateEducationEackgroundID

                                     select new

                                     {

                                         tbAuthenticateEducationEackground.EducationBackground

                                     }).Single();

                byte[] stuImg = PaymentLogimg.EducationBackground;

                return File(stuImg, @"image/jpg");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);

                return Json("failed", JsonRequestBehavior.AllowGet);
            }
        }
        /// <summary>
        /// 审核
        /// </summary>
        /// <param name="VIP"></param>
        /// <returns></returns>
        public ActionResult MaterialReviewReview(PW_AuthenticateEducationEackground AuthenticateEducationEackground, PW_User user)
        {
            ReturnJson msg = new ReturnJson();
            try
            {
                var Borroing = myModel.PW_AuthenticateEducationEackground.Where(m => m.AuthenticateEducationEackgroundID == AuthenticateEducationEackground.AuthenticateEducationEackgroundID).Single();
                var User = myModel.PW_User.Where(m => m.UserID == user.UserID).Single();
                if (AuthenticateEducationEackground.EackgroundStatus == "成功")
                {
                    User.ReviewRemarks = user.ReviewRemarks;//审核备注
                    Borroing.EackgroundStatus = AuthenticateEducationEackground.EackgroundStatus;//状态
                    Borroing.EackgroundAuditTime = DateTime.Now;//审核时间
                }
                else if (AuthenticateEducationEackground.EackgroundStatus == "失败")
                {
                    Borroing.EackgroundAuditTime = DateTime.Now;//审核时间
                    User.ReviewRemarks = user.ReviewRemarks;//审核备注
                    Borroing.EackgroundStatus = AuthenticateEducationEackground.EackgroundStatus;
                }
                else if (AuthenticateEducationEackground.EackgroundStatus == "审核中")
                {
                    User.ReviewRemarks = user.ReviewRemarks;//审核备注
                    Borroing.EackgroundStatus = AuthenticateEducationEackground.EackgroundStatus;
                }
                myModel.Entry(Borroing).State = System.Data.Entity.EntityState.Modified;
                myModel.Entry(User).State = System.Data.Entity.EntityState.Modified;
                if (myModel.SaveChanges() > 0)
                {
                    msg.State = true;
                    msg.Text = "审核成功";
                }
                else
                {
                    msg.Text = "审核失败";
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                msg.Text = "数据异常";
            }
            return Json(msg, JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 修改保存
        /// </summary>
        /// <param name="AuthenticatePhome"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public ActionResult MaterialReviewUpdate(PW_AuthenticateEducationEackground AuthenticateEducationEackground, PW_User User,SYS_UserDetail UserDetail, HttpPostedFileBase imgFile,string EnrollmentTime)
        {
            ReturnJson msg = new ReturnJson();
            try
            {
                PW_AuthenticateEducationEackground AuthenticateEducation = (from tbAuthenticateEducationEackground in myModel.PW_AuthenticateEducationEackground
                                                                            where tbAuthenticateEducationEackground.AuthenticateEducationEackgroundID == AuthenticateEducationEackground.AuthenticateEducationEackgroundID
                                                                            select tbAuthenticateEducationEackground).Single();
                AuthenticateEducation.EackgroundSchool = AuthenticateEducationEackground.EackgroundSchool;//学校
                AuthenticateEducation.EackgroundSpecialty = AuthenticateEducationEackground.EackgroundSpecialty;//专业
                AuthenticateEducation.EnrollmentTime = AuthenticateEducationEackground.EnrollmentTime;//入学时间
                AuthenticateEducation.GraduationDate = AuthenticateEducationEackground.GraduationDate;//毕业时间
                AuthenticateEducation.EackgroundStatus = AuthenticateEducationEackground.EackgroundStatus;//状态
                AuthenticateEducation.EackgroundRemark = AuthenticateEducationEackground.EackgroundRemark;//备注
                //处理图片

                if (imgFile != null)
                {
                    //修改了图片
                    //创建二进制数组对象
                    byte[] byteFile = new byte[imgFile.ContentLength];
                    //将读取图片文件
                    imgFile.InputStream.Read(byteFile, 0, imgFile.ContentLength);
                    AuthenticateEducation.EducationBackground = byteFile;
                }
                else
                {
                    //未修改图片,查询原来的图片信息
                    AuthenticateEducation.EducationBackground = AuthenticateEducation.EducationBackground;
                }
                myModel.Entry(AuthenticateEducation).State = System.Data.Entity.EntityState.Modified;

                PW_User dbuser = (from tbUser in myModel.PW_User
                                  where tbUser.UserID == User.UserID
                                  select tbUser).Single();
                dbuser.UserName = User.UserName;
                dbuser.ReviewRemarks = User.ReviewRemarks;
                myModel.Entry(dbuser).State = System.Data.Entity.EntityState.Modified;
                SYS_UserDetail dbUserDetail = (from tbUserDetail in myModel.SYS_UserDetail
                                               where tbUserDetail.UserDetailID == UserDetail.UserDetailID
                                               select tbUserDetail).Single();
                dbUserDetail.DetailName = UserDetail.DetailName;
                myModel.Entry(dbUserDetail).State = System.Data.Entity.EntityState.Modified;
                myModel.SaveChanges();

                msg.State = true;
                msg.Text = "修改成功";
            }
            catch (Exception)
            {
                msg.Text = "数据异常";
            }
            return Json(msg, JsonRequestBehavior.AllowGet);
        }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值