update tương ứng với db mới

This commit is contained in:
2020-12-09 17:13:48 +07:00
parent 24e3347d43
commit 75073b956d
8 changed files with 70 additions and 9 deletions

View File

@@ -18,6 +18,11 @@ function _close() {
}
function _save(e) {
var code = $("input[name='Code']").val();
if (code === "") {
alert("Hãy nhập mã đối tượng!");
return;
}
var name = $("input[name='Name']").val();
if (name === "") {
alert("Hãy nhập tên!");
@@ -28,6 +33,7 @@ function _save(e) {
url: $(e).attr("data-href"),
type: 'POST',
data: {
code: code,
name: name,
type: $("select[name='Type']").val(),
gender: $("select[name='Gender']").val(),

View File

@@ -60,6 +60,7 @@ function _formModified(e) {
success: function (data) {
common.modalBlock(false);
$("select[name='Type']").val(data.type);
$("input[name='Code']").val(data.code);
$("input[name='Name']").val(data.name);
$("select[name='Gender']").val(data.gender);
$("input[name='Birthday']").val(data.birthday);
@@ -77,6 +78,11 @@ function _formModified(e) {
}
function _update(e) {
var code = $("input[name='Code']").val();
if (code === "") {
alert("Hãy nhập mã đối tượng!");
return;
}
var name = $("input[name='Name']").val();
if (name === "") {
alert("Hãy nhập tên!");
@@ -87,6 +93,7 @@ function _update(e) {
url: $(e).attr("data-href"),
type: 'POST',
data: {
code: code,
name: name,
type: $("select[name='Type']").val(),
gender: $("select[name='Gender']").val(),
@@ -97,8 +104,12 @@ function _update(e) {
image: $("input[name='AnhNhanVienUrl']").val()
},
success: function (data) {
alert("Cập nhật dữ liệu thành công!");
window.location.reload(true);
common.modalBlock(false);
if (data) {
alert("Cập nhật dữ liệu thành công!");
window.location.reload(true);
} else
alert("Mã đối tượng đã tồn tại!");
},
error: function (jqXHR, textStatus, errorThrown) {
common.modalBlock(false);
@@ -225,6 +236,11 @@ function btnImage() {
}
function _create(e) {
var code = $("input[name='Code']").val();
if (code === "") {
alert("Hãy nhập mã đối tượng!");
return;
}
var name = $("input[name='Name']").val();
if (name === "") {
alert("Hãy nhập tên!");
@@ -240,6 +256,7 @@ function _create(e) {
url: $(e).attr("data-href"),
type: 'POST',
data: {
code: code,
name: name,
type: $("select[name='Type']").val(),
gender: $("select[name='Gender']").val(),
@@ -249,8 +266,12 @@ function _create(e) {
image: image
},
success: function (data) {
alert("Cập nhật dữ liệu thành công!");
window.location.reload(true);
common.modalBlock(false);
if (data.status) {
alert("Cập nhật dữ liệu thành công!");
window.location.reload(true);
} else
alert("Mã đối tượng đã tồn tại!");
},
error: function (jqXHR, textStatus, errorThrown) {
common.modalBlock(false);