Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function CreateMember() {
- ClearFaultsDialogs();
- var serviceUrl = "../ServicesECERT/OrderItemDetailService.svc/CreateItems";
- var orderHeaderId = 1; //$.trim($("#OrderHeaderID").val());
- var originCode = $.trim($("#dropdownOriginCode").val());
- var intendedUse = $.trim($("#dropdownIntendedUse").val());
- var storageCode = $.trim($("#dropdownStorageCode").val());
- var inspectionType = $.trim($("#dropdownInspectionType").val());
- var materialItemCode = $.trim($("#inputMaterialItemCode").val());
- var materialItemDesc = $.trim($("#inputMaterialItemDesc").val());
- var nZHSCCode = $.trim($("#inputNZHSCCode").val());
- var species = $.trim($("#inputSpecies").val());
- var eligibilityCountries = $.trim($("#inputEligibilityCountries").val());
- var startDate = $.trim($.format.date(new Date($("#inputStartDate").val()), "dd MMM yyyy HH:mm:ss sss"));
- var expiryDate = $.trim($.format.date(new Date($("#inputExpiryDate").val()), "dd MMM yyyy HH:mm:ss sss"));
- var containerNumber = $.trim($("#inputContainerNumber").val());
- var sealNumber = $.trim($("#inputSealNumber").val());
- var netWeight = $.trim($("#inputNetWeight").val());
- var netWeightUnitCode = $.trim($("#dropdownNetWeightUnitCode").val());
- var grossWeight = $.trim($("#inputGrossWeight").val());
- var grossWeightCode = $.trim($("#dropdownGrossWeightCode").val());
- var netVolume = $.trim($("#inputNetVolume").val());
- var netVolumeCode = $.trim($("#dropdownNetVolumeCode").val());
- var grossVolume = $.trim($("#inputGrossVolume").val());
- var grossVolumeCode = $.trim($("#dropdownGrossVolumeCode").val());
- var productionBatch = $.trim($("#inputProductionBatch").val());
- var comments = $.trim($("#inputComments").val());
- var createdBy = "<%= Page.User.Identity.Name %>";
- var createdDate = $.trim($.format.date(new Date(), "dd MMM yyyy HH:mm:ss sss"));
- var modifiedBy = "<%= Page.User.Identity.Name %>";
- var modifiedDate = $.trim($.format.date(new Date(), "dd MMM yyyy HH:mm:ss sss"));
- var isActive = true;
- var main = new Array();
- var data = '{"orderHeaderID": ' + orderHeaderId + ', "originCode":"' + originCode + '", "intendedUse":"' + intendedUse + '", "storageCode":"' + storageCode + '", "inspectionType":"' + inspectionType + '", "materialItemCode":"' + materialItemCode + '", "materialItemDesc":"' + materialItemDesc + '", "nZHSCCode":"' + nZHSCCode + '", "species":"' + species + '", "eligibilityCountries":"' + eligibilityCountries + '", "startDate":"' + startDate + '", "expiryDate":"' + expiryDate + '", "containerNumber":"' + containerNumber + '", "sealNumber":"' + sealNumber + '", "netWeight":"' + netWeight + '", "netWeightUnitCode":"' + netWeightUnitCode + '", "grossWeight":"' + grossWeight + '", "grossWeightCode":"' + grossWeightCode + '", "netVolume":"' + netVolume + '", "netVolumeCode":"' + netVolumeCode + '", "grossVolume":"' + grossVolume + '", "grossVolumeCode":"' + grossVolumeCode + '", "productionBatch":"' + productionBatch + '", "comments":"' + comments + '", "createdBy":"' + createdBy + '", "createdDate":"' + createdDate + '", "modifiedBy":"' + modifiedBy + '", "modifiedDate":"' + modifiedDate + '", "isActive":"' + isActive + '"}';
- var processingobject = new Array();
- for (var i = 0; i < $("#processingDetailstable > tbody > tr").length; i++) {
- var obj = new Object();
- obj.ProcessTypeCode = $.trim($("#dropdownProcessTypeCode" + i).val());
- obj.ProcessDateFrom = $.trim($("#inputProcessDateFrom" + i).val());
- obj.ProcessDateTo = $.trim($("#inputProcessDateTo" + i).val());
- obj.AppliedBy = $.trim($("#inputAppliedBy" + i).val());
- obj.ForeignPremisesCountry = $.trim($("#dropdownForeignPremisesCountry" + i).val());
- obj.AppliedOverseasBy = $.trim($("#inputAppliedOverseasBy" + i).val());
- obj.ForeignPremisesName = $.trim($("#inputForeignPremisesName" + i).val());
- if ($.trim($("#checkboxOverrides:checked").val()) == "on") {
- obj.Overrides = true;
- } else {
- obj.Overrides = false;
- }
- if ($.trim($("#checkboxOveridesNames:checked").val()) == "on") {
- obj.OveridesNames = true;
- } else {
- obj.OveridesNames = false;
- }
- alert(obj);
- processingobject.push(obj);
- }
- main.push(data);
- main.push(processingobject);
- // data.children.push(processingobject);
- alert(main);
- //how to post array of json objects
- //data: JSON.stringify(data,{OrderProcessingDetail:processingobject}),
- $.ajax({
- type: "POST",
- url: serviceUrl,
- // data: main,
- data: JSON.stringify({OrderItemDetail:main}),
- processdata: true,
- contentType: "application/json; charset=utf-8",
- dataType: "json",
- success: function (response) {
- var results = eval(JSON.parse(response.CreateResult));
- DisplayFaultsDialog(results.Faults);
- $('#dialog-form', window.parent.document).scrollTop(0);
- if (!FaultsContainErrors(results.Faults) && !FaultsContainValidationErrors(results.Faults)) {
- // Assign the id from the newly created item
- seletedId = results.data.OrderItemID
- // Slow the page with the new item
- sortItem = "OrderItemID";
- sortIDirection = "desc";
- currentIndex = 0;
- LoadData(currentPageIndex);
- var dialogSelector = "#dialog-form";
- $(dialogSelector).parent().find("button").each(function () {
- if ($(this).text() == 'Save') {
- $(this).attr('disabled', true);
- }
- });
- }
- },
- error: function (msg) {
- alert(msg);
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement