void ReleaseDesignerOutlets() { if (HelloButton != null) { HelloButton.Dispose(); HelloButton = null; } if (Subheading != null) { Subheading.Dispose(); Subheading = null; } if (WelcomeImage != null) { WelcomeImage.Dispose(); WelcomeImage = null; } if (WelcomeLabel != null) { WelcomeLabel.Dispose(); WelcomeLabel = null; } }
public async Task UpdateSubheading(int subheadId, string subheadName, int subheadHeadId) { Subheading subheading = Context.Subheadings.FirstOrDefault(x => x.SubheadingId == subheadId); if (subheading != null) { subheading.SubheadingName = subheadName; subheading.SubheadingId = subheadHeadId; Context.Subheadings.Update(subheading); } await Context.SaveChangesAsync(); }
/// <summary> /// 新增或修改 /// </summary> /// <param name="data"></param> /// <returns></returns> public async Task <int> AddOrUpdate(Subheading data) { if (data.id <= 0) { await _db.Subheadings.AddAsync(data); await _db.SaveChangesAsync(); return(data.id); } else { var shead = await _db.Subheadings.SingleOrDefaultAsync(s => s.id == data.id); if (shead == null) { return(0); } shead.head = data.head; await _db.SaveChangesAsync(); return(data.id); } }
public async Task <IActionResult> SaveSubheading(Subheading data) { int aid = await _subheading.AddOrUpdate(data); return(Json(new { code = aid == 0 ? false : true, aid = aid })); }
private void FindSubheading(IExcelDataReader excelReader, string s) { try { string s2 = ReadCell(excelReader, 0); if (s2 != null) { string head = GetNormalString(@"^\d+ (.*)", s2); if (headings.ContainsKey(head)) { currentHeading = headings[head]; } else { var heiding = new Heading() { HeadingName = head }; Context.Headings.Add(heiding); Context.SaveChanges(); headings.Add(head, heiding.HeadingId); currentHeading = heiding.HeadingId; } } string str = GetNormalString(@"^\d.\d+ (.*)", s); if (str == "Общие показатели") { var tempSubhead = Context.Subheadings .Select(x => new Subheading { SubheadingId = x.SubheadingId, SubheadingName = x.SubheadingName, HeadingId = x.HeadingId }) .Where(x => x.SubheadingName == str && x.HeadingId == currentHeading).FirstOrDefault(); if (tempSubhead == null) { var subh = new Subheading() { SubheadingName = str, HeadingId = currentHeading }; Context.Subheadings.Add(subh); currentSubHead = subh.SubheadingId; } else { currentSubHead = tempSubhead.SubheadingId; } } else { if (subheadings.ContainsKey(str)) { currentSubHead = subheadings[str]; } else { var subh = new Subheading() { SubheadingName = str, HeadingId = currentHeading }; Context.Subheadings.Add(subh); Context.SaveChanges(); subheadings.Add(str, subh.SubheadingId); currentSubHead = subh.SubheadingId; } } } catch (Exception e) { } }