public static List <PriceList> getPriceTicket(string s) { List <PriceList> pl = null; List <PriceList> pp = null; using (AquaparkDBDataContext db = new AquaparkDBDataContext()) { pp = (from p in db.tbl_PriceHistories where p.TicketName == s && DateTime.Today >= p.BeginDate && DateTime.Today <= p.EndDate select new PriceList { price = p.TicketPrice }).ToList(); if (pp.Count() == 0) { pl = (from r in db.tbl_PriceLists where r.Entry == s select new PriceList { price = r.Price }).ToList(); return(pl); } else { return(pp); } } }
public static bool checkPass(string p) { List <Pass> pl = null; using (AquaparkDBDataContext db = new AquaparkDBDataContext()) { var searchId = from s in db.tbl_Clients where s.PESEL == p select s.ID; pl = (from c in db.tbl_Passes where c.ID == searchId.First() select new Pass { whenEnds = c.WhenEnds }).ToList(); } if (pl.All(List => List.whenEnds >= DateTime.Today) && pl.Count() != 0) { return(true); } return(false); }
public static bool updatePriceAttraction(string na, double pa, DateTime ds, DateTime de) { if (ds > de) { DateTime tmp = ds; ds = de; de = tmp; } if (ds < DateTime.Today) { return(false); } if (pa < 0) { return(false); } using (AquaparkDBDataContext db = new AquaparkDBDataContext()) { var getid = from i in db.tbl_Attractions where i.Name == na select i.ID; var getidp = from p in db.tbl_PriceListAttractions where p.IDAttraction == getid.First() select p.ID; var testdate = from d in db.tbl_AttractionHistories where d.IDAttractionList == getidp.First() && d.EndDate >= DateTime.Today select d; foreach (var i in testdate) { if ((ds >= i.BeginDate && ds <= i.EndDate) || (de >= i.BeginDate && de <= i.EndDate) || (ds <= i.BeginDate && de >= i.EndDate)) { return(false); } } var insDate = new tbl_AttractionHistory { BeginDate = ds, EndDate = de, IDAttractionList = getidp.First(), AttractionName = na, AttractionPrice = pa }; db.tbl_AttractionHistories.InsertOnSubmit(insDate); db.SubmitChanges(); return(true); } }
public static void insRFID() { using (AquaparkDBDataContext db = new AquaparkDBDataContext()) { var nw = new tbl_RFIDWatch { Status = false }; db.tbl_RFIDWatches.InsertOnSubmit(nw); db.SubmitChanges(); } }
public static bool updateTicketPrice(string nt, double pt, DateTime ds, DateTime de) { if (ds > de) { DateTime tmp = ds; ds = de; de = tmp; } if (ds < DateTime.Today) { return(false); } if (pt < 0) { return(false); } using (AquaparkDBDataContext db = new AquaparkDBDataContext()) { var getid = from p in db.tbl_PriceLists where p.Entry == nt select p.ID; var testdate = from d in db.tbl_PriceHistories where d.IDPriceList == getid.First() && d.EndDate >= DateTime.Today select d; foreach (var i in testdate) { if ((ds >= i.BeginDate && ds <= i.EndDate) || (de >= i.BeginDate && de <= i.EndDate) || (ds <= i.BeginDate && de >= i.EndDate)) { return(false); } } var insDate = new tbl_PriceHistory { BeginDate = ds, EndDate = de, IDPriceList = getid.First(), TicketName = nt, TicketPrice = pt, }; db.tbl_PriceHistories.InsertOnSubmit(insDate); db.SubmitChanges(); return(true); } }
public static bool checkClient(string p) { bool isThere; using (AquaparkDBDataContext db = new AquaparkDBDataContext()) { var check = (from c in db.tbl_Clients where c.PESEL == p select c).Any(); isThere = check; } return(isThere); }
public static int getIdTicket(string n) { var pl = 0; using (AquaparkDBDataContext db = new AquaparkDBDataContext()) { var update = from p in db.tbl_PriceLists where p.Entry == n select p.ID; pl = update.First(); }; return(pl); }
public static List <PriceList> getEntry() { List <PriceList> pl = null; using (AquaparkDBDataContext db = new AquaparkDBDataContext()) { pl = (from r in db.tbl_PriceLists select new PriceList { entry = r.Entry }).ToList(); } return(pl); }
public static List <Attraction> getAttractionName() { List <Attraction> at = null; using (AquaparkDBDataContext db = new AquaparkDBDataContext()) { at = (from r in db.tbl_Attractions select new Attraction { name = r.Name }).ToList(); } return(at); }
public static List <Gate> getGatesID() { List <Gate> gID = null; using (AquaparkDBDataContext db = new AquaparkDBDataContext()) { gID = (from g in db.tbl_Gates select new Gate { id = g.ID }).ToList(); } return(gID); }
public static List <Visit> getInsideRFID() { List <Visit> rID = null; using (AquaparkDBDataContext db = new AquaparkDBDataContext()) { rID = (from r in db.tbl_Visits where r.StopTime == null select new Visit { idWatch = r.IDWatch }).ToList(); } return(rID); }
public static List <RFIDWatch> getAllRFIDWatchIDPass() { List <RFIDWatch> rID = null; using (AquaparkDBDataContext db = new AquaparkDBDataContext()) { rID = (from r in db.tbl_RFIDWatches where r.Status == true select new RFIDWatch { id = r.ID }).ToList(); } return(rID); }
public static void addClient(string n, string s, string p) { using (AquaparkDBDataContext db = new AquaparkDBDataContext()) { var nc = new tbl_Client { Name = n, Surname = s, PESEL = p }; db.tbl_Clients.InsertOnSubmit(nc); db.SubmitChanges(); } }
private static void reportRFIDs() { int working = 0; int notworking = 0; using (AquaparkDBDataContext db = new AquaparkDBDataContext()) { var ok = from w in db.tbl_RFIDWatches where w.Status == true select w; var notok = from w in db.tbl_RFIDWatches where w.Status == false select w; working = ok.Count(); notworking = notok.Count(); } string s1 = "Liczba zegarków gotowych do użycia:"; string s2 = working.ToString(); string s3 = "Liczba zegarków zezłomowanych:"; string s4 = notworking.ToString(); string s5 = "Suma:"; string s6 = (working + notworking).ToString(); PdfDocument document = new PdfDocument(); document.Info.Title = "Zegarki"; PdfPage page1 = document.AddPage(); XGraphics gfx = XGraphics.FromPdfPage(page1); XFont fontTitle = new XFont("Verdana", 16, XFontStyle.Bold); XFont fontContent = new XFont("Verdana", 11, XFontStyle.Regular); gfx.DrawString("STATUS ZEGARKÓW", fontTitle, XBrushes.Black, new XRect(50, 50, page1.Width, page1.Height), XStringFormats.TopLeft); gfx.DrawString(DateTime.Now.ToString(), fontContent, XBrushes.Black, new XRect(50, 80, page1.Width, page1.Height), XStringFormats.TopLeft); gfx.DrawString(s1, fontContent, XBrushes.Black, new XRect(50, 130, page1.Width, page1.Height), XStringFormats.TopLeft); gfx.DrawString(s2, fontContent, XBrushes.Black, new XRect(350, 130, page1.Width, page1.Height), XStringFormats.TopLeft); gfx.DrawString(s3, fontContent, XBrushes.Black, new XRect(50, 150, page1.Width, page1.Height), XStringFormats.TopLeft); gfx.DrawString(s4, fontContent, XBrushes.Black, new XRect(350, 150, page1.Width, page1.Height), XStringFormats.TopLeft); gfx.DrawString(s5, fontContent, XBrushes.Black, new XRect(50, 170, page1.Width, page1.Height), XStringFormats.TopLeft); gfx.DrawString(s6, fontContent, XBrushes.Black, new XRect(350, 170, page1.Width, page1.Height), XStringFormats.TopLeft); string filename = "aquapark-" + DateTime.Now.ToShortDateString() + "-status-zegarkow.pdf"; document.Save(filename); }
public static void changeStatus(int id) { using (AquaparkDBDataContext db = new AquaparkDBDataContext()) { var update = from p in db.tbl_RFIDWatches where p.ID == id select p; foreach (tbl_RFIDWatch p in update) { p.Status ^= true; } db.SubmitChanges(); } }
public static void exitAquapark(int idw, DateTime stop) { using (AquaparkDBDataContext db = new AquaparkDBDataContext()) { var update = from p in db.tbl_Visits where p.IDWatch == idw && p.StopTime == null select p; foreach (tbl_Visit p in update) { p.StopTime = stop; } db.SubmitChanges(); } }
public static List <RFIDWatch> getAllRFIDWatch() { List <RFIDWatch> rstat = null; using (AquaparkDBDataContext db = new AquaparkDBDataContext()) { rstat = (from r in db.tbl_RFIDWatches select new RFIDWatch { id = r.ID, status = r.Status }).ToList(); } return(rstat); }
public static void addVisitPass(int iw, int ip) { using (AquaparkDBDataContext db = new AquaparkDBDataContext()) { var insVis = new tbl_Visit { StartTime = DateTime.Now, StopTime = null, IDWatch = iw, IDPriceEntry = null, IDPass = ip }; db.tbl_Visits.InsertOnSubmit(insVis); db.SubmitChanges(); } }
public static List <PlannedPrices> getTicketTimePeriods(string n) { List <PlannedPrices> list = new List <PlannedPrices>(); using (AquaparkDBDataContext db = new AquaparkDBDataContext()) { var selection = (from pl in db.tbl_PriceLists join ph in db.tbl_PriceHistories on pl.ID equals ph.IDPriceList where pl.Entry == n select ph); foreach (var i in selection) { list.Add(new PlannedPrices(Convert.ToInt32(i.TicketPrice), i.BeginDate.ToShortDateString(), i.EndDate.ToShortDateString())); } } return(list); }
public static void insertGateEntering(int idg, int idw) { using (AquaparkDBDataContext db = new AquaparkDBDataContext()) { var idv = (from i in db.tbl_Visits where i.IDWatch == idw && i.StopTime == null select i.ID); var insGE = new tbl_GateHistory { Timestamp = DateTime.Now, IDGate = idg, IDVisit = idv.First() }; db.tbl_GateHistories.InsertOnSubmit(insGE); db.SubmitChanges(); } }
public static void addPass(string p) { using (AquaparkDBDataContext db = new AquaparkDBDataContext()) { var sel = from s in db.tbl_Clients where s.PESEL == p select s; var ap = new tbl_Pass { WhenEnds = DateTime.Today.AddDays(30), IDClient = sel.First().ID }; db.tbl_Passes.InsertOnSubmit(ap); db.SubmitChanges(); } }
public static List <PlannedPrices> getAttractionTimePeriods(string n) { List <PlannedPrices> list = new List <PlannedPrices>(); using (AquaparkDBDataContext db = new AquaparkDBDataContext()) { var selection = (from a in db.tbl_Attractions join pl in db.tbl_PriceListAttractions on a.ID equals pl.IDAttraction join ph in db.tbl_AttractionHistories on pl.ID equals ph.IDAttractionList orderby ph.EndDate ascending where a.Name == n select ph); foreach (var i in selection) { list.Add(new PlannedPrices(Convert.ToInt32(i.AttractionPrice), i.BeginDate.ToShortDateString(), i.EndDate.ToShortDateString())); } } return(list); }
public static int getPassID(string p) { int i = 0; using (AquaparkDBDataContext db = new AquaparkDBDataContext()) { var searchIdClient = from s in db.tbl_Clients where s.PESEL == p select s.ID; var searchIdPass = from pa in db.tbl_Passes where pa.IDClient == searchIdClient.First() select pa.ID; i = searchIdPass.First(); } return(i); }
public static int getPrice(string s) { int price = 0; using (AquaparkDBDataContext db = new AquaparkDBDataContext()) { var pr = from ph in db.tbl_PriceHistories where ph.TicketName == s && DateTime.Today >= ph.BeginDate && DateTime.Today <= ph.EndDate select ph.TicketPrice; if (pr.Count() != 0) { price = Convert.ToInt32(pr.First()); } else { var pd = from r in db.tbl_PriceLists where r.Entry == s select r.Price; price = Convert.ToInt32(pd.First()); } } return(price); }
public static int getPriceAttraction(string s) { int price = 0; using (AquaparkDBDataContext db = new AquaparkDBDataContext()) { var pr = from ah in db.tbl_AttractionHistories where ah.AttractionName == s && DateTime.Today >= ah.BeginDate && DateTime.Today <= ah.EndDate select ah.AttractionPrice; if (pr.Count() != 0) { price = Convert.ToInt32(pr.First()); } else { var pd = (from a in db.tbl_Attractions join pl in db.tbl_PriceListAttractions on a.ID equals pl.IDAttraction where a.Name == s select pl.PriceAttraction); price = Convert.ToInt32(pd.First()); } } return(price); }
private static void reportAttractionIntensity(DateTime fr, DateTime to) { if (fr > to) { var h = fr; fr = to; to = h; } List <AttractionIntensityReport> air = null; List <AttractionIntensityReport> air2 = null; using (AquaparkDBDataContext db = new AquaparkDBDataContext()) { air = (from a in db.tbl_Attractions select new AttractionIntensityReport { id = a.ID, name = a.Name }).ToList(); air2 = (from a in db.tbl_Attractions join g in db.tbl_Gates on a.ID equals g.IDAttraction join gh in db.tbl_GateHistories on g.ID equals gh.IDGate join v in db.tbl_Visits on gh.IDVisit equals v.ID where v.StartTime >= fr && v.StartTime <= to.AddDays(1) select new AttractionIntensityReport { id = a.ID }).ToList(); } foreach (var i in air) { i.quantity = air2.Count(item => item.id == i.id); } PdfDocument document = new PdfDocument(); document.Info.Title = "Popularność atrakcji"; List <PdfPage> pages = new List <PdfPage>(); pages.Add(new PdfPage()); document.AddPage(pages.Last()); XGraphics gfx = XGraphics.FromPdfPage(pages.Last()); XFont fontTitle = new XFont("Verdana", 16, XFontStyle.Bold); XFont fontHeaders = new XFont("Verdana", 13, XFontStyle.Underline); XFont fontContent = new XFont("Verdana", 11, XFontStyle.Regular); gfx.DrawString("POPULARNOŚĆ ATRAKCJI", fontTitle, XBrushes.Black, new XRect(50, 50, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); gfx.DrawString(fr.ToShortDateString() + " – " + to.ToShortDateString(), fontContent, XBrushes.Black, new XRect(50, 80, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); gfx.DrawString("Nazwa", fontHeaders, XBrushes.Black, new XRect(50, 130, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); gfx.DrawString("Liczba użyć", fontHeaders, XBrushes.Black, new XRect(300, 130, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); int d = 160; foreach (var i in air) { gfx.DrawString(i.name, fontContent, XBrushes.Black, new XRect(50, d, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); gfx.DrawString(i.quantity.ToString(), fontContent, XBrushes.Black, new XRect(300, d, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); d += 20; if (d > 760) { pages.Add(new PdfPage(document)); document.AddPage(pages.Last()); d = 50; gfx = XGraphics.FromPdfPage(pages.Last()); } } string filename = "aquapark-" + DateTime.Now.ToShortDateString() + "-popularnosc-atrakcji.pdf"; document.Save(filename); }
public static Tuple <List <object>, int> calculateCost(int idw, DateTime stop) { int overallPrice = 0; List <object> cost = new List <object>(); using (AquaparkDBDataContext db = new AquaparkDBDataContext()) { var chT = (from t in db.tbl_Visits where t.IDWatch == idw && t.StopTime == null select t.IDPriceEntry); try { bool x = chT.First() == null; } catch (InvalidOperationException) { Tuple <List <object>, int> q = new Tuple <List <object>, int>(cost, -1); return(q); } if (chT.First() == null) { cost.Add("Karnet"); } else { var ticketE = from t in db.tbl_PriceLists //to scalic i wywaalic xd albo najpierw cenah potem normalna where t.ID == chT.First() select t.Entry; var ticketH = from h in db.tbl_PriceHistories where h.IDPriceList == chT.First() && DateTime.Today >= h.BeginDate && DateTime.Today <= h.EndDate select h.TicketPrice; cost.Add(ticketE.First()); if (ticketH.Count() != 0) { overallPrice += Convert.ToInt32(ticketH.First()); } else { var ticketP = from t in db.tbl_PriceLists where t.ID == chT.First() select t.Price; overallPrice += Convert.ToInt32(ticketP.First()); } int howLong = 0; switch (Convert.ToInt32(chT.First())) { case 1: howLong = 1; break; case 2: howLong = 2; break; case 3: howLong = 3; break; case 4: howLong = 12; break; case 5: howLong = 1; break; case 6: howLong = 2; break; case 7: howLong = 3; break; case 8: howLong = 12; break; } var start = (from t in db.tbl_Visits where t.IDWatch == idw && t.StopTime == null select t.StartTime); int totalSpent = Convert.ToInt32(Math.Ceiling((stop - start.First()).Value.TotalHours)); int exceedance = totalSpent - howLong; int idc = 0; if (exceedance > 0) { switch (exceedance) { case 1: idc = 9; break; case 2: idc = 10; break; case 3: idc = 11; break; default: idc = 11; break; } } if (idc != 0) { var priceifplanned = from h in db.tbl_PriceHistories where idc == h.IDPriceList && DateTime.Today >= h.BeginDate && DateTime.Today <= h.EndDate select h; if (priceifplanned.Count() != 0) { cost.Add(priceifplanned.First().TicketName); overallPrice += Convert.ToInt32(priceifplanned.First().TicketPrice); } else { var pricepl = (from p in db.tbl_PriceLists where p.ID == idc select p); cost.Add(pricepl.First().Entry); overallPrice += Convert.ToInt32(pricepl.First().Price); } } } var atn = (from gh in db.tbl_GateHistories join vi in db.tbl_Visits on gh.IDVisit equals vi.ID join ga in db.tbl_Gates on gh.IDGate equals ga.ID join at in db.tbl_Attractions on ga.IDAttraction equals at.ID join pla in db.tbl_PriceListAttractions on at.ID equals pla.IDAttraction where vi.IDWatch == idw && vi.StopTime == null select at.Name); foreach (var i in atn) { cost.Add(i); } foreach (var i in atn) { var atpp = from h in db.tbl_AttractionHistories where i == h.AttractionName && DateTime.Today >= h.BeginDate && DateTime.Today <= h.EndDate select h.AttractionPrice; if (atpp.Count() != 0) { overallPrice += Convert.ToInt32(atpp.First()); } else { var atp = from gh in db.tbl_GateHistories join vi in db.tbl_Visits on gh.IDVisit equals vi.ID join ga in db.tbl_Gates on gh.IDGate equals ga.ID join at in db.tbl_Attractions on ga.IDAttraction equals at.ID join pla in db.tbl_PriceListAttractions on at.ID equals pla.IDAttraction where vi.IDWatch == idw && vi.StopTime == null select pla.PriceAttraction; overallPrice += Convert.ToInt32(atp.First()); } } //?? //foreach (var i in atp) overallPrice += Convert.ToInt32(i); } Tuple <List <object>, int> r = new Tuple <List <object>, int>(cost, overallPrice); return(r); }
private static void reportIncome(DateTime fr, DateTime to) { if (fr > to) { var h = fr; fr = to; to = h; } List <IncomeReport> sourcePasses = new List <IncomeReport>(); List <IncomeReport> sourceTickets = new List <IncomeReport>(); List <IncomeReport> sourceAttractions = new List <IncomeReport>(); List <IncomeReport> sourceOvertime = new List <IncomeReport>(); using (AquaparkDBDataContext db = new AquaparkDBDataContext()) { //find passes sold during the time period var pass = from p in db.tbl_Passes where p.WhenEnds >= fr.AddDays(30) && p.WhenEnds <= to.AddDays(31) select p.WhenEnds; //fill in passes with predefinded, determined values foreach (var i in pass) { sourcePasses.Add(new IncomeReport("Karnet", i.AddDays(-30).ToShortDateString(), 179)); } //find tickets sold during the time period var ticket = from t in db.tbl_PriceLists join v in db.tbl_Visits on t.ID equals v.IDPriceEntry where v.StartTime >= fr && v.StartTime <= to.AddDays(1) select new { t, v }; //find ticket prices of the time foreach (var i in ticket) { var whatprice = from h in db.tbl_PriceHistories where i.v.StartTime >= h.BeginDate && i.v.StartTime <= Convert.ToDateTime(h.EndDate).AddDays(1) && i.t.Entry == h.TicketName select h.TicketPrice; if (whatprice.Count() != 0) { sourceTickets.Add(new IncomeReport(i.t.Entry, i.v.StartTime.Value.ToShortDateString(), Convert.ToInt32(whatprice.First()))); } else { sourceTickets.Add(new IncomeReport(i.t.Entry, i.v.StartTime.Value.ToShortDateString(), -1)); } } //find default ticket prices if necessary foreach (var i in sourceTickets) { var defprice = from t in db.tbl_PriceLists where t.Entry == i.name select t.Price; if (defprice.Count() != 0) { if (i.value == -1) { i.value = Convert.ToInt32(defprice.First()); } } } //find attractions uses of the time var att = from a in db.tbl_Attractions join g in db.tbl_Gates on a.ID equals g.IDAttraction join h in db.tbl_GateHistories on g.ID equals h.IDGate join v in db.tbl_Visits on h.IDVisit equals v.ID where v.StartTime >= fr && v.StartTime <= to.AddDays(1) select new { a, g, h, v }; //find attraction prices of the time foreach (var i in att) { var whatprice = from h in db.tbl_AttractionHistories where i.v.StartTime >= h.BeginDate && i.v.StartTime <= Convert.ToDateTime(h.EndDate).AddDays(1) && i.a.Name == h.AttractionName select h.AttractionPrice; if (whatprice.Count() != 0) { sourceAttractions.Add(new IncomeReport(i.a.Name, i.v.StartTime.Value.ToShortDateString(), Convert.ToInt32(whatprice.First()))); } else { sourceAttractions.Add(new IncomeReport(i.a.Name, i.v.StartTime.Value.ToShortDateString(), -1)); } } //find default attraction prices if necessary foreach (var i in sourceAttractions) { var defprice = from a in db.tbl_Attractions join p in db.tbl_PriceListAttractions on a.ID equals p.IDAttraction where a.Name == i.name select p.PriceAttraction; if (defprice.Count() != 0) { if (i.value == -1) { i.value = Convert.ToInt32(defprice.First()); } } } //decide overtime occurrences foreach (var i in ticket) { int howLong = 0; switch (i.t.ID) { case 1: howLong = 1; break; case 2: howLong = 2; break; case 3: howLong = 3; break; case 4: howLong = 12; break; case 5: howLong = 1; break; case 6: howLong = 2; break; case 7: howLong = 3; break; case 8: howLong = 12; break; } int realTime = Convert.ToInt32(Math.Ceiling((i.v.StopTime - i.v.StartTime).Value.TotalHours)); int exceedance = (realTime - howLong); int idc = 0; if (exceedance > 0) { switch (exceedance) { case 1: idc = 9; break; case 2: idc = 10; break; case 3: idc = 11; break; default: idc = 11; break; } //find overtime prices of the time var whatprice = from h in db.tbl_PriceHistories where i.v.StopTime >= h.BeginDate && i.v.StopTime <= Convert.ToDateTime(h.EndDate).AddDays(1) && h.IDPriceList == idc select h; if (whatprice.Count() != 0) { sourceOvertime.Add(new IncomeReport(whatprice.First().TicketName, i.v.StopTime.Value.ToShortDateString(), Convert.ToInt32(whatprice.First().TicketPrice))); } else { var getName = from t in db.tbl_PriceLists where t.ID == idc select t.Entry; sourceOvertime.Add(new IncomeReport(getName.First().ToString(), i.v.StopTime.Value.ToShortDateString(), -1)); } } } //find default overtime prices if necessary foreach (var i in sourceOvertime) { var defprice = from t in db.tbl_PriceLists where t.Entry == i.name select t.Price; if (defprice.Count() != 0) { if (i.value == -1) { i.value = Convert.ToInt32(defprice.First()); } } } } //merge sources lists List <IncomeReport> sourcesNoOrder = sourcePasses.Concat(sourceTickets).Concat(sourceAttractions).Concat(sourceOvertime).ToList(); List <IncomeReport> sources = sourcesNoOrder.OrderBy(item => item.date).ToList(); int sum = 0; foreach (var i in sources) { sum += i.value; } PdfDocument document = new PdfDocument(); document.Info.Title = "Przychody"; List <PdfPage> pages = new List <PdfPage>(); pages.Add(new PdfPage()); document.AddPage(pages.Last()); XGraphics gfx = XGraphics.FromPdfPage(pages.Last()); XFont fontTitle = new XFont("Verdana", 16, XFontStyle.Bold); XFont fontHeaders = new XFont("Verdana", 13, XFontStyle.Underline); XFont fontContent = new XFont("Verdana", 11, XFontStyle.Regular); XFont fontSummary = new XFont("Verdana", 11, XFontStyle.Bold); gfx.DrawString("PRZYCHODY", fontTitle, XBrushes.Black, new XRect(50, 50, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); gfx.DrawString(fr.ToShortDateString() + " – " + to.ToShortDateString(), fontContent, XBrushes.Black, new XRect(50, 80, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); gfx.DrawString("Źródło", fontHeaders, XBrushes.Black, new XRect(50, 130, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); gfx.DrawString("Data", fontHeaders, XBrushes.Black, new XRect(280, 130, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); gfx.DrawString("Wpływ", fontHeaders, XBrushes.Black, new XRect(430, 130, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); int d = 160; foreach (var i in sources) { gfx.DrawString(i.name, fontContent, XBrushes.Black, new XRect(50, d, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); gfx.DrawString(i.date, fontContent, XBrushes.Black, new XRect(280, d, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); gfx.DrawString(i.value.ToString(), fontContent, XBrushes.Black, new XRect(430, d, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); d += 20; if (d > 760) { pages.Add(new PdfPage(document)); document.AddPage(pages.Last()); d = 50; gfx = XGraphics.FromPdfPage(pages.Last()); } } gfx.DrawString("Suma", fontSummary, XBrushes.Black, new XRect(50, d, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); gfx.DrawString(sum.ToString(), fontSummary, XBrushes.Black, new XRect(430, d, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); string filename = "aquapark-" + DateTime.Now.ToShortDateString() + "-przychody.pdf"; document.Save(filename); }
private static void reportPassHolders() { List <Client> cl = null; List <List <Pass> > ps = new List <List <Pass> >(); using (AquaparkDBDataContext db = new AquaparkDBDataContext()) { cl = (from c in db.tbl_Clients select new Client { id = c.ID, name = c.Name, surname = c.Surname }).ToList(); foreach (var i in cl) { var pp = (from p in db.tbl_Passes where p.IDClient == i.id select new Pass { id = p.ID, whenEnds = p.WhenEnds, clientid = p.IDClient }).ToList(); ps.Add(pp); } } PdfDocument document = new PdfDocument(); document.Info.Title = "Karnetowicze"; List <PdfPage> pages = new List <PdfPage>(); pages.Add(new PdfPage()); document.AddPage(pages.Last()); XGraphics gfx = XGraphics.FromPdfPage(pages.Last()); XFont fontTitle = new XFont("Verdana", 16, XFontStyle.Bold); XFont fontHeaders = new XFont("Verdana", 13, XFontStyle.Underline); XFont fontContent = new XFont("Verdana", 11, XFontStyle.Regular); gfx.DrawString("ZESTAWIENIE KARNETOWICZÓW", fontTitle, XBrushes.Black, new XRect(50, 50, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); gfx.DrawString(DateTime.Now.ToShortDateString(), fontContent, XBrushes.Black, new XRect(50, 80, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); gfx.DrawString("ID klienta", fontHeaders, XBrushes.Black, new XRect(50, 130, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); gfx.DrawString("Imię", fontHeaders, XBrushes.Black, new XRect(140, 130, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); gfx.DrawString("Nazwisko", fontHeaders, XBrushes.Black, new XRect(230, 130, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); gfx.DrawString("ID karnetu", fontHeaders, XBrushes.Black, new XRect(340, 130, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); gfx.DrawString("Karnet do", fontHeaders, XBrushes.Black, new XRect(430, 130, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); int d = 160; for (int i = 0; i < cl.Count(); i++) { gfx.DrawString(cl[i].id.ToString(), fontContent, XBrushes.Black, new XRect(50, d, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); gfx.DrawString(cl[i].name.ToString(), fontContent, XBrushes.Black, new XRect(140, d, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); gfx.DrawString(cl[i].surname.ToString(), fontContent, XBrushes.Black, new XRect(230, d, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); foreach (var j in ps[i]) { gfx.DrawString(j.id.ToString(), fontContent, XBrushes.Black, new XRect(340, d, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); gfx.DrawString(j.whenEnds.ToString("dd/MM/yyyy"), fontContent, XBrushes.Black, new XRect(430, d, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); d += 20; if (d > 760) { pages.Add(new PdfPage(document)); document.AddPage(pages.Last()); d = 50; gfx = XGraphics.FromPdfPage(pages.Last()); } } if (ps[i].Count() == 0) { d += 20; } } string filename = "aquapark-" + DateTime.Now.ToShortDateString() + "-zestawienie-karnetowiczow.pdf"; document.Save(filename); }
private static void reportVisits(DateTime fr, DateTime to) { if (fr > to) { var h = fr; fr = to; to = h; } List <VisitReport> vr = null; using (AquaparkDBDataContext db = new AquaparkDBDataContext()) { vr = (from v in db.tbl_Visits join p in db.tbl_PriceLists on v.IDPriceEntry equals p.ID into ps from p in ps.DefaultIfEmpty() where v.StartTime >= fr && v.StartTime <= to.AddDays(1) select new VisitReport { enter = v.StartTime.ToString(), exit = v.StopTime.ToString(), ticketType = p.Entry, watchID = v.IDWatch }).ToList(); } foreach (var i in vr) { if (i.ticketType == null) { i.ticketType = "Karnet"; } } PdfDocument document = new PdfDocument(); document.Info.Title = "Odwiedziny"; List <PdfPage> pages = new List <PdfPage>(); pages.Add(new PdfPage()); document.AddPage(pages.Last()); XGraphics gfx = XGraphics.FromPdfPage(pages.Last()); XFont fontTitle = new XFont("Verdana", 16, XFontStyle.Bold); XFont fontHeaders = new XFont("Verdana", 13, XFontStyle.Underline); XFont fontContent = new XFont("Verdana", 11, XFontStyle.Regular); gfx.DrawString("ZESTAWIENIE WIZYT", fontTitle, XBrushes.Black, new XRect(50, 50, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); gfx.DrawString(fr.ToShortDateString() + " – " + to.ToShortDateString(), fontContent, XBrushes.Black, new XRect(50, 80, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); gfx.DrawString("Wejście", fontHeaders, XBrushes.Black, new XRect(50, 130, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); gfx.DrawString("Wyjście", fontHeaders, XBrushes.Black, new XRect(200, 130, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); gfx.DrawString("Rodzaj biletu", fontHeaders, XBrushes.Black, new XRect(350, 130, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); //gfx.DrawString("ID zegarka", fontHeaders, XBrushes.Black, new XRect(490, 130, page1.Width, page1.Height), XStringFormats.TopLeft); int d = 160; foreach (var i in vr) { gfx.DrawString(i.enter, fontContent, XBrushes.Black, new XRect(50, d, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); if (i.exit != null) { gfx.DrawString(i.exit, fontContent, XBrushes.Black, new XRect(200, d, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); } else { gfx.DrawString("", fontContent, XBrushes.Black, new XRect(200, d, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); } gfx.DrawString(i.ticketType, fontContent, XBrushes.Black, new XRect(350, d, pages.Last().Width, pages.Last().Height), XStringFormats.TopLeft); //gfx.DrawString(i.watchID.ToString(), fontContent, XBrushes.Black, new XRect(490, d, page1.Width, page1.Height), XStringFormats.TopLeft); d += 20; if (d > 760) { pages.Add(new PdfPage(document)); document.AddPage(pages.Last()); d = 50; gfx = XGraphics.FromPdfPage(pages.Last()); } } string filename = "aquapark-" + DateTime.Now.ToShortDateString() + "-zestawienie-wizyt.pdf"; document.Save(filename); }