public List <Invoice> returnInvoiceListOrderByInvoiceNumber() { List <Invoice> lst = new InvoiceDataSource().returnInvoiceList(); List <Invoice> SortedList = lst.OrderBy(o => o.InvoiceNumber).ToList(); return(SortedList); }
public itemListTuple <double, DateTime> getDayRangeRecord(string startDay, string endDay) { double amt = 0; DateTime currentDay; DateTime dayStart = (Convert.ToDateTime(startDay.ToString())); DateTime dayLimit = (Convert.ToDateTime(endDay.ToString())); itemListTuple <double, DateTime> tempTuple = new itemListTuple <double, DateTime>(); List <Invoice> tempInvoiceList = new InvoiceDataSource().returnInvoiceList(); currentDay = dayStart; foreach (Invoice inv in tempInvoiceList) { DateTime invoiceDate = (Convert.ToDateTime(inv.Date)); if (invoiceDate > dayLimit) { break; } else if (invoiceDate == currentDay) { amt += inv.SalesAmount; } else if (invoiceDate > currentDay) { tempTuple.Add(amt, currentDay); currentDay = currentDay.AddDays(1); } } return(tempTuple); }
public List <Invoice> returnInvoiceListOrderByStaffName() { List <Invoice> lst = new InvoiceDataSource().returnInvoiceList(); List <Invoice> SortedList = lst.OrderBy(o => o.Admin).ToList(); return(SortedList); }
public itemListTuple <double, string> getMonthlyRecord(string startDay) { Console.WriteLine("Date from function parameter : {0}", startDay); double[] arr = new double[30]; int arrIndex = 0; string date = startDay; DateTime datevalue = (Convert.ToDateTime(date.ToString())); Console.WriteLine("Date from function parameter after conversion to date time : {0}", datevalue); String dy = datevalue.Day.ToString(); DateTime dayStart = datevalue; DateTime dayLimit = datevalue.AddDays(30); Console.WriteLine("Start day : {0}", dayStart); Console.WriteLine("End day : {0}", dayLimit); itemListTuple <double, string> tempTuple = new itemListTuple <double, string>(); List <Invoice> tempInvoiceList = new InvoiceDataSource().returnInvoiceList(); foreach (Invoice inv in tempInvoiceList) { DateTime cdate = (Convert.ToDateTime(inv.Date.ToString())); if (cdate > dayLimit) { break; } else if ((cdate.Day - dayStart.Day) > arrIndex) { arrIndex++; } else if ((cdate.Day - dayStart.Day) == arrIndex) { arr[arrIndex] += inv.SalesAmount; Console.WriteLine("array element new size : {0}", arr[arrIndex]); } } for (int i = 0; i < 30; i++) { tempTuple.Add(arr[i], "Day : " + (i + 1)); } return(tempTuple); }
public itemListTuple <double, string> getOneDayRecord(string day) { itemListTuple <double, string> tempTuple = new itemListTuple <double, string>(); List <Invoice> tempInvoiceList = new InvoiceDataSource().returnInvoiceList(); foreach (Invoice inv in tempInvoiceList) { if (inv.Date.Equals(day, StringComparison.OrdinalIgnoreCase)) { tempTuple.Add(inv.SalesAmount, inv.Admin); } } return(tempTuple); }
public void calculateLargestTransactionNumber() { //Step 1 : Fetch the list InvoiceDataSource ids = new InvoiceDataSource(); List <Invoice> tempList = ids.returnInvoiceList(); //Step 2 : Iterate through the list and record the largest number foreach (Invoice inv in tempList) { if (inv.InvoiceNumber > largestInvoicNumber) { largestInvoicNumber = inv.InvoiceNumber; } } //Step 3 : end of iteration. set the max value to max found value //Done }
public itemListTuple <double, string> getWeeklyRecord(string startDay) { double[] arr = new double[7]; int arrIndex = 0; string date = startDay; DateTime datevalue = (Convert.ToDateTime(date.ToString())); String dy = datevalue.Day.ToString(); DateTime dayStart = datevalue; DateTime dayLimit = datevalue.AddDays(7); itemListTuple <double, string> tempTuple = new itemListTuple <double, string>(); List <Invoice> tempInvoiceList = new InvoiceDataSource().returnInvoiceList(); foreach (Invoice inv in tempInvoiceList) { DateTime cdate = (Convert.ToDateTime(inv.Date.ToString())); if (cdate > dayLimit) { break; } else if ((cdate.Day - dayStart.Day) > arrIndex) { arrIndex++; } else if ((cdate.Day - dayStart.Day) == arrIndex) { arr[arrIndex] += inv.SalesAmount; } } for (int i = 0; i < 7; i++) { Console.WriteLine("Adding to tuple : {0} ", arr[i]); tempTuple.Add(arr[i], "Day : " + (i + 1)); } return(tempTuple); }
/* * PDF generation code starts here */ public uint generateInvoice(double vat, double totalprice, string date, string time, string admin, string paid, string moneyreturn) { Document myDocument = new Document(PageSize.LETTER, 10, 10, 42, 35); InvoiceFactory ifc = new InvoiceFactory(); uint invNumber = ifc.makeNewTransactionNumber(); Invoice inv = new Invoice(); try { // step 2: // Now create a writer that listens to this doucment and writes the document to desired Stream. string documentPath = @"C:\\Users\\ahmed\\Desktop\\PDF\\"; string filename = invNumber + ".pdf"; string documentFullPath = documentPath + filename; string invPath = "C:\\Users\\ahmed\\Desktop\\PDF\\"; string path = invPath + invNumber + ".pdf"; inv.InvoiceNumber = invNumber; inv.Date = date; inv.SalesAmount = totalprice; inv.Admin = admin; inv.Path = invPath; PdfWriter.GetInstance(myDocument, new FileStream(documentFullPath, FileMode.Create)); // step 3: Open the document now using myDocument.Open(); // step 4: Now add some contents to the document //myDocument.Add(new Paragraph(" time: ")); //myDocument.Add(new Paragraph(" Welcome ")); myDocument.Add(new Paragraph(" Weapon Centralized Sales Automation ")); myDocument.Add(new Paragraph(" Nikunjo-2 ")); myDocument.Add(new Paragraph(" Road : 11 ")); myDocument.Add(new Paragraph(" House : 2A ")); myDocument.Add(new Paragraph(" Contact Number : " + "012863772" + " ")); myDocument.Add(new Paragraph("Invoice Number = " + invNumber + " Date :" + date)); myDocument.Add(new Paragraph(" Time :" + time)); myDocument.Add(new Paragraph(" ")); myDocument.Add(new Paragraph(" ")); myDocument.Add(new Paragraph(" ")); PdfPTable table = new PdfPTable(3); table.AddCell("Name"); table.AddCell("Quantity"); table.AddCell("Total Price"); //myDocument.Add(table); PdfPTable table2 = new PdfPTable(3); foreach (Product P in purchaseList) { table.AddCell(new Phrase(P.ProductName)); table.AddCell(new Phrase(P.Quantity.ToString())); table.AddCell(new Phrase(P.Price.ToString())); table2 = table; } myDocument.Add(table2); //table.AddCell(" "); //table.AddCell(" "); //table.AddCell("Vat :"+vat); //table.AddCell(" "); //table.AddCell(" "); //table.AddCell("Total Cost :" + totalCost); //table.AddCell(" "); //table.AddCell(" "); //table.AddCell("Paid :" + paid); //table.AddCell(" "); //table.AddCell(" "); //table.AddCell("Cash Return :" + moneyreturn); //myDocument.Add(table); myDocument.Add(new Paragraph(" VAT : " + vat + "%")); myDocument.Add(new Paragraph(" total cost : " + totalCost)); myDocument.Add(new Paragraph(" Cash Paid : " + paid)); myDocument.Add(new Paragraph(" cash return : " + moneyreturn)); myDocument.Add(new Paragraph("Cashair : " + admin + "")); myDocument.Add(new Paragraph(" ")); myDocument.Add(new Paragraph(" ")); myDocument.Add(new Paragraph(" ")); myDocument.Add(new Paragraph(" ")); myDocument.Add(new Paragraph(" ")); myDocument.Add(new Paragraph(" ")); myDocument.Add(new Paragraph(" Thank you For Your Visit ")); myDocument.Add(new Paragraph(" Have A Nice Day ")); } catch (DocumentException de) { Console.Error.WriteLine(de.Message); } catch (IOException ioe) { Console.Error.WriteLine(ioe.Message); } // step 5: Remember to close the documnet myDocument.Close(); InvoiceDataSource ids = new InvoiceDataSource(); ids.AddInvoiceNumber(inv); return(invNumber); }