private ReportParameter[] CreateReportParameters(BudgetReportParameters parameters)
        {
            List<ReportParameter> reportParameters = new List<ReportParameter>();
            PropertyInfo[] propertyInfos = parameters.GetType().GetProperties();
            foreach (PropertyInfo pInfo in propertyInfos)
            {
                ReportParameter parameter = new ReportParameter(pInfo.Name, (string)pInfo.GetValue(parameters));
                reportParameters.Add(parameter);
            }

            return reportParameters.ToArray();
            
        }
 public void SetParameters(BudgetReportParameters parameters)
 {
     this.reportViewer1.LocalReport.SetParameters(CreateReportParameters(parameters));
 }
        private void btnGeneratePDF_Click_1(object sender, RoutedEventArgs e)
        {
            //Generate Parameters
            BudgetReportParameters parameters = new BudgetReportParameters();
            parameters.Buyer = ViewModel.Order.Company.Name;
            parameters.CurrencyValueInINR = GetFormattedValueString(ViewModel.SelectedProduct.CurrencyValueInINR);
            parameters.DateOfGeneration = DBResources.Instance.GetServerTime().ToShortDateString();
            parameters.ExpectedQuantity = GetFormattedValueString( ViewModel.SelectedProduct.ExpectedQuantity);
            parameters.OrderDate = ViewModel.Order.OrderDate.ToShortDateString();
            parameters.OrderedProductCurrency = ViewModel.SelectedProduct.Currency.Symbol;
            parameters.OrderID = ViewModel.Order.OrderID.ToString();
            parameters.OurPrice = GetFormattedValueString(ViewModel.SelectedProduct.OurCostInProductCurrenyValue)  + " " + parameters.OrderedProductCurrency;
            parameters.PerUnitBuyerTargetPrice = GetFormattedValueString(ViewModel.SelectedProduct.CustomerTargetPrice) + " " + parameters.OrderedProductCurrency;
            parameters.ProductName = ViewModel.SelectedProduct.ProductName.Name;
            parameters.ProfitOrLoss = GetFormattedValueString(ViewModel.SelectedProduct.ProfitOrLossAmount) + " " + parameters.OrderedProductCurrency;
            parameters.StyleID = ViewModel.SelectedProduct.ProductName.StyleID;
            parameters.TotalValue = GetFormattedValueString(ViewModel.SelectedProduct.OrderValue) + " " + "INR";
            parameters.NumberOfItems = ViewModel.SelectedProduct.ProductMaterials.Count.ToString();
            parameters.OrderConfirmComment = "No Comments";

            foreach (History history in ViewModel.Order.Histories)
            {
                if (history.OrderChanges.Contains("confirmed the Order"))
                {
                    parameters.OrderConfirmComment = history.Comment;
                }
            }

            string tempFilePathForPdf = System.IO.Path.Combine(
                                           System.IO.Path.GetTempPath(), "OM_Budget-" + parameters.OrderID + "-" + parameters.StyleID + "-" + parameters.DateOfGeneration.Replace(@"/","_") + ".pdf");

            if (File.Exists(tempFilePathForPdf))
            {
                File.Delete(tempFilePathForPdf);
            }

            budgetReportControl.SetParameters(parameters);
            budgetReportControl.CreateReportAsPDF(ViewModel.Order.OrderID, ViewModel.SelectedProduct.ProductID, tempFilePathForPdf);
            System.Diagnostics.Process.Start(tempFilePathForPdf);
        }