Example #1
0
        public void PrintGrid(string gridPath, Zen.Barcode.Code128BarcodeDraw barcode, string invoiceNo, DataTable dtheadNew, DataRow drhead, DataTable gridTableRight, DataTable gridTableLeft)
        {
            LocalReport localReport = new LocalReport();

            localReport.ReportPath = Server.MapPath(gridPath);

            var image = barcode.Draw(invoiceNo, 50, 2);

            byte[] arr;
            using (var memStream = new MemoryStream())
            {
                image.Save(memStream, ImageFormat.Jpeg);
                arr = memStream.ToArray();
            }
            drhead["Barcode"] = arr;

            dtheadNew.ImportRow(drhead);

            localReport.DataSources.Add(new ReportDataSource("GridHead", dtheadNew));
            if (gridTableLeft != null && gridTableRight != null)
            {
                localReport.DataSources.Add(new ReportDataSource("Grid200BodyRight", gridTableRight));
            }
            localReport.DataSources.Add(new ReportDataSource("Grid200BodyLeft", gridTableLeft));
            string printerName = "Microsoft Print to PDF";

            localReport.PrintToPrinter(printerName);
            dtheadNew.Rows.Clear();
        }
Example #2
0
        private void btnPrint_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string ReportName = "Report1";

                LocalReport report = new LocalReport();

                //report.ReportEmbeddedResource = "Rail." + ReportName + ".rdlc";
                report.ReportPath = ReportName + ".rdlc";

                ReportParameter rp1 = new ReportParameter("Dated", Convert.ToDateTime(txtDated.Text.ToString()).ToString("dd/MM/yyy"));
                ReportParameter rp2 = new ReportParameter("PayTo", txtPayto.Text.ToString());
                ReportParameter rp3 = new ReportParameter("theSumOfRupees", txttheSumOfRupees.Text.ToString());
                ReportParameter rp4 = new ReportParameter("Rs", txtRs.Text.ToString());

                report.SetParameters(new ReportParameter[] { rp1, rp2, rp3, rp4 });

                report.PrintToPrinter();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #3
0
        private void Imprimir_Click(object sender, RoutedEventArgs e)
        {
            var pedido = SalvarPedido();
            var report = new LocalReport();

            report.ReportEmbeddedResource = "DistribuidoraWandall.Reports.Pedidos.rdlc";

            report.DataSources.Add(new ReportDataSource("Produtos", pedido.Produtos.Select(x => new ReportProduto()
            {
                Nome          = x.Produto.Nome,
                Quantidade    = x.Quantidade,
                ValorUnitario = x.ValorVendido
            })));
            report.PrintToPrinter();
        }
