public ActionResult BatchForm(VTBatchModel 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") { // Add the choices in the select down model.ListBatchFields = logic.getBatchInfo(model.SerialNumber); // There was an error if (model.ListBatchFields[0].return_num != "0") { model.DisplayMessage = model.ListBatchFields[0].error_message; return(View(model)); } for (int i = 0; i < model.ListBatchFields.Count; i++) { BatchOption option = new BatchOption(); option.Text = model.ListBatchFields[i].Label; option.Value = model.ListBatchFields[i].Token; model.Options.Add(option); } if (model.BatchAmount != 0) { model.ListFields = logic.getFormInfo(model.SerialNumber, model.EmployeeID, model.SelectedItem); // It is only going to fill the first element // There was an error if (model.ListFields[0].return_num != "0") { model.DisplayMessage = model.ListFields[0].error_message; return(View(model)); } // Add the first serial number scanned to the batch list model.SerialNumbers.Add(model.SerialNumber); for (int i = 0; i < model.BatchAmount - 1; i++) { model.SerialNumbers.Add(""); } model.GoBatch = true; } model.Go = true; } else if (buttontype == "Submit") { string[] check; List <String> submit_list = new List <String>(); // Fills in the hidden values. for (int i = 0; i < model.ListFields.Count; i++) { if (model.ListFields[i].isHidden) { if (model.ListFields[i].Token == "SNT" || model.ListFields[i].Token == "SNC") { string serial_numbers = model.SerialNumber; // Add all of the remaining serial numbers for (int j = 0; j < model.SerialNumbers.Count; j++) { serial_numbers += "," + model.SerialNumbers[j]; } // Remove the extra comma at the end model.ListFields[i].Value = serial_numbers; } else if (model.ListFields[i].Token == "USR") { model.ListFields[i].Value = EmployeeID; } else if (model.ListFields[i].Token == "TMS") { model.ListFields[i].Value = "0"; } } if (model.ListFields[i].DataType == "DATA-PIN") { model.ListFields[i].Value = model.PIN; } submit_list.Add(model.ListFields[i].Token + model.ListFields[i].Value); } check = logic.helperSubmit(submit_list, 4, model.SelectedItem); string error_number = check[0]; string error_message = check[1]; if (error_number == "0") { ModelState.Clear(); VTBatchModel clear_model = new VTBatchModel(); // Creates an empty model clear_model.Success = true; clear_model.DisplayMessage = "Submitted\n"; for (int i = 0; i < model.SerialNumbers.Count; i++) { clear_model.DisplayMessage += model.SerialNumbers[i] + ","; } clear_model.DisplayMessage += "\n" + DateTime.Now; clear_model.DisplaySerialError = error_message; return(View(clear_model)); } else { model.DisplayMessage = helper.checkErrors(error_number, error_message); // Sets the display message to the error. } } } return(View(model)); }
public ActionResult BatchForm() { VTBatchModel model = new VTBatchModel(); return(View(model)); }