예제 #1
0
 public void SetParameters(GrnReportParameters parameters)
 {
     try
     {
         this.reportViewer1.LocalReport.SetParameters(CreateReportParameters(parameters));
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
예제 #2
0
        private ReportParameter[] CreateReportParameters(GrnReportParameters 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 bool GeneratePDF(string fileName)
        {
            try
            {
                if (string.IsNullOrEmpty(fileName))
                {
                    fileName = System.IO.Path.Combine(
                                            System.IO.Path.GetTempPath(), "GRN_" + grnNumberBox.Text + ".pdf");
                }

                if (System.IO.File.Exists(fileName))
                {
                    System.IO.File.Delete(fileName);
                }

                if (grnReportControl == null)
                    grnReportControl = new GrnReportControl();

                var firstGrnReceipt = (from grnReceipt in DBResources.Instance.Context.GRNReciepts
                                       where grnReceipt.GRNIndex == firstGrnIndex
                                       select grnReceipt).FirstOrDefault();

                if (firstGrnReceipt != null)
                {
                    GRNReciept grnReceipt = firstGrnReceipt as GRNReciept;
                    GrnReportParameters parameters = new GrnReportParameters();

                    if (grnIndexes.Count == 1)
                    {
                        parameters.Supplier = Constants.GetSupplierInformation(grnReceipt.OrderedItem.PurchaseOrder.Supplier);
                        parameters.GrnDate = grnReceipt.RecievedDate.Value.ToString();
                    }
                    else
                    {
                        parameters.Supplier = "Multiple Suppliers";
                        parameters.GrnDate = "Multiple Dates";
                    }
                    parameters.GrnNo = grnNumberBox.Text;
                    
                    parameters.StyleInfo = Constants.GetStyleInfo(grnReceipt.OrderedItem.PurchaseOrder.Order);

                    grnReportControl.SetParameters(parameters);
                    grnReportControl.CreateReportAsPDF(grnString, fileName);
                    System.Diagnostics.Process.Start(fileName);
                    return true;
                }
            }
            catch (Exception e)
            {
                System.Windows.MessageBox.Show(e.Message);
            }

            return false;
        }
        private bool GenerateGrnReport(string filePath, long? grnIndex)
        {
            try
            {
                if (grnReportControl == null)
                    grnReportControl = new GrnReportControl();

                GRNReciept grnReceipt = grnReportGrid.Items[0] as GRNReciept;
                GrnReportParameters parameters = new GrnReportParameters();
                parameters.Supplier = Constants.GetSupplierInformation(ViewModel.PurchaseOrder.Supplier);
                parameters.GrnNo = grnIndex.Value.ToString();
                parameters.GrnDate = grnReceipt.RecievedDate.Value.ToString();
                parameters.StyleInfo = Constants.GetStyleInfo(ViewModel.PurchaseOrder.Order);

                grnReportControl.SetParameters(parameters);
                grnReportControl.CreateReportAsPDF(grnIndex.Value.ToString(), filePath);
            }
            catch (Exception e)
            {
                System.Windows.MessageBox.Show(e.Message);
                return false;
            }

            return true;

        }