private void FillBillingGrid() { EventBill bill = calendarEvent.EventBills.FirstOrDefault(); if (bill == null) { return; } billingDataGridView.Rows.Clear(); foreach (var item in bill.EventBillItems) { int rowIndex = billingDataGridView.Rows.Add(new object[] { item.Name, item.Count.ToString("0 ks"), item.Discount.ToString("0.00 €"), item.UnitPrice.ToString("0.00 €") }); } int lastRowIndex = billingDataGridView.Rows.Add(new object[] { "Spolu:", bill.EventBillItems.Sum(x => x.Count).ToString("0 ks"), "Cena so zľavou:", bill.EventBillItems.Sum(x => x.Count * x.UnitPrice - x.Discount).ToString("0.00 €") }); billingDataGridView.Rows[lastRowIndex].DefaultCellStyle.ForeColor = Color.White; billingDataGridView.Rows[lastRowIndex].DefaultCellStyle.BackColor = Color.Black; billingDataGridView.Rows[lastRowIndex].Cells["Price"].Style.ForeColor = Colors.FlatButtonColorGreen; billingDataGridView.Rows[lastRowIndex].Cells["Discount"].Style.ForeColor = Colors.FlatButtonColorOrange; }
public ActionResult DeleteConfirmed(int id) { EventBill eventBill = db.EventBills.Find(id); db.EventBills.Remove(eventBill); db.SaveChanges(); return(RedirectToAction("Index")); }
public bool CreatePdf() { bool result = true; try { if (calendarEvent == null) { result = false; } else { PdfDocument.Open(); Chapter chapter = AddChapter(new Paragraph(GetTitleText("Záznam o návšteve")) { SpacingAfter = 10f, Alignment = HAlingmentLeft }, 0, 0); iTextSharp.text.Section firstSection = AddSection(chapter, 0f, new Paragraph(GetSectionText(calendarEvent.Patient.FullName + " " + calendarEvent.StartDate.ToString("d. MMMM yyyy, HH:mm"))) , 0); firstSection.Add(CreateInfoTable()); iTextSharp.text.Section actionsSection = AddSection(chapter, 0f, new Paragraph(GetSectionText("Vykonané")), 0); if (!string.IsNullOrEmpty(calendarEvent.ExecutedActionText)) { actionsSection.Add(new Paragraph(GetText(calendarEvent.ExecutedActionText))); } actionsSection.Add(CreateActionsTable()); iTextSharp.text.Section billingSection = AddSection(chapter, 0f, new Paragraph(GetSectionText("Vyúčtovanie")), 0); EventBill eventBill = calendarEvent.EventBills.FirstOrDefault(); if (eventBill != null && eventBill.EventBillItems.Count != 0) { billingSection.Add(CreateBillingTable(eventBill)); } else { billingSection.Add(new Paragraph(GetBoldText("Návšteva neobsahuje žiadne účtovné položky"))); } PdfDocument.Add(chapter); AddFooter(); PdfDocument.Close(); } } catch (Exception ex) { BasicMessagesHandler.LogException(ex); result = false; } return(result); }
public ActionResult Edit([Bind(Include = "EventBillID,ClientOrderID,TotalBill,Discount,Advance,NetBill")] EventBill eventBill) { if (ModelState.IsValid) { db.Entry(eventBill).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ClientOrderID = new SelectList(db.ClientOrders, "ClientOrderID", "ClientOrderKey", eventBill.ClientOrderID); return(View(eventBill)); }
// GET: EventBill/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EventBill eventBill = db.EventBills.Find(id); if (eventBill == null) { return(HttpNotFound()); } return(View(eventBill)); }
// GET: EventBill/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EventBill eventBill = db.EventBills.Find(id); if (eventBill == null) { return(HttpNotFound()); } ViewBag.ClientOrderID = new SelectList(db.ClientOrders, "ClientOrderID", "ClientOrderKey", eventBill.ClientOrderID); return(View(eventBill)); }
public JsonResult Create(ClientOrderViewModel vm) { ViewBag.CityID = new SelectList(db.Cities, "CityID", "CityName"); ViewBag.ClientID = new SelectList(db.Clients, "ClientID", "Name"); ViewBag.EventSubTypeID = new SelectList(db.EventSubTypes, "EventSubTypeID", "EventSubTypeName"); ViewBag.EventTypeID = new SelectList(db.EventTypes, "EventTypeID", "EventTypeName"); ViewBag.VenueID = new SelectList(db.Venues, "VenueID", "VenueName"); ViewBag.ServiceID = new SelectList(db.Services, "ServiceID", "ServiceName"); ViewBag.ServiceProviderID = new SelectList(db.ServiceProviders, "ServiceProviderID", "ServiceProviderName"); bool status = false; if (ModelState.IsValid) { EventServices evs = new EventServices(); ClientOrder co = new ClientOrder(); co.ClientID = vm.ClientID; co.CityID = vm.CityID; co.EventTypeID = vm.EventTypeID; co.EventSubTypeID = vm.EventSubTypeID; co.EventName = vm.EventName; co.EventStartDate = vm.EventStartDate; co.EventEndDate = vm.EventEndDate; co.NoOfGuest = vm.NoOfGuest; if (vm.VenueID != 0) { co.VenueID = Convert.ToInt32(vm.VenueID); } co.SpecialInstruction = vm.SpecialInstruction; co.Date = DateTime.Now.Date; db.ClientOrders.Add(co); db.SaveChanges(); int latestCoId = co.ClientOrderID; if (vm.VenueID != 0) { evs.ClientOrderID = latestCoId; evs.ServiceID = 9; evs.Price = Convert.ToDouble(db.Venues.Where(e => e.VenueID == vm.VenueID).Select(rent => rent.Rent).FirstOrDefault()); db.EventServicess.Add(evs); db.SaveChanges(); } EventSchedule es = new EventSchedule(); es.EventName = vm.EventName; es.EventStartDate = vm.EventStartDate; es.EventEndDate = vm.EventEndDate; es.VenueID = Convert.ToInt32(vm.VenueID); db.EventSchedules.Add(es); db.SaveChanges(); if (vm.PgCategory != null) { EventsPhotography ep = new EventsPhotography(); ep.Category = Convert.ToInt32(vm.PgCategory); ep.NumberOfTeam = Convert.ToInt32(vm.PgNumberOfTeam); ep.Price = Convert.ToDouble(vm.PgPrice); ep.ClientOrderID = latestCoId; db.EventsPhotographies.Add(ep); db.SaveChanges(); evs.ClientOrderID = latestCoId; evs.ServiceID = 7; evs.Price = Convert.ToDouble(vm.PgPrice); db.EventServicess.Add(evs); db.SaveChanges(); } if (vm.EventsDecorations != null) { foreach (var item in vm.EventsDecorations) { EventsDecoration evDec = new EventsDecoration(); evDec.ClientOrderID = latestCoId; evDec.DecorationTypeID = item.DecorationTypeID; if (item.DecorationImageID != null) { evDec.DecorationImageID = item.DecorationImageID; } if (item.CustomImage != null) { evDec.CustomImage = item.CustomImage; } evDec.Price = item.Price; db.EventsDecorations.Add(evDec); } evs.ClientOrderID = latestCoId; evs.ServiceID = 6; evs.Price = Convert.ToDouble(vm.TotalDecCost); db.SaveChanges(); } if (vm.EventsCaterings != null) { foreach (var item in vm.EventsCaterings) { EventsCatering ecate = new EventsCatering(); ecate.ClientOrderID = latestCoId; ecate.MealType = item.MealType; ecate.FoodItems = item.FoodItems; ecate.PerPersonCost = item.PerPersonCost; ecate.TotalCost = item.PerPersonCost * vm.NoOfGuest; db.EventsCaterings.Add(ecate); } evs.ClientOrderID = latestCoId; evs.ServiceID = 5; evs.Price = Convert.ToDouble(vm.TotalCateCost * vm.NoOfGuest); db.SaveChanges(); } if (vm.EventServicess != null) { foreach (var i in vm.EventServicess) { EventServices eser = new EventServices(); eser.ClientOrderID = latestCoId; eser.ServiceID = i.ServiceID; eser.Price = i.Price; db.EventServicess.Add(eser); } db.SaveChanges(); } var subTotal = db.EventServicess.Where(e => e.ClientOrderID == latestCoId).Sum(s => s.Price); if (subTotal != 0) { EventBill ebill = new EventBill(); ebill.ClientOrderID = latestCoId; ebill.SubTotalAmount = Convert.ToDouble(subTotal); ebill.MadeBy = User.Identity.GetUserName(); ebill.vat = vm.Vat; ebill.Discount = Convert.ToInt32(vm.Discount); db.EventBills.Add(ebill); db.SaveChanges(); EventPayment epay = new EventPayment(); epay.ClientOrderID = latestCoId; epay.Total = vm.NetTotal; epay.PaidAmount = 0; db.EventPayments.Add(epay); db.SaveChanges(); } status = true; } else { status = false; } var errors = ModelState.Values.SelectMany(v => v.Errors); return(Json(status, JsonRequestBehavior.AllowGet)); }
private PdfPTable CreateBillingTable(EventBill bill) { PdfPTable table = new PdfPTable(new[] { 50f, 10f, 20f, 20f }) { HorizontalAlignment = HAlingmentLeft, SpacingBefore = 10f, SpacingAfter = 10f }; table.WidthPercentage = 100f; PdfPCell cell = GetCell(System.Drawing.Color.White, GetBoldText("Položka")); cell.UseVariableBorders = true; cell.BorderWidthBottom = 1f; cell.PaddingBottom = 4f; cell.BorderColorBottom = BaseColor.BLACK; table.AddCell(cell); cell = GetCell(System.Drawing.Color.White, GetBoldText("Počet")); cell.UseVariableBorders = true; cell.BorderWidthBottom = 1f; cell.PaddingBottom = 4f; cell.BorderColorBottom = BaseColor.BLACK; table.AddCell(cell); cell = GetCell(System.Drawing.Color.White, GetBoldText("Jedn. cena")); cell.UseVariableBorders = true; cell.BorderWidthBottom = 1f; cell.PaddingBottom = 4f; cell.BorderColorBottom = BaseColor.BLACK; table.AddCell(cell); cell = GetCell(System.Drawing.Color.White, GetBoldText("Zľava")); cell.UseVariableBorders = true; cell.BorderWidthBottom = 1f; cell.PaddingBottom = 4f; cell.BorderColorBottom = BaseColor.BLACK; table.AddCell(cell); foreach (var item in bill.EventBillItems) { AddCell(table, GetText(item.Name), System.Drawing.Color.White); AddCell(table, GetText(item.Count.ToString("0 ks")), System.Drawing.Color.White); AddCell(table, GetText(item.UnitPrice.ToString("0.00 €")), System.Drawing.Color.White); AddCell(table, GetText(item.Discount.ToString("0.00 €")), System.Drawing.Color.White); } cell = GetCell(System.Drawing.Color.White, GetBoldText("Spolu:")); cell.UseVariableBorders = true; cell.BorderWidthTop = 1f; cell.BorderColorTop = BaseColor.BLACK; table.AddCell(cell); cell = GetCell(System.Drawing.Color.White, GetBoldText(bill.EventBillItems.Sum(x => x.Count).ToString("0 ks"))); cell.UseVariableBorders = true; cell.BorderWidthTop = 1f; cell.BorderColorTop = BaseColor.BLACK; table.AddCell(cell); cell = GetCell(System.Drawing.Color.White, GetBoldText("Cena so zľavou:")); cell.UseVariableBorders = true; cell.BorderWidthTop = 1f; cell.BorderColorTop = BaseColor.BLACK; table.AddCell(cell); cell = GetCell(System.Drawing.Color.White, GetBoldText(bill.EventBillItems.Sum(x => x.UnitPrice * x.Count - x.Discount).ToString("0.00 €"))); cell.UseVariableBorders = true; cell.BorderWidthTop = 1f; cell.BorderColorTop = BaseColor.BLACK; table.AddCell(cell); return(table); }