private void ExcuteAddNewPaymentCommand(object button) { try { var btn = button as System.Windows.Controls.Button; if (btn != null) { string buttonTag = btn.Tag.ToString(); switch (buttonTag) { case "Expense": var expenseEntryWindow = new ExpenseEntry(PaymentTypes.CashOut); expenseEntryWindow.ShowDialog(); break; case "CashLoan": var cashLoanEntryWindow = new ExpenseEntry(PaymentTypes.CashIn); cashLoanEntryWindow.ShowDialog(); break; case "Edit": var editWindow = new ExpenseEntry(SelectedPayment); editWindow.ShowDialog(); break; } } Load(); } catch (Exception exception) { MessageBox.Show("Can't Add Payment" + Environment.NewLine + exception.Message, "Can't Add Payment", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void Update(int Id, int Timesheetid, DateTime Expensedate, double Cost, string Expensedesc) { ExpenseEntry item = new ExpenseEntry(); item.MarkOld(); item.IsLoaded = true; item.Id = Id; item.Timesheetid = Timesheetid; item.Expensedate = Expensedate; item.Cost = Cost; item.Expensedesc = Expensedesc; item.IsDeleted = false; item.CreatedOn = null; item.CreatedBy = null; item.ModifiedOn = null; item.ModifiedBy = null; item.Save(UserName); }
// [Route("api/Entries/GetEntries")] public IActionResult UpdateEntry(int Id, [FromBody] ExpenseEntry entry) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (Id != entry.Id) { return(BadRequest()); } try { var oldEntry = _context.ExpenseEntries.FirstOrDefault(de => de.Id == Id); if (oldEntry == null) { return(NotFound()); } oldEntry.Description = entry.Description; oldEntry.Value = entry.Value; oldEntry.IsExpense = entry.IsExpense; _context.SaveChanges(); return(Ok("Entry Updated")); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
private void enterExpenseToolStripMenuItem_Click(object sender, EventArgs e) { // Load the expense entry form for user input ExpenseEntry expenseForm = new ExpenseEntry(); expenseForm.Show(); }
public ActionResult EditExpenseEntry(int eid) { Entities dc = new Entities(); expensesheet Sheet = dc.expensesheets.Find(eid); if (Sheet != null) { expenseentry thisExp = Sheet.expenseentries.FirstOrDefault(); if (thisExp != null) { ExpenseEntry viewExp = new ExpenseEntry() { EmpName = thisExp.expensesheet.employee.EmpFName + thisExp.expensesheet.employee.EmpLName, ExpCategory = thisExp.ExpCategory, ExpDate = thisExp.ExpDate, ExpDollarAmt = thisExp.ExpDollarAmt, ProjName = thisExp.project.ProjName, ExpenseEntryID = thisExp.ExpEntryID, SelectedCategoryText = thisExp.ExpCategory }; return(View(viewExp)); } else { return(HttpNotFound()); } } else { return(HttpNotFound()); } }
public ActionResult ExpenseEntry(int?eid, ExpenseEntry thisExpense) { //TODO: ADD edit/view expense entry logic in here using (Entities dc = new Entities()) { DateTime d = System.DateTime.Now.StartOfWeek(DayOfWeek.Monday); ///payrollcycle pc = dc.payrollcycles.Where(a => a.PayrollCycleStart = d); var v = dc.payrollcycles.Where(a => a.PayrollCycleStart == d).FirstOrDefault(); expensesheet es = new expensesheet { EmpID = Int32.Parse(Request.Cookies["UserID"].Value), PayrollCycleID = v.PayrollCycleID, ExpSheetStatus = "In Progress", ExpSheetTotalAmt = thisExpense.ExpDollarAmt }; dc.expensesheets.Add(es); expenseentry ee = new expenseentry() { ExpSheetID = (int)es.ExpSheetID, EmpID = es.EmpID, ExpDate = thisExpense.ExpDate, ExpDollarAmt = thisExpense.ExpDollarAmt, ExpCategory = thisExpense.ExpCategory.ToString(), ProjID = thisExpense.ProjID }; dc.expenseentries.Add(ee); try { dc.SaveChanges(); return(Redirect("List")); } catch (System.Data.Entity.Validation.DbEntityValidationException dbEx) { //more descriptive error for validation problems Exception exception = dbEx; foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { string message1 = string.Format("{0}:{1}", validationErrors.Entry.Entity.ToString(), validationError.ErrorMessage); //create a new exception inserting the current one as the InnerException exception = new InvalidOperationException(message1, exception); } } //error for UI ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); throw exception; } } }
public ActionResult CreateCat(CatVetting catVetting) { if (ModelState.IsValid) { if (catVetting.TempVettingDecimal != 0) { var eE = new ExpenseEntry(); catVetting.Animal = db.Animals.Find(catVetting.AnimalId); eE.VetBillsDecimal = catVetting.TempVettingDecimal; eE.VetBillsComment = catVetting.Animal.name + " - " + catVetting.ReasonForVisit; eE.AccountTypeID = 0; eE.EffectiveDate = (catVetting.VetDiagnosisDate == null) ? DateTime.Today : catVetting.VetDiagnosisDate; catVetting.VettingTotalDecimal += catVetting.TempVettingDecimal; catVetting.Animal.VettingTotalDecimal = catVetting.VettingTotalDecimal; db.ExpenseEntries.Add(eE); db.SaveChanges(); } db.CatVettings.Add(catVetting); db.SaveChanges(); return(RedirectToAction("CatIndex")); } //return View(dogVetting); return(RedirectToAction("CatIndex", "Vettings")); }
public async Task <int> AddExpenseAsync(Expense expense) { if (!string.IsNullOrEmpty(expense.ExpenseCategoryLabel)) { var newExpenseCategory = await _expenseCategoryRepository.GetExpenseCategoryForUserAsync(expense.ExpenseCategoryLabel, expense.UserId); if (newExpenseCategory != null) { expense.ExpenseCategoryId = newExpenseCategory.ExpenseCategoryId; } } var newExpenseEntry = new ExpenseEntry { UserId = expense.UserId, DateAdded = DateTime.Now, Description = expense.Description, Title = expense.Title, ExpenseCategoryId = expense.ExpenseCategoryId, Value = expense.Value }; _dbContext.ExpenseEntries.Add(newExpenseEntry); await _dbContext.SaveChangesAsync(); return(newExpenseEntry.ExpenseEntryId); }
public HttpResponseMessage Delete([FromUri] int id, [FromBody] int modifiedBy) { ExpenseEntry Report = new ExpenseEntry(); Report.ID = id; Report.ModifiedBy = modifiedBy; return(Request.CreateResponse(HttpStatusCode.OK, Report.Delete())); }
public ActionResult DeleteExpenseConfirmed(short id) { ExpenseEntry expenseEntry = db.ExpenseEntries.Find(id); db.ExpenseEntries.Remove(expenseEntry); db.SaveChanges(); return(RedirectToAction("Entries")); }
public ActionResult EditExpense(ExpenseEntry expenseEntry) { if (ModelState.IsValid) { db.Entry(expenseEntry).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Entries")); } ViewBag.AccountTypeID = new SelectList(db.AccountTypes, "AccountTypeID", "AccountTypeName", expenseEntry.AccountTypeID); return(View(expenseEntry)); }
public ActionResult CreateExpense(ExpenseEntry expenseEntry) { if (ModelState.IsValid) { db.ExpenseEntries.Add(expenseEntry); db.SaveChanges(); //return RedirectToAction("ListExpenses"); return(RedirectToAction("Entries")); } ViewBag.AccountTypeID = new SelectList(db.AccountTypes, "AccountTypeID", "AccountTypeName", expenseEntry.AccountTypeID); return(View(expenseEntry)); }
// GET: Accounting/Details/5 public ActionResult DetailsExpense(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ExpenseEntry expenseEntry = db.ExpenseEntries.Find(id); if (expenseEntry == null) { return(HttpNotFound()); } return(View(expenseEntry)); }
public void SavePersonelExpense(PersonelExpense expense) { var entry = new ExpenseEntry { UserId = expense.UserId, ProductId = expense.ProductId, Description = expense.Description, Date = expense.Date, Amount = expense.Amount, Created_On = DateTime.Now }; _db.ExpenseEntries.Add(entry); _db.SaveChanges(); }
// GET: Accounting/Edit/5 public ActionResult EditExpense(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ExpenseEntry expenseEntry = db.ExpenseEntries.Find(id); if (expenseEntry == null) { return(HttpNotFound()); } ViewBag.AccountTypeID = new SelectList(db.AccountTypes, "AccountTypeID", "AccountTypeName", expenseEntry.AccountTypeID); return(View(expenseEntry)); }
// [Route("api/Entries/GetEntries")] public IActionResult PostEntry([FromBody] ExpenseEntry entry) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { _context.ExpenseEntries.Add(entry); _context.SaveChanges(); return(Ok("Entry Added")); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public ActionResult Create(Animal animal) { if (animal.PullFee > 0.00m) { var eE = new ExpenseEntry { PullFeeDecimal = animal.PullFee, AccountTypeID = 0, EffectiveDate = animal.IntakeDate, PullFeeComment = animal.name + " - Pull Fee" }; db.ExpenseEntries.Add(eE); } animal.MCARId = AssignMCARId(animal.AnimalTypeID); db.Animals.Add(animal); db.SaveChanges(); return(RedirectToAction("Index", "Animals")); //return View(animal); }
public ActionResult DogEdit(DogVetting dogVetting) { if (ModelState.IsValid) { if (dogVetting.TempVettingDecimal != 0) { var eE = new ExpenseEntry(); dogVetting.Animal = db.Animals.Find(dogVetting.AnimalId); eE.VetBillsDecimal = dogVetting.TempVettingDecimal; eE.VetBillsComment = dogVetting.Animal.name + " - " + dogVetting.ReasonForVisit; eE.AccountTypeID = 0; eE.EffectiveDate = (dogVetting.VetDiagnosisDate == null) ? DateTime.Today : dogVetting.VetDiagnosisDate; dogVetting.VettingTotalDecimal += dogVetting.TempVettingDecimal; dogVetting.Animal.VettingTotalDecimal = dogVetting.VettingTotalDecimal; db.ExpenseEntries.Add(eE); db.SaveChanges(); } db.Entry(dogVetting).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("DogIndex")); } ViewBag.AnimalId = new SelectList(db.Animals.Where(e => e.AnimalTypeID == 0).Where(e => e.Adopted == false), "id", "Name", dogVetting.AnimalId); ViewBag.DewormerLocationId = new SelectList(db.Locations.Where(e => e.isBasicVaxLocation).OrderBy(e => e.isShowLast).ThenBy(e => e.name), "id", "name", dogVetting.DewormerLocationId); ViewBag.FleaTickLocationId = new SelectList(db.Locations.Where(e => e.isBasicVaxLocation).OrderBy(e => e.isShowLast).ThenBy(e => e.name), "id", "name", dogVetting.FleaTickLocationId); ViewBag.HeartwormLocationId = new SelectList(db.Locations.Where(e => e.isBasicVaxLocation).OrderBy(e => e.isShowLast).ThenBy(e => e.name), "id", "name", dogVetting.HeartwormLocationId); ViewBag.DA2PPR1LocationId = new SelectList(db.Locations.Where(e => e.isBasicVaxLocation).OrderBy(e => e.isShowLast).ThenBy(e => e.name), "id", "name", dogVetting.DA2PPR1LocationId); ViewBag.DA2PPR2LocationId = new SelectList(db.Locations.Where(e => e.isBasicVaxLocation).OrderBy(e => e.isShowLast).ThenBy(e => e.name), "id", "name", dogVetting.DA2PPR2LocationId); ViewBag.DA2PPR3LocationId = new SelectList(db.Locations.Where(e => e.isBasicVaxLocation).OrderBy(e => e.isShowLast).ThenBy(e => e.name), "id", "name", dogVetting.DA2PPR3LocationId); ViewBag.BordetellaLocationId = new SelectList(db.Locations.Where(e => e.isBasicVaxLocation).OrderBy(e => e.isShowLast).ThenBy(e => e.name), "id", "name", dogVetting.BordetellaLocationId); ViewBag.MicrochipLocationId = new SelectList(db.Locations.Where(e => e.isBasicVaxLocation).OrderBy(e => e.isShowLast).ThenBy(e => e.name), "id", "name", dogVetting.MicrochipLocationId); ViewBag.RabiesLocationId = new SelectList(db.Locations.Where(e => e.isRabiesVaxLocation).OrderBy(e => e.isShowLast).ThenBy(e => e.name), "id", "name", dogVetting.RabiesLocationId); ViewBag.SterilizationLocationId = new SelectList(db.Locations.Where(e => e.isRabiesVaxLocation).OrderBy(e => e.isShowLast).ThenBy(e => e.name), "id", "name", dogVetting.SterilizationLocationId); ViewBag.MicrochipManufacturerId = new SelectList(db.Medications.Where(e => e.isMicrochipManufacturer).OrderBy(e => e.Name), "id", "name", dogVetting.MicrochipManufacturerId); return(View(dogVetting)); }
public static void Initialize(AppDbContext context) { context.Database.EnsureCreated(); // Look for any students. if (context.ExpenseEntries.Any()) { return; // DB has been seeded } var ExpenseEntries = new ExpenseEntry[] { new ExpenseEntry { Id = 1, Description = "test", IsExpense = true, Value = 0.98 } }; context.ExpenseEntries.AddRange(ExpenseEntries); context.SaveChanges(); }
public void AddEntry(TransactionLogEntry tl_entry) { int factor = 1; switch (tl_entry.factor) { case "K": factor = 1000; break; case "M": factor = 1000000; break; case "B": factor = 1000000000; break; } ExpenseEntry entry = new ExpenseEntry { month = tl_entry.month, reason = tl_entry.reason, amount = Convert.ToInt32(tl_entry.amount) * factor }; expenses.Add(entry); }
public ActionResult CatEdit(CatVetting catVetting) { if (ModelState.IsValid) { if (catVetting.TempVettingDecimal != 0) { var eE = new ExpenseEntry(); catVetting.Animal = db.Animals.Find(catVetting.AnimalId); eE.VetBillsDecimal = catVetting.TempVettingDecimal; eE.VetBillsComment = catVetting.Animal.name + " - " + catVetting.ReasonForVisit; eE.AccountTypeID = 0; eE.EffectiveDate = (catVetting.VetDiagnosisDate == null) ? DateTime.Today : catVetting.VetDiagnosisDate; catVetting.VettingTotalDecimal += catVetting.TempVettingDecimal; catVetting.Animal.VettingTotalDecimal = catVetting.VettingTotalDecimal; db.ExpenseEntries.Add(eE); db.SaveChanges(); } db.Entry(catVetting).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("CatIndex")); } ViewBag.AnimalId = new SelectList(db.Animals.Where(e => e.AnimalTypeID == 0).Where(e => e.Adopted == false), "id", "Name", catVetting.AnimalId); ViewBag.DewormerLocationId = new SelectList(db.Locations, "id", "name", catVetting.DewormerLocationId); ViewBag.FleaTickLocationId = new SelectList(db.Locations, "id", "name", catVetting.FleaTickLocationId); ViewBag.FVRCP1LocationId = new SelectList(db.Locations, "id", "name", catVetting.FVRCP1LocationId); ViewBag.FVRCP2LocationId = new SelectList(db.Locations, "id", "name", catVetting.FVRCP2LocationId); ViewBag.FVRCP3LocationId = new SelectList(db.Locations, "id", "name", catVetting.FVRCP3LocationId); ViewBag.MicrochipLocationId = new SelectList(db.Locations, "id", "name", catVetting.MicrochipLocationId); ViewBag.RabiesLocationId = new SelectList(db.Locations, "id", "name", catVetting.RabiesLocationId); ViewBag.SterilizationLocationId = new SelectList(db.Locations, "id", "name", catVetting.SterilizationLocationId); ViewBag.MicrochipManufacturerId = new SelectList(db.Medications.Where(e => e.isMicrochipManufacturer).OrderBy(e => e.Name), "id", "name", catVetting.MicrochipManufacturerId); return(View(catVetting)); }
public void OnEditClick(object sender, EventArgs e) { try { ExpenseEntry deleteID = null; if (sender is MenuItem) { deleteID = (ExpenseEntry)((sender as Button).CommandParameter); } else if (sender is Button) { deleteID = (ExpenseEntry)((sender as Button).CommandParameter); } Navigation.PushAsync(new AddItem(deleteID, null) { Title = "Edit " + deleteID.AccountName + " Account" }); focusFlag = true; } catch (Exception ex) { DependencyService.Get <IToast>().Show(ex.Message); } }
public void Insert(int Timesheetid,DateTime Expensedate,double Cost,string Expensedesc,bool IsDeleted,DateTime? CreatedOn,string CreatedBy,DateTime? ModifiedOn,string ModifiedBy) { ExpenseEntry item = new ExpenseEntry(); item.Timesheetid = Timesheetid; item.Expensedate = Expensedate; item.Cost = Cost; item.Expensedesc = Expensedesc; item.IsDeleted = IsDeleted; item.CreatedOn = CreatedOn; item.CreatedBy = CreatedBy; item.ModifiedOn = ModifiedOn; item.ModifiedBy = ModifiedBy; item.Save(UserName); }
public HttpResponseMessage Get() { return(Request.CreateResponse(HttpStatusCode.OK, ExpenseEntry.GetDetails())); }
public AmazonExpenseEntry(string plainTextEmail) : base(plainTextEmail) { var expenseEntryRegex = @"(.*\r\n.*)\r\n*\s*Sold by"; var matches = Regex.Matches(EmailBody, expenseEntryRegex); var NominalOrderTotalMatches = Regex.Matches(EmailBody, @"Item Subtotal\:\s\$(\d*\.\d*)"); if (NominalOrderTotalMatches.Count == 0) { NominalOrderTotalMatches = Regex.Matches(EmailBody, @"Order Total\:\s\$(\d*\.\d*)"); } var NominalOrderTotalMatchStrings = from Match item in NominalOrderTotalMatches select item.Groups[1].Value; foreach (var item in NominalOrderTotalMatchStrings) { double.TryParse(item, out var output); NominalOrderTotal += output; } // NominalOrderTotal = MatchNumber(@"Item Subtotal\:\s\$(\d*\.\d*)", 1); ReceiverName = MatchRegex(@"Your order will be sent to:\r\n([^\r\n]*)", 1).Trim(); var orderIDmatches = Regex.Matches(EmailBody, @"Order #([\d\-]*)"); var matchStrings = from Match item in matches select item.Groups[1].Value; var orderIDs = (from Match item in orderIDmatches select item.Groups[1].Value).Distinct().ToList(); int i = 0; foreach (var item in matchStrings) { var expenseEntry = new ExpenseEntry(); if (i < orderIDs.Count) { expenseEntry.orderID = orderIDs[i]; } else { expenseEntry.orderID = orderIDs.Last() + "-" + i.ToString(); } ++i; var hasQuantityRegex = Regex.Match(item.Trim(), @"^(\d+)\sx\s(.*)"); if (hasQuantityRegex.Success) { int quantity; int.TryParse(hasQuantityRegex.Groups[1].Value, out quantity); expenseEntry.Quantity = quantity; expenseEntry.Name = hasQuantityRegex.Groups[2].Value.Trim(); } else { expenseEntry.Name = common.MatchRegex(item, @"(.*)\r\n\s*\$", 1).Trim(); } double cost; double.TryParse(common.MatchRegex(item, @"\$(\d*\.\d*)", 1), out cost); expenseEntry.CostPerItem = cost; expenseEntries.Add(expenseEntry); } }