YNICTE/BO/Views/croom/gradeupload.cshtml

147 lines
6.3 KiB
Plaintext

@model NP.Model.VMCRoom
@{
}
<form id="mform" method="post" enctype="multipart/form-data" class="form-horizontal">
<section class="panel panel-default" style="border-top: 1px solid #ddd; margin-top: 5px;">
<header class="panel-heading"><strong><i class="fa fa-bars"></i> 일괄등록 (시스템에 등록된 회원만 추가 가능합니다)<span class=""></span></strong></header>
<div class="panel-body">
<div class="form-group">
<label class="col-sm-4 col-md-2 control-label">성적 일괄등록</label>
<div class="col-sm-8 col-md-10">
<input id="uploadfile" type="file" /><br />
<a href="~/Content/file/gradeupload.xlsx" class="btn btn-info">양식다운로드</a>
<a href="#" class="btn btn-primary" onclick="checkfile();">파일검증</a>
</div>
</div>
<div class="text-right">
<a href="#" class="btn btn-danger" onclick="delall();">불량DATA 일괄삭제</a>
<a href="#" class="btn btn-primary" onclick="save();">등록</a>
</div>
</div>
<div class="table-responsive" id="excel2">
<table class="table table-striped b-t b-light">
<thead>
<tr>
<th width="20">No</th>
<th>주민등록번호</th>
<th>교육종료일</th>
<th>점수</th>
<th>교육생명</th>
<th>수강번호</th>
<th>강좌명</th>
<th>평가명</th>
<th>검증내역</th>
<th>삭제</th>
</tr>
</thead>
<tbody class="data" id="tbody"></tbody>
</table>
</div>
</section>
</form>
@section scriptsHeader{
<style type="text/css">
#layertable td {
padding: 2px 4px;
}
tbody th.cm {
padding: 0 10px;
}
tr.error {
color: red;
}
</style>
}
@section scripts{
<script src="~/js/moment.js"></script>
<script>
$(document).ready(function () {
$("#uploadfile").on("change", function () {
if ($(this).val() != "") {
$("#tbody tr").remove();
}
});
$("body").on("click", "#tbody tr td a.btn-danger", function () {
if (confirm("삭제하시겠습니까?")) {
$(this).closest("tr").remove();
}
});
});
function checkfile() {
if ($("#uploadfile").val() == "") {
msg2("파일을 선택해주세요.");
}
else {
var thumbext = $("#uploadfile").val();
thumbext = thumbext.slice(thumbext.indexOf(".") + 1).toLowerCase();
if ("xls,xlsx".indexOf(thumbext) < 0) {
msg("xls,xlsx 확장자만 가능합니다.", 0, true);
}
$("#tbody tr").remove();
var formData = new FormData();
formData.append("uploadfile", $("#uploadfile")[0].files[0]);
formData.append("uploadjob", "gradeuploadbatch");
capfile("/acommon/uploadexcel", formData, "cbcheckfile", true, false, true, true);
}
}
function cbcheckfile() {
if (capResult.code != 1000) {
msg2(capResult.msg);
}
else {
$.each(capResult.obj, function (i, d) {
$("#tbody").append("<tr data-userno=\"" + d.userno + "\" data-cmino=\"" + d.cmino + "\" data-lectno=\"" + d.lectno + "\" data-iscomplete=\"" + d.iscomplete + "\" data-cmno=\"" + d.cmno + "\" data-cname=\"" + d.cname + "\" data-exno=\"" + d.exno + "\" data-exname=\"" + d.exname + "\" data-tpoint=\"" + d.tpoint + "\" class=\"" + (d.value == "정상" ? "data" : "error") + "\">" +
"<td>" + d.rnorvt + "</td>" +
"<td>" + d.userpno + "</td>" +
"<td>" + moment(d.stime).format('YYYY-MM-DD') + "</td>" +
"<td>" + d.tpoint + "</td>" +
"<td>" + d.username + "</td>" +
"<td>" + zerotonull(d.lectno) + "</td>" +
"<td class=\"text-left\">" + d.cname + "</td>" +
"<td>" + d.exname + "</td>" +
"<td>" + d.value + "</td><td class=\"link text-center\"><a href=\"#\" class=\"btn-xxs btn btn-danger\">X</a></td></tr>");
});
}
}
function zerotonull(v) {
return v == 0 ? "" : v;
}
function delall() {
if (confirm("불량DATA를 일괄삭제하시겠습니까?")) {
$("#tbody tr.error").remove();
}
}
function save() {
if ($("#tbody tr.error").length > 0) {
msg("불량DATA가 있어 등록할 수 없습니다.");
}
else if ($("#tbody tr.data").length < 1) {
msg("등록할 데이터가 없습니다.");
}
else if (confirm("성적을 일괄 업로드하시겠습니까?")) {
var lectexs = [];
$.each($("#tbody tr.data"), function (i, r) {
lectexs.push($(r).data());
});
capp("/acommon/gradeuploadbatch", { lectexs: lectexs }, "cbsave");
}
}
function cbsave() {
if (capResult.code == 1000) {
if (capResult.obj > 0) {
msg("총 " + capResult.obj + "건 일괄 등록되었습니다.");
submit("mform", 500);
} else {
msg("일괄 등록된 건이 없습니다.");
submit("mform", 500);
}
} else if (capResult.code == 9999) {
msg(capResult.msg);
} else { msgdev(); }
}
</script>
}