public ActionResult GetReworkForm(VTReworkViewModel model, string buttontype) { if (ModelState.IsValid) { // Determine Which ID to use depending on the settings. string EmployeeID = ""; if (VT.Properties.Settings.Default.UsingBinaryBadgeID) { try { EmployeeID = helper.VTIDtoEMPID(model.EmployeeID); } catch { model.DisplayMessage = "Please Scan your VT ID"; return(View(model)); } } else { EmployeeID = model.EmployeeID; } if (buttontype == "Go") { ModelState.Clear(); model.Go = true; List <VTFormObject> list_HeaderForm = new List <VTFormObject>(); // [i] Title, [i+1] Token list_HeaderForm = logic.getAllHeaders(model.SerialNumber, EmployeeID); // Gets all headers if (list_HeaderForm[0].return_num == "0") { // Loop through all of the headers and add it to the model header list for (int i = 0; i < list_HeaderForm.Count; i++) { string headerToken = list_HeaderForm[i].HeaderToken; model.ListForms.Add(list_HeaderForm[i]); } } else { if (list_HeaderForm[0].return_num == "0") { model.DisplayMessage = "Submitted"; } else { model.DisplayMessage = helper.checkErrors(list_HeaderForm[0].return_num, list_HeaderForm[0].error_message); } } } else if (buttontype == "Rework") { model.Rework = true; model.ReworkListFields = logic.getFormInfo(model.SerialNumber, EmployeeID, model.SelectedHeaderToken); if (!(model.ReworkListFields[0].return_num == "0")) { if (model.ReworkListFields[0].return_num == "0") { model.DisplayMessage = "Submitted"; } else { model.DisplayMessage = helper.checkErrors(model.ReworkListFields[0].return_num, model.ReworkListFields[0].error_message); } } } else if (buttontype == "Update") { model.Update = true; string header = model.SelectedHeaderToken; List <string> submit_list = new List <string>(); for (int i = 0; i < model.ReworkListFields.Count; i++) { // Covers the case if it is a update TMS, to update with a "0" instead of the previous TMS. if (model.ReworkListFields[i].Token == "TMS") { model.ReworkListFields[i].Value = "0"; } // If it is a check box do the right conversion. if (model.ReworkListFields[i].DataType == "DATA-CKBOX") { string convertedValue = helper.boolToInt(model.ReworkListFields[i].BoolValue).ToString(); model.ReworkListFields[i].Value = convertedValue; } submit_list.Add(model.ReworkListFields[i].Token + model.ReworkListFields[i].Value); } string[] check = logic.helperSubmit(submit_list, 1, header); string error_number = check[0]; string error_message = check[1]; if (error_number == "0") { ModelState.Clear(); VTReworkViewModel clear_model = new VTReworkViewModel(); // Creates an empty model clear_model.DisplayMessage = "Updated"; clear_model.Success = helper.intToBoolZeroIsTrue(Convert.ToInt32(error_number)); return(View(clear_model)); } else { model.DisplayMessage = helper.checkErrors(error_number, error_message); // Sets the display message to the error. } } else if (buttontype == "Update") { ModelState.Clear(); VTReworkViewModel clear_model = new VTReworkViewModel(); // Creates an empty model //clear_model.DisplayMessage = "Updated"; return(View(clear_model)); } } return(View(model)); }
public ActionResult GetReworkForm() { var model = new VTReworkViewModel(); return(View(model)); }