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