Click here to Skip to main content
15,893,564 members
Home / Discussions / C#
   

C#

 
AnswerRe: Mutiplication error? Pin
#realJSOP13-Dec-09 11:33
mve#realJSOP13-Dec-09 11:33 
Questionbackup and restore from database Pin
farokhian13-Dec-09 6:18
farokhian13-Dec-09 6:18 
AnswerRe: backup and restore from database Pin
Mycroft Holmes13-Dec-09 13:53
professionalMycroft Holmes13-Dec-09 13:53 
QuestionHow to Add context menu strip in notify icon of c# console application Pin
AhmedMasum13-Dec-09 5:39
AhmedMasum13-Dec-09 5:39 
AnswerRe: How to Add context menu strip in notify icon of c# console application Pin
Luc Pattyn13-Dec-09 9:05
sitebuilderLuc Pattyn13-Dec-09 9:05 
GeneralRe: How to Add context menu strip in notify icon of c# console application Pin
AhmedMasum13-Dec-09 18:49
AhmedMasum13-Dec-09 18:49 
GeneralRe: How to Add context menu strip in notify icon of c# console application Pin
AhmedMasum14-Dec-09 20:38
AhmedMasum14-Dec-09 20:38 
Questionexport without the Microsoft report control Pin
Jassim Rahma13-Dec-09 2:29
Jassim Rahma13-Dec-09 2:29 
I am using thecode below to generate the reports but I want to know how to modify it to export to PDF file directly without a need of the report viewer control?


