private void FormReportPrepSummary_Load(object sender, EventArgs e) { DataTable1TableAdapter.Fill(this.DSPrepSummary.DataTable1, mAssignmentId); reportViewerPrepSummary.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.FullPage; reportViewerPrepSummary.RefreshReport(); }
private void btnCreateVersion_Click(object sender, EventArgs e) { if (mAssignment.WorkflowStatusId != WorkflowStatus.Complete) { MessageBox.Show("Order must be saved as complete first"); return; } int newVersion = mAssignment.AnalysisReportVersion + 1; if (mAssignment.AnalysisReportVersion > 0) { FormReportAuditComment form = new FormReportAuditComment(); if (form.ShowDialog() != DialogResult.OK) { return; } mAssignment.AuditComment += "v." + newVersion + ": " + form.SelectedComment + Environment.NewLine; } SqlConnection conn = null; try { conn = DB.OpenConnection(); mAssignment.AnalysisReportVersion = newVersion; mAssignment.Dirty = true; mAssignment.StoreToDB(conn, null); DataTable1TableAdapter.Fill(DSOrderReport.DataTable1, mAssignment.Name); DataTable2TableAdapter.Fill(DSOrderReport.DataTable2, mAssignment.Name); reportViewer.LocalReport.DataSources.Clear(); ReportDataSource rd1 = new ReportDataSource("DataSet1", DSOrderReport.Tables[0]); ReportDataSource rd2 = new ReportDataSource("DataSet2", DSOrderReport.Tables[1]); reportViewer.LocalReport.DataSources.Add(rd1); reportViewer.LocalReport.DataSources.Add(rd2); reportViewer.LocalReport.Refresh(); reportViewer.RefreshReport(); mContent = reportViewer.LocalReport.Render("PDF", ""); mHasNewVersion = true; btnCreateVersion.Enabled = false; } catch (Exception ex) { Common.Log.Error(ex); MessageBox.Show(ex.Message); } finally { conn?.Close(); } }
private void button1_Click_1(object sender, EventArgs e) { Report2 rep = new Report2(); DataSet1 ds = new DataSet1(); DataTable1TableAdapter ct = new DataTable1TableAdapter(); ct.Fill(ds.DataTable1); rep.SetDataSource(ds); rep.SetParameterValue("value", comboBox1.SelectedItem.ToString()); crystalReportViewer1.ReportSource = rep; }
private void FormReportViewer_Load(object sender, EventArgs e) { DataTable1TableAdapter.Fill(DSOrderReport.DataTable1, mAssignment.Name); DataTable2TableAdapter.Fill(DSOrderReport.DataTable2, mAssignment.Name); reportViewer.LocalReport.DataSources.Clear(); ReportDataSource rd1 = new ReportDataSource("DataSet1", DSOrderReport.Tables[0]); ReportDataSource rd2 = new ReportDataSource("DataSet2", DSOrderReport.Tables[1]); reportViewer.LocalReport.DataSources.Add(rd1); reportViewer.LocalReport.DataSources.Add(rd2); reportViewer.LocalReport.Refresh(); reportViewer.RefreshReport(); }
private void btnCreateVersion_Click(object sender, EventArgs e) { int newVersion = mAssignment.AnalysisReportVersion + 1; if (mAssignment.AnalysisReportVersion > 0) { FormReportAuditComment form = new FormReportAuditComment(); if (form.ShowDialog() != DialogResult.OK) { return; } mAssignment.AuditComment += "v." + newVersion + ": " + form.SelectedComment + Environment.NewLine; } SqlConnection conn = null; try { conn = DB.OpenConnection(); mAssignment.AnalysisReportVersion = newVersion; mAssignment.Dirty = true; mAssignment.StoreToDB(conn, null); } catch (Exception ex) { Common.Log.Error(ex); MessageBox.Show(ex.Message); return; } finally { conn?.Close(); } DataTable1TableAdapter.Fill(DSOrderReport.DataTable1, mAssignment.Name); reportViewer.RefreshReport(); mContent = reportViewer.LocalReport.Render("PDF", ""); mHasNewVersion = true; btnCreateVersion.Enabled = false; }
private void FormReportViewer_Load(object sender, EventArgs e) { DataTable1TableAdapter.Fill(DSOrderReport.DataTable1, mAssignment.Name); reportViewer.RefreshReport(); }
private void button1_Click(object sender, EventArgs e) { try { DialogResult result = openFileDialog1.ShowDialog(); // Atver dialogu, kur var izvēlēties failu if (result == DialogResult.OK) //Lai nospiežot cancel programma nenosprāgtu { string file = openFileDialog1.FileName; //Saglabā faila atrašanās vietu failasaturs = File.ReadAllText(file); // Simbolu virknē failasaturs saglabā visu faila tekstu } myConnection = new SqlConnection(); myConnection.ConnectionString = failasaturs; //Data Source=USER;initial catalog=md2;Integrated Security = True myConnection.Open(); DataTable1TableAdapter.Connection = myConnection; //Norādu, ka jāizmanto myConnection, nevis tas, kas saglabāts pie Properties->Connection DataTable1TableAdapter.Fill(DataSet1.DataTable1); //Aizpildu DataSetā tabulu DataTable reportViewer1.RefreshReport(); myConnection.Close(); } catch (FileNotFoundException) { MessageBox.Show("File not found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (InvalidOperationException) { MessageBox.Show("Cannot open a connection without specifying a data source or server", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (SqlException ex) { if (ex.Number == 53) { MessageBox.Show("Error: " + ex.Number.ToString() + "\nAn error has occurred while establishing a connection to the server.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (ex.Number == -2) { MessageBox.Show("Error: " + ex.Number.ToString() + "\nTimeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (ex.Number == 17) { MessageBox.Show("Error:" + ex.Number.ToString() + "\nInvalid server name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (ex.Number == 4060) { MessageBox.Show("Error: " + ex.Number.ToString() + "\nInvalid database name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (ex.Number == 18456) { MessageBox.Show("Error: " + ex.Number.ToString() + "\nInvalid user name or password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Error: " + ex.Number.ToString() + "\n" + ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show("Some error occurred: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Marks_Loaded(object sender, RoutedEventArgs e) { dtdt.Fill(ds.DataTable1); //Заполняем datagrid Marks.ItemsSource = ds.DataTable1; }