public InvoiceSummaryReportVM() { CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); try { var data = _serviceInstance.GetDAIAddressName(userCode).Select(d => new InvoiceSummaryReport { CompanyName = d.CompanyName, AddressLine1 = d.AddressLine1, City = d.City, Phone = d.Phone }).FirstOrDefault(); CompanyName = data.CompanyName; AddressLine1 = data.AddressLine1; City = data.City; Phone = data.Phone; // get data and create report here var report = new InvoiceSummaryRPT(); var data1 = _serviceInstance.LoadInvoiceList(0, StartDate, EndDate).Select(d => new InvoiceSummaryReport { InvoiceNumber = d.InvoiceNumber, InvoiceAmount = d.InvoiceAmount, InvoiceDate = d.InvoiceDate, Units = d.Units, CustomerName = d.CustomerName, CompanyName = CompanyName, AddressLine1 = AddressLine1, City = City, Phone = Phone, StartDate = StartDate, EndDate = EndDate, }).ToList(); double totalInvoiceAmount = 0; int totalUnits = 0; if (data1 != null) { data1.Add(new InvoiceSummaryReport { InvoiceNumber = null, InvoiceAmount = totalInvoiceAmount, InvoiceDate = null, Units = totalUnits, CustomerName = null, CompanyName = CompanyName, AddressLine1 = AddressLine1, City = City, Phone = Phone, StartDate = StartDate, EndDate = EndDate }); } report.DataSource = data1; //MyReportSource = report; } catch (Exception ex) { LogHelper.LogErrorToDb(ex); bool displayErrorOnUI = false; CommonSettings.logger.LogError(this.GetType(), ex); if (displayErrorOnUI) { throw; } } finally { CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } }
/// <summary> /// This function is used to search report according to date /// </summary> /// <param name="obj"></param> public void Search(object obj) { CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); try { if (StartDate != null && EndDate != null) { if (StartDate <= EndDate) { // get data and create report here var report = new InvoiceSummaryRPT(); var data = _serviceInstance.LoadInvoiceList(0, StartDate, EndDate).Select(d => new InvoiceSummaryReport { InvoiceNumber = d.InvoiceNumber, InvoiceAmount = d.InvoiceAmount, InvoiceDate = d.InvoiceDate, CustomerNumber = d.CustomerNumber, Units = d.Units, CustomerName = d.CustomerName, CompanyName = CompanyName, AddressLine1 = AddressLine1, City = City, Phone = Phone, StartDate = StartDate, EndDate = EndDate, }).ToList(); //double totalInvoiceAmount = 0; //int totalUnits = 0; if (data != null) { //totalInvoiceAmount = data.Sum(x => x.InvoiceAmount); //totalUnits = data.Sum(x => (int)x.Units); //data.Add(new InvoiceSummaryReport //{ // InvoiceNumber = "Total:", // InvoiceAmount = totalInvoiceAmount, // InvoiceDate = null, // Units = totalUnits, // CustomerName = null, // CompanyName = CompanyName, // AddressLine1 = AddressLine1, // City = City, // Phone = Phone, // StartDate = StartDate, // EndDate = EndDate, //}); } report.DataSource = data; MyReportSource = report; } else { MessageBox.Show(Resources.msgDateCompair); return; } } else { MessageBox.Show(Resources.msgDateReq); } } catch (Exception ex) { LogHelper.LogErrorToDb(ex); bool displayErrorOnUI = false; CommonSettings.logger.LogError(this.GetType(), ex); if (displayErrorOnUI) { throw; } } finally { CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } }
/// <summary> /// This method is used to open print window for print invoice /// </summary> /// <param name="obj"></param> public void OpenPrintInvoiceContinue(object obj) { CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); try { int reprintIndValue = 0; int reptintTypeValue = 0; int dateTypeValue = 0; if (ReprintInd == true) { reprintIndValue = 1; } else if (UnPrint == true) { reprintIndValue = 0; } if (ByDate == true) { reptintTypeValue = 0; } else if (ByNumber == true) { reptintTypeValue = 1; } if (PrintedDate == true) { dateTypeValue = 0; } else if (InvoiceDate == true) { dateTypeValue = 1; } if (ReprintInd == true) { if (ByDate == true) { if (InvoiceDateFrom == null) { MessageBox.Show(Resources.msgStratDateReq); return; } if (InvoiceDateTo == null) { MessageBox.Show(Resources.msgEndDateReq); return; } if (InvoiceDateFrom > InvoiceDateTo) { System.Windows.MessageBox.Show(Resources.msgDateCompair); return; } } else { if (string.IsNullOrWhiteSpace(InvoiceNumberFrom)) { MessageBox.Show(Resources.msgStratInvoiceReq); return; } if (string.IsNullOrWhiteSpace(InvoiceNumberTo)) { MessageBox.Show(Resources.msgEndInvoiceReq); return; } } } if (BothCopiesInd) { CopiesToPrint = 2; } else if (DiversifiedCopyInd || CustomerCopyInd) { CopiesToPrint = 1; } if ((CopiesToPrint == 1) || (CopiesToPrint == 2)) { if (CopiesToPrint == 2) { var report2 = new PrintInvoiceRPT(); var data2 = _serviceInstance.GetInvoiceDataForInvoicePrint(reprintIndValue, reptintTypeValue, dateTypeValue, InvoiceDateFrom, InvoiceDateTo, InvoiceNumberFrom, InvoiceNumberTo).Select(d => new Appworks.Reports.PrintInvoiceReport { CustomerName = d.CustomerName, AddressLine1 = d.AddressLine1, AddressLine2 = d.AddressLine2, City = d.City, Country = d.Country, CustomerCode = d.CustomerCode, Zip = d.Zip, FullAddress = (!string.IsNullOrEmpty(d.City) ? d.City + ", " : "") + d.State + " " + d.Zip, InvoiceNumber = d.InvoiceNumber, InvoiceDate = d.InvoiceDate, InvoiceAmount = d.InvoiceAmount, VIN = d.VIN, DateIn = d.DateIn, DateOut = d.DateOut, EntryRate = d.EntryRate, TotalCharge = d.TotalCharge, StorageCharges = d.StorageCharges, State = d.State, CompanyName = CompanyName, CompanyAddressLine1 = CompanyAddressLine1, CompanyCity = CompanyCity, CompanyPhone = CompanyPhone, Model = d.Model, StorageDays = d.StorageDays, BilledDays = d.BilledDays, DailyStorage = d.DailyStorage, Header = d.Header }).ToList(); PrintInvoiceList = new List <Appworks.Reports.PrintInvoiceReport>(); for (int i = 0; i < data2.ToList().Count; i++) { for (int j = 1; j <= 2; j++) { PrintInvoiceList.Add(data2[i]); } } List <Appworks.Reports.PrintInvoiceReport> printInvoiceListTemp = new List <Appworks.Reports.PrintInvoiceReport>(); for (int i = 0; i < PrintInvoiceList.Count; i++) { Appworks.Reports.PrintInvoiceReport printInvoiceListCopy = new Appworks.Reports.PrintInvoiceReport(); printInvoiceListCopy.CustomerName = PrintInvoiceList[i].CustomerName; printInvoiceListCopy.AddressLine1 = PrintInvoiceList[i].AddressLine1; printInvoiceListCopy.AddressLine2 = PrintInvoiceList[i].AddressLine2; printInvoiceListCopy.City = PrintInvoiceList[i].City; printInvoiceListCopy.Country = PrintInvoiceList[i].Country; printInvoiceListCopy.CustomerCode = PrintInvoiceList[i].CustomerCode; printInvoiceListCopy.Zip = PrintInvoiceList[i].Zip; printInvoiceListCopy.FullAddress = PrintInvoiceList[i].FullAddress; printInvoiceListCopy.InvoiceNumber = PrintInvoiceList[i].InvoiceNumber; printInvoiceListCopy.InvoiceDate = PrintInvoiceList[i].InvoiceDate; printInvoiceListCopy.InvoiceAmount = PrintInvoiceList[i].InvoiceAmount; printInvoiceListCopy.VIN = PrintInvoiceList[i].VIN; printInvoiceListCopy.DateIn = PrintInvoiceList[i].DateIn; printInvoiceListCopy.DateOut = PrintInvoiceList[i].DateOut; printInvoiceListCopy.EntryRate = PrintInvoiceList[i].EntryRate; printInvoiceListCopy.TotalCharge = PrintInvoiceList[i].TotalCharge; printInvoiceListCopy.StorageCharges = PrintInvoiceList[i].StorageCharges; printInvoiceListCopy.State = PrintInvoiceList[i].State; printInvoiceListCopy.CompanyName = CompanyName; printInvoiceListCopy.CompanyAddressLine1 = CompanyAddressLine1; printInvoiceListCopy.CompanyCity = CompanyCity; printInvoiceListCopy.CompanyPhone = CompanyPhone; printInvoiceListCopy.Model = PrintInvoiceList[i].Model; printInvoiceListCopy.StorageDays = PrintInvoiceList[i].StorageDays; printInvoiceListCopy.BilledDays = PrintInvoiceList[i].BilledDays; printInvoiceListCopy.DailyStorage = PrintInvoiceList[i].DailyStorage; printInvoiceListCopy.Header = PrintInvoiceList[i].Header; //if (i == 2) // printInvoiceListCopy.Header = "Dishank"; //else if (i == 3) // printInvoiceListCopy.Header = "Dishank Pundir"; if (i % 2 != 0) { printInvoiceListCopy.InvoiceNumber = printInvoiceListCopy.InvoiceNumber + " "; printInvoiceListCopy.Header = "Customer Copy"; } else { printInvoiceListCopy.Header = "Diversified Copy"; } printInvoiceListTemp.Add(printInvoiceListCopy); } report2.DataSource = printInvoiceListTemp.OrderBy(x => x.Header).ThenBy(x => x.CustomerName); MyReportSource = report2; } else { var report = new PrintInvoiceRPT(); var data = _serviceInstance.GetInvoiceDataForInvoicePrint(reprintIndValue, reptintTypeValue, dateTypeValue, InvoiceDateFrom, InvoiceDateTo, InvoiceNumberFrom, InvoiceNumberTo).Select(d => new Appworks.Reports.PrintInvoiceReport { CustomerName = d.CustomerName, AddressLine1 = d.AddressLine1, AddressLine2 = d.AddressLine2, City = d.City, Country = d.Country, CustomerCode = d.CustomerCode, Zip = d.Zip, FullAddress = (!string.IsNullOrEmpty(d.City) ? d.City + ", " : "") + d.State + " " + d.Zip, InvoiceNumber = d.InvoiceNumber, InvoiceDate = d.InvoiceDate, InvoiceAmount = d.InvoiceAmount, VIN = d.VIN, DateIn = d.DateIn, DateOut = d.DateOut, EntryRate = d.EntryRate, TotalCharge = d.TotalCharge, StorageCharges = d.StorageCharges, State = d.State, CompanyName = CompanyName, CompanyAddressLine1 = CompanyAddressLine1, CompanyCity = CompanyCity, CompanyPhone = CompanyPhone, Model = d.Model, StorageDays = d.StorageDays, BilledDays = d.BilledDays, DailyStorage = d.DailyStorage, Header = DiversifiedCopyInd == true ? "Diversified Copy" : "Customer Copy" }).ToList(); PrintInvoiceList = data.ToList(); report.DataSource = PrintInvoiceList.OrderBy(c => c.Header).ThenBy(x => x.CustomerName); MyReportSource = report; } if (PrintInvoiceList.Count > 0) { //PrintWindow objPrintWindow = new PrintWindow(PrintInvoiceList); //objPrintWindow.Show(); if (!reprintInd) { var summaryReport = new InvoiceSummaryRPT(); var list = PrintInvoiceList.OrderBy(x => x.InvoiceDate); summaryReport.DataSource = GetAndDisplayPortStorageSummaryReport(list.FirstOrDefault().InvoiceDate, list.LastOrDefault().InvoiceDate); MyReportSummarySource = summaryReport; PrintInvoiceReportWindow objPrintSummary = new PrintInvoiceReportWindow(MyReportSummarySource); objPrintSummary.ShowDialog(); } PrintInvoiceReportWindow objPrintWindow = new PrintInvoiceReportWindow(MyReportSource); objPrintWindow.Owner = Application.Current.MainWindow; objPrintWindow.ShowDialog(); } else { MessageBox.Show(Resources.msgNoData); } } else { MessageBox.Show("Please select copies to print!"); } } catch (Exception ex) { LogHelper.LogErrorToDb(ex); bool displayErrorOnUI = false; CommonSettings.logger.LogError(this.GetType(), ex); if (displayErrorOnUI) { throw; } } finally { CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name)); } }