Example #4
0
        private void print(DataGridView dataGridView1)
        {
            ToWord word = new ToWord(Convert.ToDecimal(dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[8].Value.Equals(DBNull.Value) ? "0" : dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[8].Value), new CurrencyInfo(CurrencyInfo.Currencies.Kilo));
            ReportParameterCollection reportParameter = new ReportParameterCollection();

            reportParameter.Add(new ReportParameter("toArabic", word.ConvertToArabic()));
            reportParameter.Add(new ReportParameter("User", Properties.Settings.Default.username));
            LocalReport localReport = new LocalReport();

            localReport.ReportPath = Application.StartupPath + "\\Report1.rdlc";
            Data_Access      data_Access = new Data_Access(Convert.ToInt16(Convert.ToInt32(dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[0].Value)));
            ReportDataSource rds         = new ReportDataSource("Wieghts", data_Access.getReportData());

            localReport.DataSources.Clear();
            localReport.DataSources.Add(rds);
            localReport.SetParameters(reportParameter);
            localReport.PrintToPrinter();
        }
        private void btnPrint_Click(object sender, EventArgs e)
        {
            ToWord word = new ToWord(Convert.ToDecimal(finalWieght()), new CurrencyInfo(CurrencyInfo.Currencies.Kilo));
            ReportParameterCollection reportParameter = new ReportParameterCollection();

            reportParameter.Add(new ReportParameter("toArabic", word.ConvertToArabic()));
            reportParameter.Add(new ReportParameter("User", Properties.Settings.Default.username));
            LocalReport localReport = new LocalReport();

            localReport.ReportPath = Application.StartupPath + "\\Report1.rdlc";
            Data_Access      data_Access = new Data_Access(Convert.ToInt32(lblCode.Text));
            ReportDataSource rds         = new ReportDataSource("Wieghts", data_Access.getReportData());

            localReport.DataSources.Clear();
            localReport.DataSources.Add(rds);
            localReport.SetParameters(reportParameter);
            localReport.PrintToPrinter();
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            LocalReport localReport = new LocalReport();

            localReport.ReportPath = Server.MapPath("Report.rdlc");
            DataTable dataTable = new DataTable();

            dataTable.Columns.Add("InvoiceNo");
            dataTable.Columns.Add("Company");
            DataRow row = dataTable.NewRow();

            row["InvoiceNo"] = "311111";
            row["Company"]   = "hahahah";
            dataTable.Rows.Add(row);
            localReport.DataSources.Add(new ReportDataSource("GridHead", dataTable));
            string printerName = "Microsoft Print to PDF";

            localReport.PrintToPrinter(printerName);
        }
        private void CustomerTicket()
        {
            FunStopDataSet ds = new FunStopDataSet();

            FunStopDataSetTableAdapters.Sp_TicketReportTableAdapter ta = new FunStopDataSetTableAdapters.Sp_TicketReportTableAdapter();
            ReportViewer1.ProcessingMode = ProcessingMode.Local;
            LocalReport lc   = ReportViewer1.LocalReport;
            string      ruta = "Reports\\RptTicket.rdlc";

            lc.ReportPath = ruta;
            ta.Fill(ds.Sp_TicketReport, ClsGlobal.TicketID);
            ReportDataSource rds = new ReportDataSource();

            ReportViewer1.LocalReport.DisplayName = "TICKET";
            rds.Name  = "DataSet1";
            rds.Value = (ds.Tables["Sp_TicketReport"]);
            ReportViewer1.LocalReport.DataSources.Clear();
            lc.DataSources.Add(rds);
            lc.PrintToPrinter();
            //this.ReportViewer1.ShowPrintButton = true;
        }
Example #8
0
        public bool RenderRep0000(string virtualbasepath, string printername, string jobname, bool dinA5, string footerinfoline, string participantname, string participationdatetime, string trainingtopic, string fexpires, out MemoryStream chunk, out string mime, out string encoding, out string uri)
        {
            /* make a direct (synchronous) PDF from training participation certificate data */
            chunk    = new MemoryStream();
            mime     = sherm.core.formatting.mime.cstMIMEPDF;
            encoding = System.Text.Encoding.UTF8.EncodingName;
            uri      = String.Format("Teilnahmezertifikat-{0}-{1}.pdf",
                                     trainingtopic.Replace(" ", "_"),
                                     participantname.Replace(" ", "_")
                                     );
            try
            {
                var rpt_format = "PDF";
                /* instantiate and render the rdlc */
                var rpt = new LocalReport()
                {
                    ReportEmbeddedResource = "sherm.rpt.msdbrpt.ReportHardcopyTrainingCert.rdlc",
                    EnableExternalImages   = true
                };
                if (dinA5)
                {
                    rpt.ReportEmbeddedResource = "sherm.rpt.msdbrpt.ReportHardcopyTrainingCertA5.rdlc";
                }
                /* data binding */
                var Logo = String.Format("{0}{1}",
                                         virtualbasepath,
                                         BuiltinReportDescriptor.MediaURL(sherm.core.formatting.mime.BINGET_NAMEDRESOURCE_CORPORATELOGO, null, null, new FileType[] { FileType.ft_png })
                                         );
                rpt.SetParameters(new ReportParameter[]
                {
                    new ReportParameter("LogoURL", Logo),
                    new ReportParameter("ParticipantName", participantname),
                    new ReportParameter("ParticipationTime", participationdatetime),
                    new ReportParameter("Topic", trainingtopic),
                    new ReportParameter("Expires", fexpires),
                    new ReportParameter("FooterInfoline", footerinfoline)
                });
                /* rendition - with [sic(k)] placeholder table to satisfy the rdlc's data binding */
                var table = new List <ReportHardcopyPSAPlanRow>();
                table.Add(new ReportHardcopyPSAPlanRow());
                var dsTable     = "dsRow";
                var dynDS_Table = new ReportDataSource(dsTable, table);
                rpt.DataSources.Add(dynDS_Table);
                rpt.Refresh();
                string[]  streams;
                Warning[] warnings;
                string    extension;

                /* [pkosec 20140521] set dpi for rdlc (MEA-2014-00207 initiative)
                 * [pkosec 20140506] use the default value (null), if DPI has not been set */
                string devinfo = null;
                devinfo = String.Format("<DeviceInfo><DpiX>{0}</DpiX><DpiY>{0}</DpiY></DeviceInfo>", 300);
                if (printername == null)
                {
                    /* [dlatikay 20180625] can now send directly */
                    var result = rpt.Render(rpt_format, devinfo, PageCountMode.Actual, out mime, out encoding, out extension, out streams, out warnings);
                    foreach (var w in warnings)
                    {
                        Tracing.WarningCore("Code: {0}, Message: {1}, Objectname: {2}, Objecttype: {3}, Severity: {4}",
                                            w.Code,
                                            w.Message,
                                            w.ObjectName,
                                            w.ObjectType,
                                            w.Severity.ToString()
                                            );
                    }
                    chunk = new MemoryStream(result);
                }
                else
                {
                    rpt.PrintToPrinter(printername, jobname);
                }
                /* succeeded */
                return(true);
            }
            catch (Exception ex)
            {
                Tracing.ErrorCore("{0}", ex.ToString());
                return(false);
            }
        }
