Java to tabel SQL Server (DELETE)
HTML :
JavaScript :
Controller APP :
Controller API :
Svc :
Stored Procedure :
<a class="btn btn-link btn-sm demo3" style="padding: 0;margin: 0;" href="#" onclick="btnDeleteMstFormatDetail('${performance.format_id}','${performance.indicator_id}','${performance.aspect}')" id="tdDeleteMstFormat"><i class="fa fa-trash" title="Delete"></i></a>
JavaScript :
function btnDeleteMstFormatDetail(formatid, indicatorid, aspect) {
swal({
title: "Anda Yakin?",
text: "Anda akan menghapus semua data!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Ya!",
closeOnConfirm: false
},
function (isConfirm) {
if (isConfirm)
{
swal("Terhapus!", "", "success");
loadHome('/bukihcisapp/web/performance/delete-mstformatheaderdetail'
+ "?formatid=" + formatid
+ "&aspect=" + aspect
+ "&indicatorid=" + indicatorid
+ "&ranNum=${ranNum}&u=${u}&moduleId=${moduleId}"
+ "&userId=" + $("#txtUserId").val()
+ "&userBranch=" + $("#txtUserBranch").val()
);
} else {
}
});
}
swal({
title: "Anda Yakin?",
text: "Anda akan menghapus semua data!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Ya!",
closeOnConfirm: false
},
function (isConfirm) {
if (isConfirm)
{
swal("Terhapus!", "", "success");
loadHome('/bukihcisapp/web/performance/delete-mstformatheaderdetail'
+ "?formatid=" + formatid
+ "&aspect=" + aspect
+ "&indicatorid=" + indicatorid
+ "&ranNum=${ranNum}&u=${u}&moduleId=${moduleId}"
+ "&userId=" + $("#txtUserId").val()
+ "&userBranch=" + $("#txtUserBranch").val()
);
} else {
}
});
}
Controller APP :
@RequestMapping(value = "/delete-mstformatheaderdetail", method = RequestMethod.GET)
private RedirectView deletePerformanceMstFormatDetail(HttpServletRequest request, HttpServletResponse response,
@RequestParam(value = "ranNum", required = false) String ranNum,
@RequestParam(value = "u", required = false) String uName,
@RequestParam(value = "moduleId", required = false) String moduleId) throws ParseException, UnsupportedEncodingException {
RestTemplate restTemplate = new RestTemplate();
ranNumber = ranNum == null ? ranNumber : ranNum;
HttpSession currentSession = request.getSession(false) == null ? request.getSession() : request.getSession(false);
String userId = request.getParameter("userId");
String formatid = request.getParameter("formatid");
String indicatorid = request.getParameter("indicatorid");
String aspect = request.getParameter("aspect");
restTemplate.getForObject(getURLBaseFromTxt_API(currentSession) + "/performance/delete-mstformatheaderdetail?formatid=" + formatid + "&formatid=" + formatid + "&indicatorid=" + indicatorid, GenericDataGrid.class);
return new RedirectView("/bukihcisapp/web/performance/grid-mstformatheaderdetail?ranNum=" + ranNumber + "&u=" + uName + "&userId=" + userId + "&moduleId=" + moduleId + "&formatid=" + formatid + "&aspect=" + aspect);
}
private RedirectView deletePerformanceMstFormatDetail(HttpServletRequest request, HttpServletResponse response,
@RequestParam(value = "ranNum", required = false) String ranNum,
@RequestParam(value = "u", required = false) String uName,
@RequestParam(value = "moduleId", required = false) String moduleId) throws ParseException, UnsupportedEncodingException {
RestTemplate restTemplate = new RestTemplate();
ranNumber = ranNum == null ? ranNumber : ranNum;
HttpSession currentSession = request.getSession(false) == null ? request.getSession() : request.getSession(false);
String userId = request.getParameter("userId");
String formatid = request.getParameter("formatid");
String indicatorid = request.getParameter("indicatorid");
String aspect = request.getParameter("aspect");
restTemplate.getForObject(getURLBaseFromTxt_API(currentSession) + "/performance/delete-mstformatheaderdetail?formatid=" + formatid + "&formatid=" + formatid + "&indicatorid=" + indicatorid, GenericDataGrid.class);
return new RedirectView("/bukihcisapp/web/performance/grid-mstformatheaderdetail?ranNum=" + ranNumber + "&u=" + uName + "&userId=" + userId + "&moduleId=" + moduleId + "&formatid=" + formatid + "&aspect=" + aspect);
}
Controller API :
@RequestMapping(value = {"/delete-mstformatheaderdetail"}, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Object> deletePerformanceMstFormatDetail(HttpServletRequest request) throws UnsupportedEncodingException {
LinkedHashMap<String, String> mappedParam = new LinkedHashMap<>();
String formatid = request.getParameter("formatid");
String indicatorid = request.getParameter("indicatorid");
mappedParam.put("formatId", (formatid));
mappedParam.put("indicatorId", (indicatorid));
try {
performanceSvc.deletePerformanceMstFormatDetail(mappedParam);
} catch (SQLException e) {
System.out.println(e.getMessage());
}
return new ResponseEntity(HttpStatus.OK);
}
public ResponseEntity<Object> deletePerformanceMstFormatDetail(HttpServletRequest request) throws UnsupportedEncodingException {
LinkedHashMap<String, String> mappedParam = new LinkedHashMap<>();
String formatid = request.getParameter("formatid");
String indicatorid = request.getParameter("indicatorid");
mappedParam.put("formatId", (formatid));
mappedParam.put("indicatorId", (indicatorid));
try {
performanceSvc.deletePerformanceMstFormatDetail(mappedParam);
} catch (SQLException e) {
System.out.println(e.getMessage());
}
return new ResponseEntity(HttpStatus.OK);
}
Svc :
public Object deletePerformanceMstFormatDetail(LinkedHashMap paramMapped) throws SQLException {
String storedProcName = "spperformance_mst_format_detail_delete";
return genericDao.getData(storedProcName, paramMapped);
}
String storedProcName = "spperformance_mst_format_detail_delete";
return genericDao.getData(storedProcName, paramMapped);
}
Stored Procedure :
SET QUOTED_IDENTIFIER ON
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo].[spperformance_mst_format_detail_delete]
@formatId INT,
@indicatorId INT
AS
SET NOCOUNT ON
DELETE dbo.performance_mst_format_detail WHERE format_id = @formatId AND indicator_id = @indicatorId
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo].[spperformance_mst_format_detail_delete]
@formatId INT,
@indicatorId INT
AS
SET NOCOUNT ON
DELETE dbo.performance_mst_format_detail WHERE format_id = @formatId AND indicator_id = @indicatorId
GO
Comments
Post a Comment