private void generate_invoices()
{
    this.Cursor = Cursors.WaitCursor;

    // sql_connection = new SqlConnection("Data Source=.\\JASSIMSQL;initial catalog=takhlees;integrated security=true");
    sql_connection = new SqlConnection(public_var.sql_server_connection);

    try
    {
        sql_connection.Open();

        sql_command = new SqlCommand("sp_get_account_book_by_book_guid", sql_connection);
        sql_command.CommandType = CommandType.StoredProcedure;
        // sql_command.Parameters.Add("@accounts_date", SqlDbType.DateTime).Value = current_date.ToShortDateString();
        // sql_command.Parameters.Add("@account_number", SqlDbType.Int).Value = dateCurrentDate.SelectionRange.Start;
        sql_command.Parameters.Add("@book_guid", SqlDbType.UniqueIdentifier).Value = book_guid;

        DataSet data_set = new dsReports();

        reportTICS.Reset();

        sql_reader = sql_command.ExecuteReader();

        data_set.Tables[0].Load(sql_reader);

        // reportViewer1.LocalReport.ReportEmbeddedResource = "The_Internet_Cafe_System.ReportDaily.rdlc";
        reportTICS.LocalReport.ReportEmbeddedResource = "dsReports_sp_get_account_book_by_book_guid";
        // reportTICS.LocalReport.ReportPath = TICS_registry_current_user_reports.GetValue("ReportsFolder").ToString() + "\\" + TICS_registry_current_user_reports.GetValue("DailyReportFile").ToString();
        reportTICS.LocalReport.ReportPath = @"C:\Users\Jassim\Documents\Visual Studio 2008\Projects\Takhlees\Takhlees\envoice.rdlc";

        ReportDataSource rds = new ReportDataSource();
        rds.Name = "dsReports_sp_get_account_book_by_book_guid";
        rds.Value = data_set.Tables[0];
        reportTICS.LocalReport.DataSources.Add(rds);

        ReportDataSource rds2 = new ReportDataSource();
        rds2.Name = "dsReports_sp_get_account_book_by_account_number";
        rds2.Value = data_set.Tables[0];
        reportTICS.LocalReport.DataSources.Add(rds2);


        reportTICS.LocalReport.Refresh();

        reportTICS.RefreshReport();

        if (chkSaveInvoice.Checked == true)
        {
            Warning[] warnings;
            string[] streamids;
            string mimeType;
            string encoding;
            string filenameExtension;

            byte[] bytes = reportTICS.LocalReport.Render("PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings);

            string file_path = "c:\\temp\\envoice\\" + DateTime.Now.ToString("dd MMM yyyy");
            System.IO.Directory.CreateDirectory(file_path);

            // string file_namr = "c:\\temp\\envoice\\" + data_set.Tables[0].Rows.Count.ToString() + ".pdf";
            string file_namr = file_path + "\\" + System.Guid.NewGuid() + ".pdf";

            using (System.IO.FileStream fs = new System.IO.FileStream(file_namr, System.IO.FileMode.Create))
            {
                fs.Write(bytes, 0, bytes.Length);
            }

            Process.Start(file_path);
        }

        // this.Text = TICS_registry_current_user_reports.GetValue("DailyReportTitle").ToString();

        // event_log.create_event("Daily Report was generated for " + dateCurrentDate.SelectionRange.Start.ToString("dd MMM yyyy"), EventLogEntryType.Information, 1000);

        // sql_reader.Close();
        // sql_connection.Close();

        progressInvoice.Minimum = 0;
        progressInvoice.Maximum = data_set.Tables[0].Rows.Count;
    }
    catch (Exception exp)
    {
        event_log.create_event("Problem preparing or viewing daily report." + Environment.NewLine + Environment.NewLine + exp.Message + Environment.NewLine + Environment.NewLine + exp.Data + Environment.NewLine + Environment.NewLine + exp.StackTrace + Environment.NewLine + Environment.NewLine + exp.InnerException, EventLogEntryType.Error, 9999);
        MessageBox.Show("Problem preparing  or viewing daily report!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        MessageBox.Show(exp.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        this.Close();
    }
    finally
    {
        if (sql_reader != null) sql_reader.Close();
        if (sql_connection != null)
        {
            if (sql_connection.State == ConnectionState.Open)
                sql_connection.Close();
        }
    }

    this.Cursor = Cursors.Default;
}

Questiontable's footer at the bottom [Microsoft Report - RDLC] Pin
Jassim Rahma13-Dec-09 2:27
Jassim Rahma13-Dec-09 2:27 
AnswerRe: table's footer at the bottom [Microsoft Report - RDLC] Pin
Jassim Rahma15-Dec-09 12:23
Jassim Rahma15-Dec-09 12:23 
QuestionOrder of precedence for LOGICAL Operators Pin
dataminers13-Dec-09 1:07
dataminers13-Dec-09 1:07 
AnswerRe: Order of precedence for LOGICAL Operators Pin
Alan N13-Dec-09 1:33
Alan N13-Dec-09 1:33 
AnswerRe: Order of precedence for LOGICAL Operators Pin
Abhinav S13-Dec-09 17:38
Abhinav S13-Dec-09 17:38 
QuestionSharpPcap new version SharpPcap-2.2.0rc1.src Pin
3bood.ghzawi13-Dec-09 0:31
3bood.ghzawi13-Dec-09 0:31 
AnswerRe: SharpPcap new version SharpPcap-2.2.0rc1.src Pin
Richard MacCutchan13-Dec-09 0:49
mveRichard MacCutchan13-Dec-09 0:49 
GeneralRe: SharpPcap new version SharpPcap-2.2.0rc1.src Pin
Migounette13-Dec-09 2:07
Migounette13-Dec-09 2:07 
GeneralRe: SharpPcap new version SharpPcap-2.2.0rc1.src Pin
Richard MacCutchan13-Dec-09 2:12
mveRichard MacCutchan13-Dec-09 2:12 
QuestionRe: SharpPcap new version SharpPcap-2.2.0rc1.src Pin
3bood.ghzawi13-Dec-09 11:46
3bood.ghzawi13-Dec-09 11:46 
AnswerRe: SharpPcap new version SharpPcap-2.2.0rc1.src Pin
Rajesh R Subramanian13-Dec-09 20:24
professionalRajesh R Subramanian13-Dec-09 20:24 
GeneralRe: SharpPcap new version SharpPcap-2.2.0rc1.src Pin
Richard MacCutchan13-Dec-09 22:52
mveRichard MacCutchan13-Dec-09 22:52 
AnswerRe: SharpPcap new version SharpPcap-2.2.0rc1.src Pin
Migounette13-Dec-09 12:07
Migounette13-Dec-09 12:07 
QuestionCan I compile only some line of code? Pin
CoderForEver13-Dec-09 0:10
CoderForEver13-Dec-09 0:10 
AnswerRe: Can I compile only some line of code? Pin
dan!sh 13-Dec-09 0:39
professional dan!sh 13-Dec-09 0:39 
GeneralRe: Can I compile only some line of code? Pin
CoderForEver13-Dec-09 1:09
CoderForEver13-Dec-09 1:09 
GeneralRe: Can I compile only some line of code? Pin
dan!sh 13-Dec-09 1:22
professional dan!sh 13-Dec-09 1:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.