public void FormDetail() { using (var ctrl = new FormDetail(dataTable, null, null, true, false, 0)) { ctrl.Show(); ctrl.Close(); } }
public ActionResult Submit(FormModel model) { var ExistingForm = db.Forms.FirstOrDefault(x => x.FormId == model.FormId); if (ExistingForm != null) { ExistingForm.FormName = model.FormName; ExistingForm.FormDescription = model.FormDescription; ExistingForm.UserId = Convert.ToInt32(Session["UserID"].ToString()); foreach (var fields in ExistingForm.FormDetails.ToList()) { db.FormDetails.Remove(fields); } foreach (var fields in model.formField) { FormDetail formdetails = new FormDetail(); formdetails.FormId = model.FormId; formdetails.Id = fields.Id; formdetails.FieldType = fields.FieldType; formdetails.FieldName = fields.FieldName; formdetails.Isrequired = fields.IsRequired; formdetails.Sortindex = fields.SortIndex; formdetails.Icons = fields.Icons; formdetails.Class = fields.Class; ExistingForm.FormDetails.Add(formdetails); } db.SaveChanges(); return(Json(new { IsSuccess = true, Message = "Your " + @model.FormName + " Form is successfully Saved" })); } else { Form userform = new Form(); userform.FormName = model.FormName; userform.FormDescription = model.FormDescription; userform.FormId = model.FormId; userform.UserId = Convert.ToInt32(Session["UserID"].ToString()); db.Forms.Add(userform); db.SaveChanges(); FormDetail formdetails = new FormDetail(); foreach (var fields in model.formField) { formdetails.FormId = userform.FormId; formdetails.Id = fields.Id; formdetails.FieldType = fields.FieldType; formdetails.FieldName = fields.FieldName; formdetails.Isrequired = fields.IsRequired; formdetails.Sortindex = fields.SortIndex; formdetails.Icons = fields.Icons; formdetails.Class = fields.Class; db.FormDetails.Add(formdetails); db.SaveChanges(); } } return(Json(new { IsSuccess = true, Message = "Your " + @model.FormName + " Form is successfully Saved" })); }
public ActionResult Upload(IFormFile excelFile, string source, string content, string medium, int name , int email, int phone, int skipLine) { utm_source = source; utm_content = content; utm_medium = medium; if (excelFile == null || excelFile.Length == 0) { return(RedirectToAction("Index")); } else { if (excelFile.FileName.EndsWith("csv")) { var path = Path.Combine($"{_wwwroot}/{folderName}", excelFile.FileName); using (var stream = new FileStream(path, FileMode.Create)) { excelFile.CopyTo(stream); } string[] allLines = System.IO.File.ReadAllLines(path); var query = from line in allLines.Skip(skipLine) let data = line.Split(',') select new { Name = data[name], Email = data[email], Phone = data[phone], }; foreach (var item in query) { FormDetail studentCandidate = new FormDetail { Fullname = item.Name, Email = item.Email, AreaCode = item.Phone.Substring(0, 3), PhoneNumber = item.Phone.Substring(3) }; model.FormDetails.Add(studentCandidate); } System.IO.File.Delete(path); return(View("Index", model)); } else { return(RedirectToAction("Index")); } } }
public ActionResult Upload(IFormFile excelFile) { if (excelFile == null || excelFile.Length == 0) { return(RedirectToAction("Index")); } else { if (excelFile.FileName.EndsWith("xlsx")) { var path = Path.Combine($"{_wwwroot}/{folderName}", excelFile.FileName); using (var stream = new FileStream(path, FileMode.Create)) { excelFile.CopyTo(stream); } System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); using (var stream = System.IO.File.Open(path, FileMode.Open, FileAccess.Read)) { using (var excelRead = ExcelReaderFactory.CreateReader(stream)) { do { while (excelRead.Read()) { var studentCandidates = new FormDetail { Fullname = excelRead.GetString(13), Email = excelRead.GetString(12), AreaCode = excelRead.GetString(14).Substring(2, 4), PhoneNumber = excelRead.GetString(14).Substring(2) }; model.FormDetails.Add(studentCandidates); } } while (excelRead.NextResult()); } } System.IO.File.Delete(path); model.FormDetails.RemoveAt(0); return(View("Index", model)); } else { return(RedirectToAction("Index")); } } }
public GenDocFormVO(string workstatId, string formNam, string storId) { this.formDetails = new List <FormDetail>(1); this.ipPortDetails = new List <IPPortDetails>(1); this.workstationMappings = new List <WorkstationPeripheralMapping>(1); this.computedHashTable = new Hashtable(30); this.foundWorkstation = null; this.foundPeripheral = null; this.foundForm = null; this.workstationId = workstatId; this.formName = formNam; this.storeId = storId; }
public IActionResult DeleteFd(int ID) { // - Find AccCode in Client-subform details ---------- // FormDetail deleteRecord = repository.DeleteFormDetail(ID); if (deleteRecord != null) { TempData["message"] = $"The row {deleteRecord.AccCode} has been deleted!"; } return(RedirectToAction("FormDetails")); }
public IActionResult EditFd(FormDetail formDetail) { if (ModelState.IsValid) { var frmId = formDetail.FormId; repository.SaveFormDetail(formDetail); TempData["message"] = $"The row of {formDetail.AccCode} has been saved!"; var frmDetails = repository.FormDetails.Where(r => r.FormId == frmId).ToList(); return(View("FormDetails", frmDetails)); } else { return(View(formDetail)); } }
public IActionResult DeleteForm(int ID) { FormDetail frmd = repository.FormDetails.FirstOrDefault(f => f.FormId == ID); if (frmd != null) { TempData["error"] = "This Form has Subform Details, you cannot delete it."; } else { Form deleteRecord = repository.DeleteForm(ID); if (deleteRecord != null) { TempData["message"] = $" Form {deleteRecord.FormCode} has been deleted!"; } } return(RedirectToAction("Forms")); }
public bool GetDataAndCompute( DataTable formTable, DataTable wkstMapTable, DataTable ipPortTable) { if (string.IsNullOrEmpty(workstationId) || string.IsNullOrEmpty(formName) || string.IsNullOrEmpty(storeId)) { return(false); } try { if (formTable == null || wkstMapTable == null || ipPortTable == null || formTable.HasErrors || wkstMapTable.HasErrors || ipPortTable.HasErrors || formTable.Rows == null || wkstMapTable.Rows == null || ipPortTable.Rows == null || formTable.Rows.Count <= 0 || wkstMapTable.Rows.Count <= 0 || ipPortTable.Rows.Count <= 0) { return(false); } //Clear computed hash table this.computedHashTable.Clear(); this.formDetails.Clear(); this.workstationMappings.Clear(); this.ipPortDetails.Clear(); //Find form foreach (DataRow r in formTable.Rows) { if (r == null) { continue; } string fmName = Utilities.GetStringValue(r["form"], string.Empty); if (!string.IsNullOrEmpty(fmName) && fmName.Equals(this.formName, StringComparison.OrdinalIgnoreCase)) { var fmDetail = new FormDetail(); fmDetail.AddendumNeeded = Utilities.GetStringValue(r["addendum_needed"], string.Empty); fmDetail.Category = Utilities.GetStringValue(r["category"], string.Empty); fmDetail.CountryCode = Utilities.GetStringValue(r["country_code"], string.Empty); fmDetail.CreatedBy = Utilities.GetStringValue(r["createdby"], string.Empty); fmDetail.EffectiveDate = Utilities.GetStringValue(r["effective_date"], string.Empty); fmDetail.TemplateFileName = Utilities.GetStringValue(r["form"], string.Empty); fmDetail.NumberCopies = Utilities.GetStringValue(r["copies"], string.Empty); fmDetail.FormLocation = Utilities.GetStringValue(r["form_location"], string.Empty); //Add form to list this.formDetails.Add(fmDetail); break; } } //If form details were not found, exit if (CollectionUtilities.isEmpty(this.formDetails)) { return(false); } //Get form detail object FormDetail fmObj = this.formDetails.First(); //Ensure that form location is valid if (fmObj == null || string.IsNullOrEmpty(fmObj.FormLocation)) { return(false); } //Find peripherals matching form location from form details above foreach (DataRow r in ipPortTable.Rows) { if (r == null) { continue; } var ipDetail = new IPPortDetails(); ipDetail.IPAddress = Utilities.GetStringValue(r["ipaddress"], string.Empty); ipDetail.PortNumber = Utilities.GetStringValue(r["portnumber"], string.Empty); ipDetail.ModelId = Utilities.GetStringValue(r["modelid"], string.Empty); ipDetail.PeripheralId = Utilities.GetStringValue(r["peripheralid"], string.Empty); ipDetail.PeripheralName = Utilities.GetStringValue(r["peripheralname"], string.Empty); ipDetail.PeripheralTypeId = Utilities.GetStringValue(r["peripheraltypeid"], string.Empty); ipDetail.StoreId = Utilities.GetStringValue(r["storeid"], string.Empty); //Match the type of the peripheral with the form location - the form's required peripheral type id if (!string.IsNullOrEmpty(ipDetail.PeripheralTypeId) && !string.IsNullOrEmpty(ipDetail.StoreId) && ipDetail.PeripheralTypeId.Equals(fmObj.FormLocation, StringComparison.OrdinalIgnoreCase) && ipDetail.StoreId.Equals(this.storeId, StringComparison.OrdinalIgnoreCase)) { this.ipPortDetails.Add(ipDetail); } } //Ensure that at least one peripheral was found if (CollectionUtilities.isEmpty(this.ipPortDetails)) { return(false); } //Find workstation peripheral mappings foreach (DataRow r in wkstMapTable.Rows) { if (r == null) { continue; } var wkstDetail = new WorkstationPeripheralMapping(); wkstDetail.WorkstationId = Utilities.GetStringValue(r["workstationid"], string.Empty); wkstDetail.PeripheralId = Utilities.GetStringValue(r["peripheralid"], string.Empty); //Add the workstation mapping if (!string.IsNullOrEmpty(wkstDetail.WorkstationId) && !string.IsNullOrEmpty(wkstDetail.PeripheralId)) { this.workstationMappings.Add(wkstDetail); } } //Ensure that at least one workstation mapping was found if (CollectionUtilities.isEmpty(this.workstationMappings)) { return(false); } //Find the peripheral to workstation mapping relationship foreach (var wkst in this.workstationMappings) { if (wkst == null) { continue; } var wkstPerId = wkst.PeripheralId; var ipPortObjFnd = this.ipPortDetails.Find( x => x.PeripheralId.Equals(wkstPerId, StringComparison.OrdinalIgnoreCase)); if (ipPortObjFnd != null) { this.foundPeripheral = ipPortObjFnd; this.foundForm = fmObj; this.foundWorkstation = wkst; break; } } //Generate found form hash details if (this.foundForm != null) { this.computedHashTable["##TEMPLATEFILENAME##"] = this.foundForm.TemplateFileName; this.computedHashTable["##HOWMANYCOPIES##"] = this.foundForm.NumberCopies; } //Generate output hash map if (this.foundPeripheral != null && this.foundForm != null && this.foundWorkstation != null) { this.computedHashTable["##IPADDRESS00##"] = this.foundPeripheral.IPAddress; this.computedHashTable["##IPADDRESS01##"] = this.foundPeripheral.IPAddress; this.computedHashTable["##PORTNUMBER00##"] = this.foundPeripheral.PortNumber; this.computedHashTable["##PORTNUMBER01##"] = this.foundPeripheral.PortNumber; } else { //As a backup, if there are no workstation specific mappings, //try to choose a peripheral that matches the type specified //by the form if (CollectionUtilities.isNotEmpty(this.ipPortDetails)) { var fndPrinter = this.ipPortDetails.Find( x => x.PeripheralTypeId.Equals( fmObj.FormLocation, StringComparison.OrdinalIgnoreCase)); if (fndPrinter != null) { this.computedHashTable["##IPADDRESS00##"] = fndPrinter.IPAddress; this.computedHashTable["##IPADDRESS01##"] = fndPrinter.IPAddress; this.computedHashTable["##PORTNUMBER00##"] = fndPrinter.PortNumber; this.computedHashTable["##PORTNUMBER01##"] = fndPrinter.PortNumber; return(true); } } return(false); } } catch (Exception ex) { if (FileLogger.Instance.IsLogFatal) { FileLogger.Instance.logMessage(LogLevel.FATAL, null, "Population of generate documents map failed: {0}: {1} ", ex.Message, ex.StackTrace); } return(false); } return(true); }