public ActionResult Statistics(long siteId, long menuId, long?id, bool?isEvent) { if (id == null) { id = 0; FormModel item = FormDAO.GetItemFromSourceID(menuId); if (item != null) { id = item.ID; } } IEnumerable <FieldModel> fields = FieldDAO.GetItems((long)id); IEnumerable <FieldValue> fieldValues = FieldValueDAO.GetItemsByFormID((long)id); bool hasValues = false; foreach (var item in fields) { IEnumerable <FieldValue> values = fieldValues.Where(v => v.FieldID == item.ID); int total = values.Count(); if (total > 0) { hasValues = true; break; } } ViewBag.hasValues = hasValues; ViewBag.Values = fieldValues; ViewBag.SiteID = siteId; ViewBag.MenuID = menuId; ViewBag.IsEvent = isEvent ?? false; return(View(fields)); }
public ActionResult FieldDesignViewAsync(string ids) { IEnumerable <long> idList = ids.Split(',').Select(item => long.Parse(item)); IEnumerable <FieldModel> fields = FieldDAO.GetItems(idList); FormModel form = FormDAO.GetItem(fields.First().ParentID); ViewBag.UploadDesignUrl = Golbal.UpdFileInfo.GetVPathBySiteID((long)form.SiteID, formDesignFileDir).TrimEnd('/'); return(View("FieldDesignView", fields)); }
public ActionResult List(long siteId, long menuId, int?index, FormItemSearch search) { FormModel form = FormDAO.GetItemFromSourceID(menuId); if (Request.HttpMethod == "GET") { if (index == null) { Utility.ClearSearchValue(); } else { FormItemSearch prevSearch = Utility.GetSearchValue <FormItemSearch>(); if (prevSearch != null) { search = prevSearch; } } } else if (Request.HttpMethod == "POST") { Utility.SetSearchValue(search); } search.FormID = form.ID; ViewBag.Search = search; Pagination pagination = new Pagination { PageIndex = index ?? 1, PageSize = 20 }; int totalRecord; IEnumerable <FormItem> items = FormItemDAO.GetItems(search, pagination.PageSize, pagination.PageIndex, out totalRecord); pagination.TotalRecord = totalRecord; ViewBag.Pagination = pagination; ViewBag.Form = form; ViewBag.Fields = FieldDAO.GetItems(search.FormID).Where(f => f.ShowInList).ToList(); ViewBag.SiteID = siteId; ViewBag.MenuID = menuId; ViewBag.UploadUrl = Golbal.UpdFileInfo.GetVPathByMenuID(siteId, menuId).TrimEnd('/') + "/"; return(View(items)); }
public FileResult ImportTmpl(long siteId, long menuId, long formId, bool?isEvent) { ViewData["Fields"] = FieldDAO.GetItems(formId); string html = Utility.GetViewHtml(this, "ImportTmpl", null); FormModel form = FormDAO.GetItem(formId); string title = form.Title; title = $"{ title }-匯入名單範本.xls"; ViewBag.SiteID = siteId; ViewBag.MenuID = menuId; ViewBag.FormID = formId; ViewBag.IsEvent = isEvent ?? false; return(File(System.Text.Encoding.UTF8.GetBytes(html), "application/vnd.ms-excel", title)); }
private FormItem FormItemSave(FormItem formItem) { formItem.IsTemp = false; IEnumerable <FieldModel> fields = FieldDAO.GetItems(formItem.FormID); foreach (FieldModel field in fields) { string val = Request.Form[field.ID.ToString()] ?? string.Empty; if (field.TypeID == "address") { string regions = Request.Form["Regions_" + field.ID] ?? string.Empty; int[] regionList = null; if (regions != string.Empty) { regionList = JsonConvert.DeserializeObject <int[]>(regions); } string address = Request.Form["Address_" + field.ID] ?? string.Empty; val = JsonConvert.SerializeObject(new FieldAddress { Regions = regionList, Address = address }); } FieldValueDAO.SetItem(new FieldValue { FormItemID = formItem.ID, FieldID = field.ID, Value = val }); if (field.DefaultType != null) { switch ((FieldDefaultType)(byte)field.DefaultType) { case FieldDefaultType.Email: formItem.Email = val; break; case FieldDefaultType.姓名: formItem.Name = val; break; case FieldDefaultType.性別: formItem.Sex = val; break; case FieldDefaultType.身份證字號: formItem.IDCard = val; break; case FieldDefaultType.手機: formItem.Mobile = val; break; case FieldDefaultType.電話: formItem.Phone = val; break; } } } FormItemDAO.SetItem(formItem); return(formItem); }