public bool AddRecord(listtable Record) { myRecords.Add(Record); context.listtables.Add(Record); context.SaveChanges(); return(true); }
public ActionResult Create(category category) { category cat = CategoryRepository.GetAllCategory().FirstOrDefault(e => e.CategoryName == category.CategoryName); if (cat != null) { TempData["Message2"] = string.Format("Category <{0}> already exist", cat.CategoryName); return(RedirectToAction("Create")); } try { if (ModelState.IsValid) { db.categories.Add(category); db.SaveChanges(); CategoryRepository.AddRecord(category); TempData["Message2"] = "Category created successfully."; return(RedirectToAction("Create")); } } catch (Exception ex) { TempData["Message2"] = "Error ocurred creating category."; } return(View(category)); }
public ActionResult Create(ministryincome ministryincome) { try { if (ministryincome.Comment == null) { ministryincome.Comment = ""; } if (ModelState.IsValid) { db.ministryincomes.Add(ministryincome); db.SaveChanges(); MinistryIncomeRepository.AddRecord(ministryincome); TempData["Message2"] = "Ministry income record added successfully."; return(RedirectToAction("Create", new { ministryID = ministryincome.ministryID })); } } catch (Exception ex) { TempData["Message2"] = "Error adding ministry income record"; } GetData(ministryincome.ministryID); return(PartialView(ministryincome)); }
public ActionResult Create(budget budget) { try { if (budget.Comment == null) { budget.Comment = ""; } if (ModelState.IsValid) { db.budgets.Add(budget); db.SaveChanges(); BudgetRepository.AddRecord(budget); TempData["Message2"] = "Budget record added successfully."; GetData(budget.Type); return(RedirectToAction("Create", new { BudgetType = budget.Type })); } } catch (Exception ex) { TempData["Message2"] = "Error adding budget item"; } GetData(budget.Type); return(PartialView(budget)); }
public bool AddRecord(bankbalance Record) { //myRecords.Add(record); context.bankbalances.Add(Record); context.SaveChanges(); return(true); }
public ActionResult Create(pledge pledge) { if (pledge.memberID == 0) { TempData["Message2"] = "Error adding pledge. Please select member."; GetData(); ViewBag.Year = 0; return(PartialView(pledge)); } try { if (ModelState.IsValid) { pledge.FundName = ConstantRepository.GetConstantID(pledge.FundID).Value1; db.pledges.Add(pledge); db.SaveChanges(); PledgeRepository.AddRecord(pledge); TempData["Message2"] = "Pledge added successfully."; GetData(); return(RedirectToAction("Create")); } } catch (Exception ex) { TempData["Message2"] = "Error adding pledge"; } GetData(); ViewBag.Year = 0; return(PartialView(pledge)); }
public ActionResult Create(goal goal) { try { if (goal.Comment == null) { goal.Comment = ""; } if (goal.Description == null) { goal.Description = ""; } if (ModelState.IsValid) { db.goals.Add(goal); db.SaveChanges(); TempData["Message2"] = "Goal record added successfully."; GetData(goal.ministryID); GoalRepository.AddRecord(goal); // return RedirectToAction("Create", new {ministryID =goal.ministryID}); return(RedirectToAction("Create")); } } catch (Exception ex) { TempData["Message2"] = "Error adding goal"; } GetData(goal.ministryID); return(PartialView(goal)); }
public ActionResult Create(income income) { try { subcategory subCat = SubCategoryRepository.GetBySubCategoryID(income.subCategoryID); if (income.bankAccountID == 0) { income.bankAccountID = subCat.bankAccountID; } if (income.Title == null) { income.Title = subCat.SubCategoryName; } if (income.Comment == null) { income.Comment = ""; } if (ModelState.IsValid) { db.incomes.Add(income); db.SaveChanges(); IncomeRepository.AddRecord(income); TempData["Message2"] = "Income added successfully."; return(RedirectToAction("Create")); } } catch (Exception ex) { TempData["Message2"] = "Error adding income"; } GetData(); return(PartialView(income)); }
public ActionResult Create(staff staff) { try { if (ModelState.IsValid) { db.staffs.Add(staff); db.SaveChanges(); //create default staff responsibities responsibility duties = new responsibility(); duties.staffID = staff.staffID; duties.BriefDescription = "Here is summary of My responsibilities"; duties.FullDescription = "Here is full detail of my responsibilities"; duties.DateCreated = System.DateTime.Today; duties.Status = "Active"; duties.Title = "Church officer"; duties.Type = "Primary"; duties.EnteredBy = User.Identity.Name.ToString(); duties.DateEntered = System.DateTime.Today; db.responsibilities.Add(duties); db.SaveChanges(); StaffRepository.AddRecord(staff); TempData["Message2"] = "Staff added successfully."; GetData(); return(RedirectToAction("Create")); } } catch (Exception ex) { TempData["Message2"] = "Error adding staff"; } GetData(); return(PartialView(staff)); }
public ActionResult Create(contribution contribution) { if (contribution.memberID == 0) { TempData["Message2"] = "Error adding contribution. Please select member."; GetData(); ViewBag.Year = 0; return PartialView(contribution); } try { string memberName = db.members.Find(contribution.memberID).MemberName; if (contribution.CheckNumber == null) { contribution.CheckNumber = ""; } if (ModelState.IsValid) { db.contributions.Add(contribution); db.SaveChanges(); ContributionRepository.AddRecord(contribution); TempData["Message2"] = "contribution record added successfully."; GetData(); return RedirectToAction("CreateList", new {dDate=contribution.ContributionDate, memberID = contribution.memberID }); } } catch (Exception ex) { TempData["Message2"] = "Error adding contribution"; } GetData(); return PartialView(contribution); }
public ActionResult Create(meeting meeting, string CallerType = "") { meeting mtg = db.meetings.FirstOrDefault(e => e.meetingID == meeting.meetingID && e.Title == meeting.Title); if (mtg != null) { TempData["Message2"] = "Meeting already exist"; return(PartialView(meeting)); } try { //if (budget.Comment == null) { budget.Comment = ""; } constant cont = ConstantRepository.GetConstantListByCategory("Ministry Activity").FirstOrDefault(e => e.ConstantName == "Ministry Meeting"); //set meeting on calendar calendar cal = new calendar(); cal.ministryID = meeting.ministryID; cal.EventType = cont.constantID; cal.CalendarDate = meeting.meetingDate; cal.StartTime = meeting.StartTime; cal.EndTime = meeting.EndTime; cal.Location = meeting.meetingVenue; cal.Title = meeting.Title; cal.Conductor = meeting.Conductor; cal.PublicAccess = false; cal.Description = ""; cal.EnteredBy = User.Identity.Name.ToString(); cal.DateEntered = System.DateTime.Today; cal.Status = "Active"; db.calendars.Add(cal); db.SaveChanges(); CalendarRepository.AddRecord(cal); meeting.CalendarID = cal.calendarID; if (ModelState.IsValid) { db.meetings.Add(meeting); db.SaveChanges(); MeetingRepository.AddRecord(meeting); TempData["Message2"] = "Meeting created successfully."; GetData(meeting.ministryID); if (CallerType == "Ministry") { return(RedirectToAction("Create", new { MinistryID = meeting.ministryID, CallerType = "Ministry" })); } else { return(RedirectToAction("Create")); } } } catch (Exception ex) { TempData["Message2"] = "Error adding meeting record"; } GetData(meeting.ministryID); return(PartialView(meeting)); }
public void UpdateRecord(constant constant) { if (constant.constantID > 0) { context.Entry(constant).State = System.Data.EntityState.Modified; } context.SaveChanges(); }
public ActionResult Create(listitem listitem) { try { if (listitem.Comment == null) { listitem.Comment = ""; } if (listitem.Value1 == null) { listitem.Value1 = ""; } if (listitem.Value2 == null) { listitem.Value2 = ""; } if (listitem.Value3 == null) { listitem.Value3 = ""; } if (listitem.Value4 == null) { listitem.Value4 = ""; } if (listitem.Value5 == null) { listitem.Value5 = ""; } if (listitem.Value6 == null) { listitem.Value6 = ""; } // if (listitem.Value7 == null) { listitem.Value7 = ""; } if (ModelState.IsValid) { db.listitems.Add(listitem); db.SaveChanges(); ListItemRepository.AddRecord(listitem); TempData["Message2"] = "Table record added successfully."; GetData(); return(RedirectToAction("Create", new { ListTableID = listitem.listTableID })); } } catch (Exception ex) { TempData["Message2"] = "Error adding table record"; } GetData(); return(PartialView(listitem)); }
public ActionResult Create(payee payee) { payee p = PayeeRepository.GetAllPayee().FirstOrDefault(e => e.PayeeName == payee.PayeeName && e.AccountNumber == payee.AccountNumber); if (p != null) { TempData["Message2"] = string.Format("Payee <{0}> already exist", p.PayeeName); return(RedirectToAction("Create")); } int bankaccountID = db.subcategories.Find(payee.SubCategoryID).bankAccountID; if (payee.Email == null) { payee.Email = "Null"; } if (payee.PhoneNumber == null) { payee.PhoneNumber = "Null"; } if (payee.URL == null) { payee.URL = "Null"; } try { payee.BankAccountID = bankaccountID; if (ModelState.IsValid) { db.payees.Add(payee); db.SaveChanges(); PayeeRepository.AddRecord(payee); TempData["Message2"] = "Payee record created successfully."; GetData(); return(RedirectToAction("Create")); } } catch (Exception ex) { TempData["Message2"] = "Error ocurred creating payee."; } GetData(); return(PartialView(payee)); }
public ActionResult Create(programevent programevent) { int ministryID = GoalRepository.GetGoalByID(programevent.goalID).ministryID; constant cont = ConstantRepository.GetConstantListByCategory("Ministry Activity").FirstOrDefault(e => e.ConstantName == "Program/Event"); try { //set meeting on calendar calendar cal = new calendar(); cal.ministryID = ministryID; cal.EventType = cont.constantID; cal.CalendarDate = programevent.C_When; cal.StartTime = programevent.BeginTime; cal.EndTime = programevent.EndTime; cal.Location = programevent.C_Where; cal.Title = programevent.Title; cal.Conductor = MemberRepository.GetMemberByID(programevent.C_Who).FullNameTitle; cal.PublicAccess = true; cal.Description = ""; cal.EnteredBy = User.Identity.Name.ToString(); cal.DateEntered = System.DateTime.Today; cal.Status = "Active"; db.calendars.Add(cal); db.SaveChanges(); CalendarRepository.AddRecord(cal); programevent.CalendarID = cal.calendarID; if (ModelState.IsValid) { db.programevents.Add(programevent); db.SaveChanges(); ProgramEventRepository.AddRecord(programevent); TempData["Message2"] = "Event added successfully."; GetData(ministryID); return(RedirectToAction("Create", new { GoalID = programevent.goalID })); } } catch (Exception ex) { TempData["Message2"] = "Error adding event"; } GetData(ministryID); return(PartialView(programevent)); }
public ActionResult Create(subcategory subcategory, int SubCategoryParentID = 0) { subcategory subcat = db.subcategories.FirstOrDefault(e => e.SubCategoryName == subcategory.SubCategoryName && e.categoryID == subcategory.categoryID); if (subcat != null) { TempData["Message2"] = string.Format("Category <{0}> already exist", subcat.SubCategoryName); return(RedirectToAction("Index")); } try { if (SubCategoryParentID > 0) { subcategory ParentCategory = db.subcategories.Find(SubCategoryParentID); subcategory.bankAccountID = ParentCategory.bankAccountID; subcategory.categoryID = ParentCategory.categoryID; } if (ModelState.IsValid) { db.subcategories.Add(subcategory); db.SaveChanges(); SubCategoryRepository.AddRecord(subcategory); TempData["Message2"] = "Category created successfully."; if (SubCategoryParentID > 0) { subcategoryitem item = new subcategoryitem(); item.ParentCategoryID = SubCategoryParentID; item.ChildCategoryID = subcategory.subCategoryID; db.subcategoryitems.Add(item); db.SaveChanges(); } return(RedirectToAction("Create", new { CategoryType = subcategory.CategoryType })); } } catch (Exception ex) { TempData["Message2"] = "Error creating category"; } subcategory.category = CategoryRepository.GetCategoryByID(subcategory.categoryID); GetData(subcategory.category.CategoryName); return(PartialView(subcategory)); }
public ActionResult Create(ministry ministry) { try { //if (contribution.CheckNumber == null) { contribution.CheckNumber = ""; } if (ModelState.IsValid) { db.ministries.Add(ministry); db.SaveChanges(); MinistryRepository.AddRecord(ministry); TempData["Message2"] = "Ministry record added successfully."; GetData(); if (ministry.GroupMinistryID > 0) { ministrygroup group = new ministrygroup(); group.ChildID = ministry.ministryID; group.ParentID = (int)ministry.GroupMinistryID; db.ministrygroups.Add(group); db.SaveChanges(); } return(RedirectToAction("Create")); } } catch (Exception ex) { TempData["Message2"] = "Error adding ministry"; } GetData(); return(PartialView(ministry)); }
public void DeleteRecord(childparent record) { using (churchdatabaseEntities context = new churchdatabaseEntities()) { // myRecords.Remove(record); childparent aRecord = context.childparents.FirstOrDefault(e => e.ChildParentID == record.ChildParentID); context.childparents.Remove(aRecord); context.SaveChanges(); } }
public void DeleteRecord(ministrymember record) { using (churchdatabaseEntities context = new churchdatabaseEntities()) { // myRecords.Remove(record); ministrymember aRecord = context.ministrymembers.FirstOrDefault(e => e.MinistryMemberID == record.MinistryMemberID); context.ministrymembers.Remove(aRecord); context.SaveChanges(); } }
public void DeleteRecord(responsibility record) { using (churchdatabaseEntities context = new churchdatabaseEntities()) { // myRecords.Remove(record); responsibility aRecord = context.responsibilities.FirstOrDefault(e => e.responsibilityID == record.responsibilityID); context.responsibilities.Remove(aRecord); context.SaveChanges(); } }
public ActionResult Create(task task) { int ministryID = GoalRepository.GetGoalByID(task.goalID).ministryID; try { if (ModelState.IsValid) { db.tasks.Add(task); db.SaveChanges(); //Action Items are tasks listed in the action item table if (task.parentTaskID > 0) { if (task.ActionItemTypeCode == null) { task.ActionItemTypeCode = ""; } actionitem a = new actionitem(); a.ParentItemID = task.parentTaskID; a.childItemID = task.taskID; a.ParentType = task.ActionItemTypeCode; db.actionitems.Add(a); db.SaveChanges(); TaskRepository.AddRecord(task); TempData["Message2"] = "Action Item added successfully."; GetData(ministryID); return(RedirectToAction("Create", new { goalID = task.goalID, parentTaskID = task.parentTaskID, ActionItemCode = task.ActionItemTypeCode, Code = "ActionItem" })); } TaskRepository.AddRecord(task); TempData["Message2"] = "Task added successfully."; GetData(ministryID); return(RedirectToAction("Create", new { bDate = DateTime.Today, eDate = DateTime.Today, SearchType = "GoalSearch", codeID = task.goalID })); } } catch (Exception ex) { TempData["Message2"] = "Error adding Task"; } GetData(ministryID); return(PartialView(task)); }
public ActionResult Create(bankaccount bankaccount) { try { if (ModelState.IsValid) { db.bankaccounts.Add(bankaccount); db.SaveChanges(); BankAccountRepository.AddRecord(bankaccount); TempData["Message2"] = "Bank account created successfully."; return(RedirectToAction("Create")); } } catch (Exception ex) { TempData["Message2"] = "Error ocurred creating bank account."; } return(PartialView(bankaccount)); }
public ActionResult Create(picture picture) { string ReturnUrl = Request.UrlReferrer.ToString(); try { if (picture.Description == null) { picture.Description = ""; } if (ModelState.IsValid) { foreach (var image in picture.files) { if (image != null) { picture.ImageMimeType = image.ContentType; picture.ImageData = new byte[image.ContentLength]; image.InputStream.Read(picture.ImageData, 0, image.ContentLength); } db.pictures.Add(picture); db.SaveChanges(); PictureRepository.AddRecord(picture); } TempData["Message2"] = "Picture added successfully."; GetData(); //return Content("Picture added successfully."); return(Redirect(ReturnUrl)); } } catch (Exception ex) { TempData["Message2"] = "Error adding picture"; } GetData(); return(PartialView(picture)); }
public ActionResult Create(product product) { try { if (ModelState.IsValid) { db.products.Add(product); db.SaveChanges(); ProductRepository.AddRecord(product); TempData["Message2"] = "Product added successfully."; GetData(); return(RedirectToAction("Create")); } } catch (Exception ex) { TempData["Message2"] = "Error adding product"; } return(View(product)); }
public ActionResult Create(property property) { try { if (ModelState.IsValid) { db.properties.Add(property); db.SaveChanges(); PropertyRepository.AddRecord(property); TempData["Message2"] = "Property added successfully."; GetData(); return(Content("Property created successfully.")); } } catch (Exception ex) { TempData["Message2"] = "Error adding property"; } return(PartialView(property)); }
public ActionResult Create(visitor visitor) { try { if (ModelState.IsValid) { db.visitors.Add(visitor); db.SaveChanges(); VisitorRepository.AddRecord(visitor); TempData["Message2"] = "Visitor added successfully."; GetData(); return(RedirectToAction("Create")); } } catch (Exception ex) { TempData["Message2"] = "Error adding visitor"; } GetData(); return(PartialView(visitor)); }
public ActionResult Create(saleitem saleitem) { try { if (ModelState.IsValid) { db.saleitems.Add(saleitem); db.SaveChanges(); SaleItemRepository.AddRecord(saleitem); TempData["Message2"] = "Sales item added successfully."; GetData(); return(RedirectToAction("Create")); } } catch (Exception ex) { TempData["Message2"] = "Error adding sale item"; } GetData(); return(View(saleitem)); }
public ActionResult Create(responsibility responsibility) { try { if (ModelState.IsValid) { db.responsibilities.Add(responsibility); db.SaveChanges(); ResponsibilityRepository.AddRecord(responsibility); TempData["Message2"] = "Responsibility added successfully."; GetData(); return(RedirectToAction("Create")); } } catch (Exception ex) { TempData["Message2"] = "Error adding responsibility"; } GetData(); return(PartialView(responsibility)); }
public ActionResult Create(family family) { try { if (ModelState.IsValid) { db.families.Add(family); db.SaveChanges(); TempData["Message2"] = "family record added successfully."; GetData(); FamilyRepository.AddRecord(family); //return Content("Fami!ly record created successfully"); return(RedirectToAction("Create")); } } catch (Exception ex) { TempData["Message2"] = "Error adding family"; } GetData(); return(View(family)); }
public ActionResult Create(bankbalance bankbalance) { try { if (ModelState.IsValid) { bankbalance.LastIncomeID = IncomeRepository.GetLastIncomeRecordID(); bankbalance.LastExpenseID = ExpenseRepository.GetLastExpenseRecordID(); db.bankbalances.Add(bankbalance); db.SaveChanges(); BankBalanceRepository.AddRecord(bankbalance); TempData["Message2"] = "Bank balance created successfully."; return(RedirectToAction("Create")); } } catch (Exception ex) { TempData["Message2"] = "Error ocurred creating bank balance."; } return(View(bankbalance)); }