Example #9
0
        private void socketIo()
        {
            var socket = IO.Socket(this.server);

            //Event
            socket.On(Socket.EVENT_CONNECT, () =>
            {
                List <String> printer = getPrinter();
                string defaultPrinter = getDefaultPrinter();

                var data = new
                {
                    ip             = this.ip,
                    name           = this.name,
                    printers       = printer,
                    defaultPrinter = defaultPrinter
                };

                var jsonFormat = Newtonsoft.Json.JsonConvert.SerializeObject(data);
                socket.Emit("recieveUserName", jsonFormat);
                notifyIcon.BalloonTipText = "Connected Server " + server;
                notifyIcon.ShowBalloonTip(1000);
            });

            var that = this;

            socket.On("message", (data) =>
            {
                Invoke(new Action(() =>
                {
                    that.Show();
                    that.WindowState   = FormWindowState.Normal;
                    notifyIcon.Visible = false;

                    var o = (JObject)data;

                    //tboMessage.Text = (string)o.GetValue("message");
                    String message = (string)o.GetValue("message");
                    //message = message.Replace(System.Environment.NewLine, "\n");
                    label1.Text    = message;
                    String strType = (string)o.GetValue("type");
                    if (strType != null)
                    {
                        setType(type[strType]);
                    }
                    //SFCForm.MainWindow fm = new SFCForm.MainWindow();
                    label1.Top = (this.Height - label1.Height) / 2 - 30;
                }));
            });

            socket.On("print", (data) =>
            {
                try
                {
                    Invoke(new Action(() =>
                    {
                        notifyIcon.BalloonTipText = "Client Printed.";
                        notifyIcon.ShowBalloonTip(1000);

                        var o = (JObject)data;
                        //JArray jarray = (JArray)o.GetValue("JOBS");
                        //JToken entry = (JToken)jarray[0];
                        //var jobs = (String)entry[0]["DocumentName"];
                        LocalReport localReport = new LocalReport();

                        foreach (JObject job in (JArray)o.GetValue("JOBS"))
                        {
                            localReport.ReportPath = (String)job.GetValue("FilePath");
                            foreach (JObject doc in (JArray)job.GetValue("DocumentDatas"))
                            {
                                try
                                {
                                    ReportParameter Param = new ReportParameter();
                                    Param.Name            = (String)doc.GetValue("Parameter");
                                    Param.Values.Add((String)doc.GetValue("Value"));
                                    localReport.SetParameters(new ReportParameter[] { Param });
                                }
                                catch (LocalProcessingException e)
                                {
                                    MessageBox.Show(e.InnerException.Message);
                                    break;
                                }
                            }

                            if ((String)job.GetValue("PrintServerID") != (String)job.GetValue("PrinterName"))
                            {
                                localReport.SetPrinterName((String)job.GetValue("PrinterName"));
                                localReport.PrintToPrinter();
                            }
                            else
                            {
                                localReport.PrintToPrinter(); //default printer output
                            }
                        }

                        // LocalReport localReport = new LocalReport();
                        // localReport.ReportPath = Application.StartupPath + "\\FGRECEIVEDBILL_REPORT.rdl";

/*
 *                      foreach (var x in (JObject)o.GetValue("item"))
 *                      {
 *                          ReportParameter Param = new ReportParameter();
 *                          Param.Name = (String)x.Key;
 *                          Param.Values.Add((String)x.Value);
 *                          localReport.SetParameters(new ReportParameter[] { Param });
 *                      }
 *
 *                      localReport.PrintToPrinter((String)o.GetValue("printer"));
 */
                    }));
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                }
            });

            socket.On(Socket.EVENT_ERROR, (error) => {
                // ...

                Invoke(new Action(() =>
                {
                    notifyIcon.BalloonTipText = "Connect Error " + server;
                    notifyIcon.ShowBalloonTip(1000);
                }));
            });
        }
