public async Task <IActionResult> Edit(EditYearEventViewModel model) { YearEvent yearEvent = await db.YearEvents.FirstOrDefaultAsync(ye => ye.Id == model.Id); yearEvent.EventText = model.EventText; yearEvent.FirstQuarter = model.FirstQuarter; yearEvent.SecondQuarter = model.SecondQuarter; yearEvent.ThirdQuarter = model.ThirdQuarter; yearEvent.FourthQuarter = model.FourthQuarter; yearEvent.Unit = model.Unit; yearEvent.TypeSection = model.TypeSection; Section section = await db.Sections.FirstOrDefaultAsync(sec => sec.Id == model.SectionId); yearEvent.Section = section.Name; SubSection subSection = await db.SubSections.FirstOrDefaultAsync(sub => sub.Id == model.SubSectionId); yearEvent.SubSection = subSection.Name; SubSection1 subSection1 = await db.SubSection1s.FirstOrDefaultAsync(sub1 => sub1.Id == model.SubSection1Id); yearEvent.SubSection1 = subSection1.Name; yearEvent.DataYear = model.DataYear; await db.SaveChangesAsync(); return(RedirectToAction("Details", "Agency", new { id = yearEvent.AgencyId, DataYearVM = yearEvent.DataYear })); }
public async Task <IActionResult> Create(CreateYearEventViewModel model) { YearEvent yearEvent = new YearEvent() { AgencyId = model.AgencyId, Number = await db.YearEvents.Where(y => y.AgencyId == model.AgencyId && y.DataYear == model.DataYear).CountAsync() + 1, EventText = model.EventText, FirstQuarter = model.FirstQuarter, SecondQuarter = model.SecondQuarter, ThirdQuarter = model.ThirdQuarter, FourthQuarter = model.FourthQuarter, Unit = model.Unit, TypeSection = model.TypeSection, DataYear = model.DataYear }; Section Section = await db.Sections.FirstOrDefaultAsync(subs => subs.Id == model.SectionId); yearEvent.Section = Section.Name; SubSection subSection = await db.SubSections.FirstOrDefaultAsync(subs => subs.Id == model.SubSectionId); yearEvent.SubSection = subSection.Name; SubSection1 subSection1 = await db.SubSection1s.FirstOrDefaultAsync(subs => subs.Id == model.SubSection1Id); yearEvent.SubSection1 = subSection1.Name; db.YearEvents.Add(yearEvent); await db.SaveChangesAsync(); return(RedirectToAction("Details", "Agency", new { id = yearEvent.AgencyId, DataYearVM = yearEvent.DataYear })); }
public ActionResult CreateSubSection(FormCollection collection) { string subsectioname = ""; bool active = false; int sid = 0; if (collection.Keys.Count == 3) { int.TryParse(collection["hSectionID"], out sid); subsectioname = collection["SubSectionName"]; active = collection["ActiveYN"].Contains("true"); } SubSection data = new SubSection { SectionID = sid, SubSectionName = subsectioname, ActiveYN = active }; var ssid = this.treeview.CreateSubSection(data); var subsections = this.treeview.GetSubSections(sid, true).Where(q => q.SubsectionID == ssid).First(); return(PartialView("SubSectionNode", subsections)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,SectionId")] SubSection subSection) { if (id != subSection.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(subSection); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SubSectionExists(subSection.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } ViewData["SectionId"] = new SelectList(_context.Sections, "Id", "Name", subSection.SectionId); return(View(subSection)); }
public void Section(TSection section, string message, MessageType?type = null) { _activeSection = section; _activeSubSection = ""; SubSection sub; // create if (!_subSections.ContainsKey(_activeSection)) { sub = new SubSection { Section = _activeSection, Name = _activeSubSection, Type = type ?? MessageType.Info, Message = message }; _subSections[_activeSection] = new Dictionary <string, SubSection>(); _subSections[_activeSection].Add(_activeSubSection, sub); } // replace else { sub = _subSections[_activeSection][_activeSubSection]; sub.Message = message; sub.Type = type ?? sub.Type; } _send(sub); }
public void SetMessage(string subSection = null, string message = null, MessageType?type = null, int?progressSteps = null) { _activeSubSection = subSection ?? _activeSubSection; SubSection sub; // create if (!_subSections[_activeSection].ContainsKey(_activeSubSection)) { sub = new SubSection { Section = _activeSection, Name = _activeSubSection, Type = type ?? MessageType.Info, Message = message, MaxProgress = progressSteps ?? 0 }; _subSections[_activeSection].Add(_activeSubSection, sub); } // replace else { sub = _subSections[_activeSection][_activeSubSection]; if (message != null) { sub.Message = message; } if (type != null) { sub.Type = type.Value; } if (progressSteps != null) { sub.MaxProgress = progressSteps.Value; sub.CurrentProgress = 0; } } _send(sub); }
public void Error(string message) { /// limit SubSection sub = _subSections[_activeSection][_activeSubSection]; if (sub.ErrorCount == MaxErrors) { sub.Errors.Add("More errors hidden..."); _send(sub); sub.HiddenErrors.Add(message); return; } else if (sub.Errors.Count > MaxErrors) { sub.HiddenErrors.Add(message); return; } /// change section if (_activeSubSection != "") { // section SubSection section = _subSections[_activeSection][""]; section.Type = MessageType.Error; _send(section); } /// sub sub.Type = MessageType.Error; sub.Errors.Add(message); _send(sub); }
internal SubSections GetSubSections(Section section, string response_id) { try { QuestionProvider provider = new QuestionProvider(DbInfo); string query = $"select * from dsto_subsections where yref_section='{section.Key}' and deleted=0"; var table = DbInfo.ExecuteSelectQuery(query); if (table.Rows.Count > 0) { DataRow row = table.Rows[0]; SubSection subsection = section.SubSections.Add(); subsection.Key = row["guid"].ToString(); subsection.OID = int.Parse(row["OID"].ToString()); subsection.Name = row["Name"].ToString(); subsection.Deleted = bool.Parse(row["deleted"].ToString()); subsection.CreatedBy = row["created_by"].ToString(); subsection.Questions = provider.GetQuestions(subsection, response_id); } return(section.SubSections); } catch (Exception ex) { throw ex; } }
public override bool Save(DCAnalyticsObject obj) { QuestionProvider provider = new QuestionProvider(DbInfo); SubSection subsection = obj as SubSection; var exists = RecordExists("dsto_subsections", subsection.Key); string query = string.Empty; if (!exists) { query = $"insert into dsto_subsections([guid],Name,[created_by],[yref_section]) values('{subsection.Key}','{subsection.Name}','Admin','{subsection.SectionKey}')"; } else { //update query = $"UPDATE dsto_subsections SET [Name]='{subsection.Name}', " + $"[Deleted]='{subsection.Deleted}' " + $"WHERE [guid] = '{subsection.Key}'"; } if (DbInfo.ExecuteNonQuery(query) > -1) { //save questions foreach (var qn in subsection.Questions) { qn.SubSectionKey = subsection.Key; provider.Save(qn); } return(true); } return(false); }
public ActionResult CreateSubSection(int?id, SubSection subSection) { subSection.SectionID = id; setzDB.SubSections.Add(subSection); setzDB.SaveChanges(); return(RedirectToAction("Index", "Admin")); }
/// <summary> /// 保存版块 /// </summary> /// <param name="name"></param> /// <param name="desc"></param> /// <param name="mainId"></param> /// <param name="topic">完成后是否跳转到发帖页面</param> /// <returns></returns> public ActionResult SaveSection(string name, string desc, int mainId, int topic) { SubSection model = new SubSection(); model.Sectionid = mainId; model.SubSectionName = name; model.SectionDescription = desc; model.TenantId = CurrentTenant.TenantId; model.CreateTime = DateTime.Now; model.Creater = CurrentUser.UserId; if (Request.Files != null && Request.Files.Count > 0 && Request.Files[0] != null && Request.Files[0].ContentLength > 0) { var filepath = SaveFile(Request.Files[0]); model.FrontImage = filepath; } _bbsService.AddSubSection(model); #region 积分 BusinessCommon.Integration.IntegrationManager.Instence.FireIntegrationEvent(IntegrationEvents.CreateSection, CurrentUser.UserId, CurrentTenant.TenantId); #endregion if (topic == 1) { return(RedirectToAction("CreateTopic")); } return(RedirectToAction("SectionIndex", new { sectId = model.SubSectionId })); //return Json(new { result = 1, msg = RetechWing.LanguageResources.Common.SaveSuccess }, JsonRequestBehavior.DenyGet); }
public List <SubSection> ListGenerateSubSection(DataTable aDataTable) { try { _ssections = new List <SubSection>(); foreach (DataRow aRow in aDataTable.Rows) { var value = Convert.ToInt32(aRow["ShortageOrExcess"]); var aSSection = new SubSection { SSection = aRow["SubSection"].ToString(), Budget = Convert.ToInt32(aRow["Budget"].ToString()), Actual = Convert.ToInt32(aRow["Actual"].ToString()), Short = value >= 0 ? "0" : Math.Abs(value).ToString(), Ex = value > 0 ? value.ToString() : "0", SSectionId = Convert.ToInt32(aRow["SSecCD"]), SectionId = Convert.ToInt32(aRow["SecCD"]), DeptId = Convert.ToInt32(aRow["DeptCD"]) }; _ssections.Add(aSSection); } } catch (Exception ex) { return(_ssections); } return(_ssections); }
/// <summary> /// Get the Layout information for a SubSection. /// </summary> private SubSectionLayout GetSubSectionLayout(SubSection subSection, DataEntrySection dataEntrySection) { return(new SubSectionLayout { Label = subSection.Label, OrderBy = subSection.OrderBy }); }
}/// <summary> /// 添加一个子版块 /// </summary> /// <param name="sub"></param> /// <returns></returns> public int AddSubSection(SubSection sub) { int sid = _dataAccess.AddEntity(sub); //创建人默认加入到版块中 CollectSubSection(sid, sub.Creater); return(sid); }
public void IncrementProgress(string subSection = null) { _activeSubSection = subSection ?? _activeSubSection; SubSection sub = _subSections[_activeSection][_activeSubSection]; sub.CurrentProgress++; _send(sub); }
/// <summary> /// Serves as a hash function for a particular type. /// </summary> /// <returns>A hash code for the current <see cref="T:System.Object" />.</returns> public override int GetHashCode() { unchecked { int hashCode = (Section != null ? Section.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (SubSection != null ? SubSection.GetHashCode() : 0); return(hashCode); } }
/// <summary> /// Returns true if the input mouse location is inside the input subsection /// </summary> protected bool IsMouseInSubSection(SubSection subSection, Vector2 mLoc) { if (mLoc.X >= subSection.origin.X && mLoc.X < subSection.origin.X + subSection.size.X && mLoc.Y >= subSection.origin.Y && mLoc.Y < subSection.origin.Y + subSection.size.Y) { return(true); } return(false); }
public ActionResult SectionDetail(int sectId, int p = 1) { SubSection subSection = _bbsService.GetSubSection(sectId); ViewBag.subsection = subSection; int total; var topics = _bbsService.GetTopics(out total, sectId, p, 10, "", "CreateTime DESC"); var pageList = new MvcPager.PagedList <Topic>(topics, p, 10, total); return(View(pageList)); }
private void AddSubSection() { SubSection subSection = _section.SubSections.Add(); SubSectionForm subSectionForm = new SubSectionForm(); subSectionForm.PickValues(subSection); if (subSectionForm.ShowDialog() == DialogResult.OK) { RefreshSubSections(); } }
public async Task <IActionResult> Create([Bind("Id,Name,SectionId")] SubSection subSection) { if (ModelState.IsValid) { _context.Add(subSection); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewData["SectionId"] = new SelectList(_context.Sections, "Id", "Name", subSection.SectionId); return(View(subSection)); }
/// <summary> /// Represent this reference as a string /// </summary> /// <param name="format"> /// The format, valid characters are: /// <list> /// <item>%d% - Domain</item> /// <item>%s% - SubSection</item> /// <item>%S% - Section</item> /// <item>%r% - Realm</item> /// <item>%i% - Id</item> /// <item>%A% - Artifact</item> /// <item>%a% - Subartifact</item> /// </list> /// </param> /// <returns></returns> public string ToString(String format) { string retString = format; retString = retString.Replace("%d%", Domain.ToString()); retString = retString.Replace("%s%", SubSection.ToString()); retString = retString.Replace("%r%", Realm); retString = retString.Replace("%i%", Id); retString = retString.Replace("%S%", Section); retString = retString.Replace("%A%", Artifact.ToString()); retString = retString.Replace("%a%", SubArtifact); retString = retString.Replace("%v%", Version); return(retString); }
public async Task <IActionResult> Edit(int id) { YearEvent yearEvent = await db.YearEvents.FirstOrDefaultAsync(ye => ye.Id == id); if (yearEvent == null) { return(NotFound()); } else { EditYearEventViewModel model = new EditYearEventViewModel { Id = yearEvent.Id, Agency = await db.Agencies.FirstOrDefaultAsync(ag => ag.Id == yearEvent.AgencyId), AgencyId = yearEvent.AgencyId, Number = yearEvent.Number, EventText = yearEvent.EventText, FirstQuarter = yearEvent.FirstQuarter, SecondQuarter = yearEvent.SecondQuarter, ThirdQuarter = yearEvent.ThirdQuarter, FourthQuarter = yearEvent.FourthQuarter, Unit = yearEvent.Unit, Units = await db.Units.ToListAsync(), TypeSection = yearEvent.TypeSection, TypeSections = await db.TypeSections.ToListAsync(), Sections = await db.Sections.ToListAsync(), SubSections = await db.SubSections.ToListAsync(), SubSection = yearEvent.SubSection, SubSection1s = await db.SubSection1s.ToListAsync(), SubSection1 = yearEvent.SubSection1, DataYear = yearEvent.DataYear, DataYears = await db.DataYears.ToListAsync() }; if (yearEvent.Section == null) { yearEvent.Section = "ИСО"; } Section section = await db.Sections.FirstOrDefaultAsync(sec => sec.Name == yearEvent.Section); model.SectionId = section.Id; SubSection subSection = await db.SubSections.FirstOrDefaultAsync(sub => sub.Name == yearEvent.SubSection); model.SubSectionId = subSection.Id; SubSection1 subSection1 = await db.SubSection1s.FirstOrDefaultAsync(sub1 => sub1.Name == yearEvent.SubSection1); model.SubSection1Id = subSection1.Id; return(View(model)); } }
private void AddSubSection() { if (Tree.SelectedNode == null) { return; } if (Tree.SelectedNode.Text != "Sub Sections") { return; } Section section = Tree.SelectedNode.Parent.Tag as Section; SubSection subSection = section.SubSections.Add(); SubSectionForm subSectionForm = new SubSectionForm(); subSectionForm.PickValues(subSection); subSectionForm.ShowDialog(); var subSectionTreeNode = AddToParentNode(Tree.SelectedNode, subSection, subSection.Name); subSectionTreeNode.Tag = subSection; foreach (var qn in subSection.Questions) { TreeNode questionsNode = subSectionTreeNode.Nodes.Add("Questions"); questionsNode.Tag = subSection.Questions; TreeNode questionNode = questionsNode.Nodes.Add(qn.Name); questionNode.Tag = qn; switch (qn.QuestionType) { case QuestionTypes.Closed: questionNode.ImageIndex = 6; questionNode.SelectedImageIndex = 6; break; case QuestionTypes.Open: questionNode.ImageIndex = 3; questionNode.SelectedImageIndex = 3; break; case QuestionTypes.MultipleChoice: questionNode.ImageIndex = 10; questionNode.SelectedImageIndex = 10; break; } } subSectionTreeNode.ImageIndex = 8; subSectionTreeNode.SelectedImageIndex = 8; }
public int CreateSubSection(SubSection data) { try { data.MFlag = 0; context.subsections.Add(data); context.SaveChanges(); return(data.SubsectionID); } catch { return(0); } }
public async Task <IActionResult> DeleteSubSection(int?id) { if (id != null) { SubSection subSection = await db.SubSections.FirstOrDefaultAsync(u => u.Id == id); if (subSection != null) { db.SubSections.Remove(subSection); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } } return(NotFound()); }
public ActionResult DeleteSubSection(SubSection subSection) { SubSection deleted = setzDB.SubSections.Find(subSection.ID); try { setzDB.SubSections.Remove(deleted); setzDB.SaveChanges(); } catch (DataException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. return(RedirectToAction("DeleteSubSection", new { id = subSection.ID, saveChangesError = true })); } return(RedirectToAction("Index", "Admin")); }
public bool DeleteSubSection(string key) { string query = $"delete from dsto_subsections where [guid] = {key}"; SubSection subSection = GetSubSection(key); string[] guids = new string[subSection.Questions.Count]; //int i = 0; foreach (var s in subSection.Questions) { //guids[i] = s.Key; //i++; new QuestionProvider(DbInfo).DeleteQuestion(s.Key); } var rows = DbInfo.ExecuteNonQuery(query); return(rows > 0); }
public void SetUp() { _templateValidationResolver = new TemplateValidationResolver(); _template = new Template(); List <Section> lstSection = new List <Section>(); Section section = new Section() { Name = "Offense", Path = "offenses", DataEntryValidation = new List <ValidationRule>(), Fields = new List <Field>() }; Section section1 = new Section() { Name = "Arrest", Path = "arrestCharges", DataEntryValidation = new List <ValidationRule>(), Fields = new List <Field>() }; Section section2 = new Section() { Name = "Arrest", Path = "arrestee", DataEntryValidation = new List <ValidationRule>(), Fields = new List <Field>() }; Field field = new Field() { DataEntryFieldId = Guid.NewGuid() }; section.Fields.Add(field); section1.Fields.Add(field); section2.Fields.Add(field); section.SubSections = new List <SubSection>(); section1.SubSections = new List <SubSection>(); section2.SubSections = new List <SubSection>(); SubSection subSection = new SubSection() { Label = "data", Fields = new List <Field>() }; subSection.Fields.Add(field); section.SubSections.Add(subSection); section1.SubSections.Add(subSection); section2.SubSections.Add(subSection); lstSection.Add(section); lstSection.Add(section1); lstSection.Add(section2); _template.Sections = lstSection; _template.CaseNumberValidation = AgencyValidtion.Required; _template.ReportNumberValidation = AgencyValidtion.Required; _template.DataEntryValidation = new List <ValidationRule>(); }
public override string ToString() { string result = "[" + SectionName; if (!SubSection.IsNullOrEmpty()) { var escSubSection = SubSection.Replace("\"", "\\\""); escSubSection = escSubSection.Replace("\\", "\\\\"); if (!SubSectionCaseSensitive) { escSubSection = escSubSection.ToLower(); } result = result + " \"" + escSubSection + "\""; } result = result + "]"; return(result); }
public override string ToString() { string result = "[" + SectionName; if (!SubSection.IsNullOrEmpty()) { if (SubSectionCaseSensitive) { result = result + " \"" + SubSection + "\""; } else { result = result + "." + SubSection; } } result = result + "]"; return(result); }
/// <summary> /// Gets the first page of posts for the specified section and sub-section. /// </summary> /// <param name="section">The section for which the posts are to be retrieved.</param> /// <param name="subSection">The sub-section for which the posts are to be retrieved.</param> /// <exception cref="NineGagException">If anything goes wrong during the retrieval of the page, an <see cref="NineGagException"/> exception is thrown.</exception> /// <returns>Returns the first page of the specified section.</returns> public Task<Page> GetPostsAsync(Section section, SubSection subSection) => this.GetPostsAsync(section, subSection, new CancellationTokenSource().Token);
/// <summary> /// Gets the first page of posts for the specified section and sub-section. /// </summary> /// <param name="section">The section for which the posts are to be retrieved.</param> /// <param name="subSection">The sub-section for which the posts are to be retrieved.</param> /// <param name="cancellationToken">The cancellation token, which can be used to cancel the retrieval of the page.</param> /// <exception cref="NineGagException">If anything goes wrong during the retrieval of the page, an <see cref="NineGagException"/> exception is thrown.</exception> /// <returns>Returns the first page of the specified section.</returns> public Task<Page> GetPostsAsync(Section section, SubSection subSection, CancellationToken cancellationToken) { // Generates the URI for the section and sub-section Uri sectionUri; if (subSection == SubSection.Hot) sectionUri = new Uri(string.Concat(section.RelativeUri.OriginalString, NineGagClient.hotPath), UriKind.Relative); else sectionUri = new Uri(string.Concat(section.RelativeUri.OriginalString, NineGagClient.freshPath), UriKind.Relative); // Retrieves the posts of the section and the sub-section return this.GetPostsAsync(sectionUri, cancellationToken); }