public PrintFinalInvoiceTemplate(int id, string moduleName)
 {
     InitializeComponent();
     ModuleName = moduleName;
     FinalInvoiceTemplateVM = new FinalInvoiceTemplateVM(id);
     BindData();
 }
Esempio n. 2
0
        public void PrintCommercialInvoice(string documentName)
        {

            string dirPath = "ReportOutput";
            if (!Directory.Exists(dirPath))
            {
                Directory.CreateDirectory(dirPath);
            }

            if (Type == (int)CommercialInvoiceType.Final|| Type == (int)CommercialInvoiceType.FinalCommercial)
            {
                string name = EnumHelper.GetDescriptionByCulture(PrintTemplateType.FinalInvoiceTemplate);
                var rptVM = new FinalInvoiceTemplateVM(Id);
                string pathName = @"PrintTemplate\" + name + "\\" + documentName;
                var localReport = new LocalReport { ReportPath = pathName };
                localReport.DataSources.Add(new ReportDataSource("Head", rptVM.HeaderList));
                localReport.DataSources.Add(new ReportDataSource("Lines", rptVM.LCPropertyList));
                var output = localReport.Render("EXCEL");
                string fileName = "FinalInvoice" + Id + "-" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls";
                var fs = new FileStream(dirPath + "\\" + fileName, FileMode.Create);
                fs.Write(output, 0, output.Length);
                fs.Flush();
                fs.Close();

                Process.Start(dirPath + "\\" + fileName);
            }
            else if (Type == (int)CommercialInvoiceType.Provisional)
            {
                string name = EnumHelper.GetDescriptionByCulture(PrintTemplateType.ProvisionalInvoiceTemplate);

                var rptVM = new ProvisionalInvoiceTemplateVM(Id);
                string pathName = @"PrintTemplate\" + name + "\\" + documentName;
                var localReport = new LocalReport { ReportPath = pathName };
                localReport.DataSources.Add(new ReportDataSource("Head", rptVM.HeaderList));
                var output = localReport.Render("EXCEL");
                string fileName = "ProvisionalInvoice" + Id + "-" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls";
                var fs = new FileStream(dirPath + "\\" + fileName, FileMode.Create);
                fs.Write(output, 0, output.Length);
                fs.Flush();
                fs.Close();

                Process.Start(dirPath + "\\" + fileName);
            }

        }