Click here to Skip to main content
15,905,025 members
Home / Discussions / C#
   

C#

 
GeneralRe: how to check which ports are available? Pin
aniarun16-Dec-09 12:42
aniarun16-Dec-09 12:42 
QuestionUsing OCX control in C# Pin
vhassan15-Dec-09 15:43
vhassan15-Dec-09 15:43 
AnswerRe: Using OCX control in C# Pin
N a v a n e e t h15-Dec-09 16:25
N a v a n e e t h15-Dec-09 16:25 
AnswerRe: Using OCX control in C# Pin
Abhinav S15-Dec-09 17:31
Abhinav S15-Dec-09 17:31 
GeneralRe: Using OCX control in C# Pin
ali- kanju216-Dec-09 0:47
ali- kanju216-Dec-09 0:47 
Questionwriting data in c# Pin
aniarun15-Dec-09 15:16
aniarun15-Dec-09 15:16 
AnswerRe: writing data in c# Pin
Dr.Walt Fair, PE15-Dec-09 16:48
professionalDr.Walt Fair, PE15-Dec-09 16:48 
Questionseparate PDFs from the report Pin
Jassim Rahma15-Dec-09 12:24
Jassim Rahma15-Dec-09 12:24 
I am using the code at the botoom to generate the monthly contracts invoices and save every invoice as a separate PDF I am generating all invoices to have the same GUID so it will be easier to retrieve all but it will be more than one invoice so for example they will all have same GUID but I will have 5 or 6 companies. I want to use the same code below to generate the separate PDFs using the invoice_number as file name.


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);

                // ReportParameter report_date_parameter = new ReportParameter("paramDate", dateCurrentDate.SelectionRange.Start.ToShortDateString());
                // reportTICS.LocalReport.SetParameters(new ReportParameter[] { report_date_parameter });

                // ReportParameter header_parameter = new ReportParameter("paramHeader", "DAILY REPORT FOR " + dateCurrentDate.SelectionRange.Start.ToString("dd MMM yyyy"));
                // reportTICS.LocalReport.SetParameters(new ReportParameter[] { header_parameter });

                // ReportParameter footer_parameter = new ReportParameter("paramFooter", "Developed by: " + jassim_rahma_registry.GetValue("DeveloperName").ToString());
                // reportTICS.LocalReport.SetParameters(new ReportParameter[] { footer_parameter });

                // ReportParameter website_parameter = new ReportParameter("paramWebsite", jassim_rahma_registry.GetValue("DeveloperWebsite").ToString());
                // reportTICS.LocalReport.SetParameters(new ReportParameter[] { website_parameter });

                // ReportParameter cafe_name_parameter = new ReportParameter("paramCafeName", TICS_registry_current_user.GetValue("CafeName").ToString());
                // reportTICS.LocalReport.SetParameters(new ReportParameter[] { cafe_name_parameter });

                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;
        }

Questiondatagridview Pin
farokhian15-Dec-09 10:16
farokhian15-Dec-09 10:16 
AnswerRe: datagridview Pin
Dr.Walt Fair, PE15-Dec-09 10:28
professionalDr.Walt Fair, PE15-Dec-09 10:28 
GeneralRe: datagridview Pin
farokhian15-Dec-09 19:54
farokhian15-Dec-09 19:54 
GeneralRe: datagridview Pin
Dr.Walt Fair, PE16-Dec-09 5:02
professionalDr.Walt Fair, PE16-Dec-09 5:02 
AnswerRe: datagridview [modified] Pin
hamed-vojdani18-Dec-09 7:31
hamed-vojdani18-Dec-09 7:31 
QuestionProblem in use skincrafter Pin
SajjadZare15-Dec-09 8:50
SajjadZare15-Dec-09 8:50 
AnswerRe: Problem in use skincrafter Pin
EliottA15-Dec-09 9:06
EliottA15-Dec-09 9:06 
QuestionCircular Dependancies! Pin
dae2200015-Dec-09 8:01
dae2200015-Dec-09 8:01 
AnswerRe: Circular Dependancies! Pin
Sir Dot Net15-Dec-09 9:12
Sir Dot Net15-Dec-09 9:12 
GeneralRe: Circular Dependancies! Pin
dae2200015-Dec-09 9:17
dae2200015-Dec-09 9:17 
AnswerRe: Circular Dependancies! Pin
_Maxxx_15-Dec-09 12:57
professional_Maxxx_15-Dec-09 12:57 
AnswerRe: Circular Dependancies! Pin
PIEBALDconsult15-Dec-09 17:19
mvePIEBALDconsult15-Dec-09 17:19 
GeneralRe: Circular Dependancies! Pin
Luc Pattyn15-Dec-09 23:47
sitebuilderLuc Pattyn15-Dec-09 23:47 
GeneralRe: Circular Dependancies! Pin
PIEBALDconsult16-Dec-09 4:01
mvePIEBALDconsult16-Dec-09 4:01 
AnswerRe: Circular Dependancies! Pin
Abhinav S15-Dec-09 17:35
Abhinav S15-Dec-09 17:35 
AnswerRe: Circular Dependancies! Pin
PIEBALDconsult16-Dec-09 3:53
mvePIEBALDconsult16-Dec-09 3:53 
GeneralRe: Circular Dependancies! Pin
dae2200016-Dec-09 8:40
dae2200016-Dec-09 8:40 

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.