Example #10
0
        private void OnPrintBtnClicked(object sender, RoutedEventArgs e)
        {
            Cursor clOldCursor = Mouse.OverrideCursor;

            Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;

            string clCurReportFilePath = System.IO.Path.Combine(AssemblyDirectory, "Bill.rdlc");

            if (!File.Exists(clCurReportFilePath))
            {
                Mouse.OverrideCursor = clOldCursor;
                MessageBox.Show("Error occurs while printing.\nContact Developer.", "Error");
                return;
            }

            LocalReport report = new LocalReport()
            {
                ReportPath = clCurReportFilePath
            };

            try
            {
                DataGridColumn clDescCol        = cl_DataTable.ColumnFromDisplayIndex(0);
                DataGridColumn clChallanNoCol   = cl_DataTable.ColumnFromDisplayIndex(1);
                DataGridColumn clChallanDateCol = cl_DataTable.ColumnFromDisplayIndex(2);
                DataGridColumn clSACCodeCol     = cl_DataTable.ColumnFromDisplayIndex(3);
                DataGridColumn clQuantityCol    = cl_DataTable.ColumnFromDisplayIndex(4);
                DataGridColumn clRateCol        = cl_DataTable.ColumnFromDisplayIndex(5);
                DataGridColumn clAmountCol      = cl_DataTable.ColumnFromDisplayIndex(6);

                DataTable clBillTable = new DataTable("BillInfo");
                clBillTable.Columns.Add("SrNo", typeof(string));
                clBillTable.Columns.Add("Description", typeof(string));
                clBillTable.Columns.Add("ChallanNo", typeof(string));
                clBillTable.Columns.Add("ChallanDate", typeof(string));
                clBillTable.Columns.Add("SACCode", typeof(string));
                clBillTable.Columns.Add("Quantity", typeof(Decimal));
                clBillTable.Columns.Add("Unit", typeof(string));
                clBillTable.Columns.Add("Rate", typeof(string));
                clBillTable.Columns.Add("Amount", typeof(Double));

                double dTotalAmount = 0;
                int    iRowCount    = cl_DataTable.Items.Count;

                clBillTable.Rows.Clear();

                for (int iRowLoop = 0; iRowLoop < iRowCount; iRowLoop++)
                {
                    Object clCurItem            = cl_DataTable.Items.GetItemAt(iRowLoop);
                    var    clDescTextBox        = clDescCol.GetCellContent(clCurItem) as TextBlock;
                    var    clChallanNoTextBox   = clChallanNoCol.GetCellContent(clCurItem) as TextBlock;
                    var    clChallanDateTextBox = clChallanDateCol.GetCellContent(clCurItem) as TextBlock;
                    var    clSACCodeTextBox     = clSACCodeCol.GetCellContent(clCurItem) as TextBlock;
                    var    clQuantityTextBox    = clQuantityCol.GetCellContent(clCurItem) as TextBlock;
                    var    clRateTextBox        = clRateCol.GetCellContent(clCurItem) as TextBlock;
                    var    clAmountTextBox      = clAmountCol.GetCellContent(clCurItem) as TextBlock;

                    int iQuantity = 0;
                    int.TryParse(clQuantityTextBox.Text, out iQuantity);

                    double dAmount = 0.0;
                    double.TryParse(clAmountTextBox.Text, out dAmount);

                    clBillTable.Rows.Add((iRowLoop + 1).ToString(),
                                         clDescTextBox.Text,
                                         clChallanNoTextBox.Text,
                                         clChallanDateTextBox.Text,
                                         clSACCodeTextBox.Text,
                                         iQuantity,
                                         "Nos",
                                         clRateTextBox.Text,
                                         dAmount
                                         );

                    dTotalAmount += dAmount;
                }

                string clAddress = cl_Address.Text;
                clAddress.Replace('\n', ',');
                report.SetParameters(new ReportParameter("strBuyerName", cl_BuyerName.Text));
                report.SetParameters(new ReportParameter("strBuyerAddress", clAddress));
                report.SetParameters(new ReportParameter("strBuyerCity", cl_City.Text));
                report.SetParameters(new ReportParameter("strBuyerGSTIN", cl_BuyerGSTIN.Text));
                report.SetParameters(new ReportParameter("strInvoiceNo", cl_InvoiceNo.Text));
                report.SetParameters(new ReportParameter("strInvoiceDate", cl_InvoiceDate.Text));
                report.SetParameters(new ReportParameter("strOtherDetails", cl_OtherDetails.Text));
                report.SetParameters(new ReportParameter("strSubTotal", dTotalAmount.ToString("F")));
                report.SetParameters(new ReportParameter("strCGST", (dTotalAmount * 0.025).ToString("F")));
                report.SetParameters(new ReportParameter("strSGST", (dTotalAmount * 0.025).ToString("F")));
                dTotalAmount += (dTotalAmount * 0.05);
                int iForRounding = (int)(dTotalAmount + 0.49);
                dTotalAmount = iForRounding;
                report.SetParameters(new ReportParameter("strRsInWords", ConvertMyword((int)dTotalAmount)));
                report.SetParameters(new ReportParameter("strTotalAmount", dTotalAmount.ToString("F")));
                report.SetParameters(new ReportParameter("strFirmName", "HARDIK ART"));
                report.SetParameters(new ReportParameter("strBankName", "State Bank Of India"));
                report.SetParameters(new ReportParameter("strAccountNo", "36729467959"));
                report.SetParameters(new ReportParameter("strIFSCCode", "SBIN0005722"));

                report.SetParameters(new ReportParameter("strBillType", "Original"));

                report.DataSources.Clear();

                var reportDataSource1 = new ReportDataSource();
                reportDataSource1.Name  = "BillInfo";
                reportDataSource1.Value = clBillTable;

                report.DataSources.Add(reportDataSource1);

                report.PrintToPrinter();

                if (cl_TriplicateBillCheckBox.IsChecked == true)
                {
                    report.SetParameters(new ReportParameter("strBillType", "Duplicate"));
                    report.PrintToPrinter();

                    report.SetParameters(new ReportParameter("strBillType", "Triplicate"));
                    report.PrintToPrinter();
                }

                if (MessageBox.Show(this, "Bill sent to printer. You want to clear bill data ?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    fnClearData();
                }
            }
            catch (Exception ex)
            {
                Mouse.OverrideCursor = clOldCursor;
                MessageBox.Show("Error occurs while exporting.\n If you think it's not your error, Contact Developer.\n\nError Message :- " + ex.Message, "Error");
            }

            Mouse.OverrideCursor = clOldCursor;
        }