function saveDefect() {
swal({
title: "Do you want to save it?",
text: "Please check Information before Submiting!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Save",
cancelButtonText: "Cancel",
closeOnConfirm: false,
closeOnCancel: false
}).then(
function (isConfirm) {
if (isConfirm) {
var defect = new Object();
defect.ProductDefectId = $("#defectId").val();
defect.CategoryId = $("#categoryId").val();
defect.Date = $("#date1").val();
defect.Product = $("#product").val();
defect.Qty = $("#quantity").val();
defect.Price = $("#price").val();
defect.Total = $("#total_1").val();
defect.Remarks = $("#remark").val();
var data = JSON.stringify({
defect: defect
});
}
});
return $.ajax({
contentType: 'application/json; charset=ut-8',
dataType: 'json',
type: 'POST',
url: "/Home/SaveDefect",
data: data,
success: function (result) {
if (result == true) {
GetAllDefectProduct();
swal("1 Defective Product Save Successfully")
}
else {
swal("Cancelled", "You have Cancelled Form Submission!", "error");
}
}
});
}
function GetAllCategory()
{
$.ajax({
contentType: "application/json; charset=ut-8",
datatype: "json",
type: "Get",
url: "/Home/GetAllCategory",
success: function (data) {
$("#categoryId").html('');
var tdContent = '';
for (var i = 0; i < data.length; i++) {
tdContent += '<option value="' + data[i].CategoryId + '"> ' + data[i].CategoryName + '</option>';
}
$("#categoryId").append(tdContent);
},
error: function () {
alert("Error!")
}
})
}