TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Chandan Dubey
NA
17
2.8k
how i insert into database using jquery when drag and drop
Oct 17 2017 6:24 AM
here is the code that is already implemented on another place ,i want to implement in new place how could i do.
CS code
[WebMethod]
public static void SaveKeyItems(Guid reportId, List<Guid> keyProductIds)
{
ServiceInfo s = new ServiceInfo(ApplicationState.ServiceTransportSecurityMode, ApplicationState.ServiceBindingType, ApplicationState.ServiceUserName, ApplicationState.ServicePassword, ApplicationState.ServiceDomain, ApplicationState.GetServiceEndPointAddress("CustomizedReportKeyProductServiceEndPointAddress"));
ICustomizedReportKeyProductService keyProductService = CustomizedReportKeyProduct.GetService(s);
DataTable predicateDataTable = CustomizedReportKeyProduct.GetPredicateDataTable(keyProductService, " AND customized_report_id = '" + reportId + "'");
if (predicateDataTable.Rows.Count > 0)
{
List<CustomizedReportKeyProductInfo> keyProductInfos = CustomizedReportKeyProduct.GetObjectListFromDataTable(predicateDataTable);
foreach (CustomizedReportKeyProductInfo keyProductInfo in keyProductInfos)
CustomizedReportKeyProduct.DeleteCustomizedReportKeyProduct(keyProductService, keyProductInfo);
}
foreach (Guid keyProductId in keyProductIds)
{
CustomizedReportKeyProductInfo keyProductInfo = new CustomizedReportKeyProductInfo();
keyProductInfo.CustomizedReportId = reportId;
keyProductInfo.ProductId = keyProductId;
keyProductInfo.Created = DateTime.Now;
keyProductInfo.CreatedBy = LarvolSecurityManager.Instance.LoggedUser.UserID;
keyProductInfo.Modified = DateTime.Now;
keyProductInfo.ModifiedBy = LarvolSecurityManager.Instance.LoggedUser.UserID;
keyProductInfo.IsActive = true;
CustomizedReportKeyProduct.CreateCustomizedReportKeyProduct(keyProductService, keyProductInfo);
}
}
aspx code
$("#key-products .droppable-area").droppable({
activeClass: "ui-state-default",
hoverClass: "ui-state-hover",
accept: ":not(.ui-sortable-helper)",
drop: function (event, ui) {
var olItemList = $(this).parent().find("ol");
if ($(olItemList).find("li[productid='" + ui.draggable.attr("productid") + "']").length == 0) {
mask(function () { saveItem('keyProductId', ui.draggable.attr("productid"), baseUrl + "Reporting/ReportBuilder/Builder.aspx/SaveKeyProduct", false); }, 0);
}
location.reload(true);
}
});
loadExcludedItems();
loadKeyProducts();
});
function saveItem(paramenterName, paramenterValue, webServiceUrl, reloadTree) {
var jsonString = "{ reportId: '" + reportId + "', " + paramenterName + ": '" + paramenterValue + "'}";
ajaxPost(webServiceUrl, jsonString, function () { if (reloadTree) loadTree(currentOpenSectionId); });
}
function saveItemList(listId, jsonParamenterName, webServiceUrl) {
var parentDiv = $("#" + listId);
var successHandler = function () { updateProductItemList(true, $("#" + listId + " h1")); loadTree(); };
var exludedProductArray = "[";
if ($("li[productid]:visible", parentDiv).length > 0) {
$("li[productid]:visible", parentDiv).each(function (index) { exludedProductArray += "'" + $(this).attr("productid") + "',"; });
exludedProductArray = exludedProductArray.substring(0, exludedProductArray.length - 1);
}
exludedProductArray += "]";
var jsonString = "{ reportId: '" + reportId + "', " + jsonParamenterName + ": " + exludedProductArray + "}";
ajaxPost(webServiceUrl, jsonString, successHandler);
}
function loadExcludedItems() {
debugger;
loadListItems("excluded-products", "GetExcludedProducts", "excluded-product-list-item-remove");
}
function loadKeyProducts() {
loadListItems("key-products", "GetKeyProducts", "key-product-list-item-remove");
}
function loadListItems(listId, webServiceMethodName, itemClassName) {
var successhandler = function (exludedProducts) {
if (exludedProducts.length > 0) {
var olExludedProducts = $("#" + listId + " ol");
$(olExludedProducts).find(".placeholder").hide();
for (var i = 0; i < exludedProducts.length; i++) {
//var innerlst = '<table style="margin-top:-17px;"><tbody><tr><td style="width:90%;">' + exludedProducts[i].Item2 + '</td><td><span class="ui-icon ui-icon-trash product-list-item-remove">Delete item</span></td></tr></tbody></table>'
$('<li style="position:relative;"></li>').html('<div style="width: 90%; margin-bottom: 4px;">' + exludedProducts[i].Item2 + '</div>' + '<span class="ui-icon ui-icon-trash ' + itemClassName + ' trash-icon-location">Delete item</span>')
.attr("productid", exludedProducts[i].Item1)
.appendTo(olExludedProducts);
}
}
};
ajaxPost(baseUrl + "Reporting/ReportBuilder/Builder.aspx/" + webServiceMethodName, "{ reportId: '" + reportId + "'}", successhandler);
}
Reply
Answers (
1
)
Trigger for DELETE
Is change in view affect the DB