Advertisement
Guest User

CreateProj JS

a guest
Oct 19th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).on('ready', function () {
  2.     LoadProjStatus();
  3.     toggleEventForElement('#saveProj', "click", saveProject_click, true);
  4. });
  5.  
  6. //----- load ddl of status, project
  7.  
  8. function LoadProjStatus() {
  9.     PageMethods.getProjStatus(
  10.         function (data) {
  11.             if (data.length != 0) {
  12.                 $.each(data, function () {
  13.                     $('#ddlProjStatus').append('<option value="' + this.Code + '">' + this.Description + ' </option>');
  14.                 });
  15.             }
  16.         },
  17.         function (err) {
  18.             alert(err.get_message());
  19.         }
  20.     );
  21.     }
  22.  
  23. //----- submit Project /modal
  24.  
  25. function saveProject_click() {
  26.     bootbox.confirm('Are you sure you want to create this Project?', function (result) {
  27.         if (result == true) {
  28.             var refObj = new Object;
  29.             refObj = createProject();
  30.             PageMethods.saveProject(refObj,
  31.             function (data) {
  32.                 if (data.ProjectID != "") {
  33.                     var Description = document.getElementById("txtDesc").value;
  34.                     loadCreateProj(data.ProjectID, Description);
  35.                 }
  36.             });
  37.         }
  38.         else {
  39.             initializeAdditionalProject();
  40.         }
  41.     });
  42. }
  43.  
  44. //----- create Project Parameters
  45.  
  46. function createProject() {
  47.     var serviceParameters = new Object;
  48.     serviceParameters = new Object;
  49.     serviceParameters.ProjectName = $("#txtProjName").val();
  50.     serviceParameters.Description = $("#txtDesc").val();
  51.     serviceParameters.Status = $("#ddlProjStatus").val();
  52.     return serviceParameters;
  53. }
  54.  
  55. //----- initialize TextBox
  56.  
  57. function initializeAdditionalProject() {
  58.     document.getElementById("txtProjName").value = "";
  59.     document.getElementById("txtDesc").value = "";
  60.     setDropdownDefaultValue(document.getElementById("ddlProjStatus"), "Active");
  61. }
  62.  
  63. //----- spawn TestModule
  64.  
  65. function loadCreateProj(ProjectID, Description) {
  66.     sessionStorage.ProjectID = ProjectID;
  67.     sessionStorage.Description = Description;
  68.     window.location.replace("TestModuleCreate.aspx");
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement