| [2] | 1 | using System;
|
|---|
| 2 | using System.Collections.Generic;
|
|---|
| 3 | using System.ComponentModel;
|
|---|
| 4 | using System.Data;
|
|---|
| 5 | using System.Data.SqlClient;
|
|---|
| 6 | using System.Drawing;
|
|---|
| 7 | using System.Text;
|
|---|
| 8 | using System.Windows.Forms;
|
|---|
| 9 | using Microsoft.Reporting.WinForms;
|
|---|
| 10 | using System.Drawing.Printing;
|
|---|
| 11 | using System.Drawing.Imaging;
|
|---|
| 12 | using System.Reflection;
|
|---|
| 13 | using System.IO;
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 | namespace Baza_Reklam
|
|---|
| 17 | {
|
|---|
| 18 | public partial class FactureViewer : Form
|
|---|
| 19 | {
|
|---|
| 20 | private int idFaktury;
|
|---|
| 21 | private int idKorekty;
|
|---|
| 22 |
|
|---|
| 23 | /// <summary>
|
|---|
| 24 | /// true - faktura, false - proforma
|
|---|
| 25 | /// </summary>
|
|---|
| 26 | bool rodzaj;
|
|---|
| 27 | DataSet ds;
|
|---|
| 28 |
|
|---|
| 29 | public FactureViewer(int idFakt,bool rodzaj)
|
|---|
| 30 | {
|
|---|
| 31 | InitializeComponent();
|
|---|
| 32 |
|
|---|
| 33 | idFaktury = idFakt;
|
|---|
| 34 |
|
|---|
| 35 | this.rodzaj = rodzaj;
|
|---|
| 36 |
|
|---|
| 37 | this.zapiszButton.Click += new EventHandler(zapiszButton_Click);
|
|---|
| 38 |
|
|---|
| 39 | fakturaTableAdapter1.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 40 | fakturA_DETAILSTableAdapter1.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 41 | fAKTURYTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 42 | proformaTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 43 |
|
|---|
| 44 | ds = new DataSet();
|
|---|
| 45 |
|
|---|
| 46 | //zczytuje dane z pliku z tlumaczeniami
|
|---|
| 47 | Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream("Baza_Reklam.Raporty.faktura.xml");
|
|---|
| 48 | ds.ReadXml(s);
|
|---|
| 49 |
|
|---|
| 50 | fAKTURYTableAdapter.FillByIdFaktury(this.rEKLAMADataSet.FAKTURY, idFakt);
|
|---|
| 51 |
|
|---|
| 52 | //ustawienie parametrów, nowych datasoure dla raportu
|
|---|
| 53 |
|
|---|
| 54 | //ustawianie danych dla raportu
|
|---|
| 55 | if (this.rodzaj)
|
|---|
| 56 | {
|
|---|
| 57 | typComboBox.Enabled = false;
|
|---|
| 58 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", fakturaTableAdapter1.GetDataByIdFaktury(idFakt)));
|
|---|
| 59 |
|
|---|
| 60 | }
|
|---|
| 61 | else {
|
|---|
| 62 | jezykComboBox.Enabled = false;
|
|---|
| 63 | reportViewer1.LocalReport.ReportEmbeddedResource = "Baza_Reklam.Raporty.proformaReversed.rdlc";
|
|---|
| 64 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", proformaTableAdapter.GetDataByIdFaktury(idFakt)));
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FakturaDetails", fakturA_DETAILSTableAdapter1.GetDataByIdFaktury(idFakt)));
|
|---|
| 68 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("tlumaczenia", ds.Tables[0]));
|
|---|
| 69 |
|
|---|
| 70 | List<ReportParameter> paramList = new List<ReportParameter>();
|
|---|
| 71 |
|
|---|
| 72 | //Produkcja ma domylnie bez podpisu
|
|---|
| 73 |
|
|---|
| 74 | if (User.getUser().St_produkcja)
|
|---|
| 75 | {
|
|---|
| 76 | podpisCheckBox.CheckState = CheckState.Unchecked;
|
|---|
| 77 | paramList.Add(new ReportParameter("podpis", podpisCheckBox.Checked.ToString(), true));
|
|---|
| 78 | this.reportViewer1.LocalReport.SetParameters(paramList);
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | //nadpisanie drukowania
|
|---|
| 82 | //this.reportViewer1.Print += new CancelEventHandler(HandlePrint);
|
|---|
| 83 | /*
|
|---|
| 84 | if (rodzaj)
|
|---|
| 85 | {
|
|---|
| 86 | this.reportViewer1.Print += new CancelEventHandler(HandlePrint);
|
|---|
| 87 | }
|
|---|
| 88 | */
|
|---|
| 89 |
|
|---|
| 90 | jezykComboBox.SelectedIndex = 0;
|
|---|
| 91 | typComboBox.SelectedIndex = 1;
|
|---|
| 92 |
|
|---|
| 93 | }
|
|---|
| 94 |
|
|---|
| 95 | public FactureViewer(int idFakt)
|
|---|
| 96 | {
|
|---|
| 97 | InitializeComponent();
|
|---|
| 98 |
|
|---|
| 99 | reportViewer1.LocalReport.ReportEmbeddedResource = "Baza_Reklam.Raporty.fakturaReversed2.rdlc";
|
|---|
| 100 | idFaktury = idFakt;
|
|---|
| 101 |
|
|---|
| 102 | this.zapiszButton.Click += zapiszButton2_Click;
|
|---|
| 103 |
|
|---|
| 104 | fakturaTableAdapter1.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 105 | fAKTURA_DETAILS2TableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 106 | fAKTURYTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 107 | proformaTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 108 |
|
|---|
| 109 | ds = new DataSet();
|
|---|
| 110 |
|
|---|
| 111 | //zczytuje dane z pliku z tlumaczeniami
|
|---|
| 112 | Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream("Baza_Reklam.Raporty.faktura.xml");
|
|---|
| 113 | ds.ReadXml(s);
|
|---|
| 114 |
|
|---|
| 115 | fAKTURYTableAdapter.FillByIdFaktury(this.rEKLAMADataSet.FAKTURY, idFakt);
|
|---|
| 116 |
|
|---|
| 117 | //ustawienie parametrów, nowych datasoure dla raportu
|
|---|
| 118 |
|
|---|
| 119 | //ustawianie danych dla raportu
|
|---|
| 120 | typComboBox.Enabled = false;
|
|---|
| 121 |
|
|---|
| 122 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", fakturaTableAdapter1.GetDataByIdFaktury(idFakt)));
|
|---|
| 123 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FakturaDetails2", fAKTURA_DETAILS2TableAdapter.GetDataIdFaktury(idFakt)));
|
|---|
| 124 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("tlumaczenia", ds.Tables[0]));
|
|---|
| 125 |
|
|---|
| 126 | List<ReportParameter> paramList = new List<ReportParameter>();
|
|---|
| 127 |
|
|---|
| 128 | //Produkcja ma domylnie bez podpisu
|
|---|
| 129 | if (User.getUser().St_produkcja)
|
|---|
| 130 | {
|
|---|
| 131 | podpisCheckBox.CheckState = CheckState.Unchecked;
|
|---|
| 132 | paramList.Add(new ReportParameter("podpis", podpisCheckBox.Checked.ToString(), true));
|
|---|
| 133 | this.reportViewer1.LocalReport.SetParameters(paramList);
|
|---|
| 134 | }
|
|---|
| 135 |
|
|---|
| 136 | jezykComboBox.SelectedIndex = 0;
|
|---|
| 137 | typComboBox.SelectedIndex = 1;
|
|---|
| 138 | }
|
|---|
| 139 |
|
|---|
| 140 | public FactureViewer(int idFakt, int idKorekty)
|
|---|
| 141 | {
|
|---|
| 142 | InitializeComponent();
|
|---|
| 143 |
|
|---|
| 144 | reportViewer1.LocalReport.ReportEmbeddedResource = "Baza_Reklam.Raporty.fakturaKorekta.rdlc";
|
|---|
| 145 |
|
|---|
| 146 | this.idFaktury = idFakt;
|
|---|
| 147 | this.idKorekty = idKorekty;
|
|---|
| 148 |
|
|---|
| 149 | this.zapiszButton.Click += zapiszKorektaButton_Click;
|
|---|
| 150 |
|
|---|
| 151 | fakturaTableAdapter1.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 152 | fAKTURA_DETAILS2TableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 153 | fAKTURYTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 154 | proformaTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 155 |
|
|---|
| 156 | ds = new DataSet();
|
|---|
| 157 |
|
|---|
| 158 | //zczytuje dane z pliku z tlumaczeniami
|
|---|
| 159 | Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream("Baza_Reklam.Raporty.faktura.xml");
|
|---|
| 160 | ds.ReadXml(s);
|
|---|
| 161 |
|
|---|
| [7] | 162 | fAKTURYTableAdapter.FillByIdFaktury(this.rEKLAMADataSet.FAKTURY, idKorekty);
|
|---|
| [2] | 163 |
|
|---|
| 164 | //ustawienie parametrów, nowych datasoure dla raportu
|
|---|
| 165 |
|
|---|
| 166 | typComboBox.Enabled = false;
|
|---|
| 167 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", fakturaTableAdapter1.GetDataByIdFaktury(idFakt)));
|
|---|
| [7] | 168 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Korekta", fakturaTableAdapter1.GetDataByIdFaktury(idKorekty)));
|
|---|
| [2] | 169 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FakturaDetails2", fAKTURA_DETAILS2TableAdapter.GetDataIdFaktury(idFakt)));
|
|---|
| 170 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FakturaDetailsKorekty", fAKTURA_DETAILS2TableAdapter.GetDataIdFaktury(idKorekty)));
|
|---|
| 171 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("tlumaczenia", ds.Tables[0]));
|
|---|
| 172 |
|
|---|
| 173 | List<ReportParameter> paramList = new List<ReportParameter>();
|
|---|
| 174 |
|
|---|
| 175 | //Produkcja ma domylnie bez podpisu
|
|---|
| 176 |
|
|---|
| 177 | if (User.getUser().St_produkcja)
|
|---|
| 178 | {
|
|---|
| 179 | podpisCheckBox.CheckState = CheckState.Unchecked;
|
|---|
| 180 | paramList.Add(new ReportParameter("podpis", podpisCheckBox.Checked.ToString(), true));
|
|---|
| 181 | this.reportViewer1.LocalReport.SetParameters(paramList);
|
|---|
| 182 | }
|
|---|
| 183 |
|
|---|
| 184 | //nadpisanie drukowania
|
|---|
| 185 | //this.reportViewer1.Print += new CancelEventHandler(HandlePrint);
|
|---|
| 186 | /*
|
|---|
| 187 | if (rodzaj)
|
|---|
| 188 | {
|
|---|
| 189 | this.reportViewer1.Print += new CancelEventHandler(HandlePrint);
|
|---|
| 190 | }
|
|---|
| 191 | */
|
|---|
| 192 |
|
|---|
| 193 | jezykComboBox.SelectedIndex = 0;
|
|---|
| 194 | typComboBox.SelectedIndex = 1;
|
|---|
| 195 |
|
|---|
| 196 | }
|
|---|
| 197 |
|
|---|
| 198 | /*
|
|---|
| 199 | /// <summary>
|
|---|
| 200 | /// FAKTURA DLA POZNANIA
|
|---|
| 201 | /// </summary>
|
|---|
| 202 | /// <param name="idFakt"></param>
|
|---|
| 203 | public FactureViewer(int idFakt)
|
|---|
| 204 | {
|
|---|
| 205 | InitializeComponent();
|
|---|
| 206 |
|
|---|
| 207 | idFaktury = idFakt;
|
|---|
| 208 |
|
|---|
| 209 | this.zapiszButton.Click += new EventHandler(zapiszPoznanButton_Click);
|
|---|
| 210 |
|
|---|
| 211 | fakturaTableAdapter1.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 212 | fakturA_DETAILSTableAdapter1.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 213 | fAKTURYTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 214 | proformaTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 215 |
|
|---|
| 216 | ds = new DataSet();
|
|---|
| 217 |
|
|---|
| 218 | //zczytuje dane z pliku z tlumaczeniami
|
|---|
| 219 | Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream("Baza_Reklam.Raporty.faktura.xml");
|
|---|
| 220 | ds.ReadXml(s);
|
|---|
| 221 |
|
|---|
| 222 | fAKTURYTableAdapter.FillByIdFaktury(this.rEKLAMADataSet.FAKTURY, idFakt);
|
|---|
| 223 |
|
|---|
| 224 | typComboBox.Enabled = false;
|
|---|
| 225 | // wersjaComboBox.Enabled = false;
|
|---|
| 226 | // jezykComboBox.Enabled = false;
|
|---|
| 227 |
|
|---|
| 228 | reportViewer1.LocalReport.ReportEmbeddedResource = "Baza_Reklam.Raporty.fakturaPoznan.rdlc";
|
|---|
| 229 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", fakturaTableAdapter1.GetDataByIdFaktury(idFakt)));
|
|---|
| 230 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FakturaDetails", fakturA_DETAILSTableAdapter1.GetDataByIdFaktury(idFakt)));
|
|---|
| 231 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("tlumaczenia", ds.Tables[0]));
|
|---|
| 232 |
|
|---|
| 233 | jezykComboBox.SelectedIndex = 0;
|
|---|
| 234 | typComboBox.SelectedIndex = 1;
|
|---|
| 235 | // wersjaComboBox.SelectedIndex = 0;
|
|---|
| 236 | }
|
|---|
| 237 | */
|
|---|
| 238 |
|
|---|
| 239 |
|
|---|
| 240 | private void FactureViewer_Load(object sender, EventArgs e)
|
|---|
| 241 | {
|
|---|
| 242 | this.reportViewer1.RefreshReport();
|
|---|
| 243 | this.reportViewer1.RefreshReport();
|
|---|
| 244 | }
|
|---|
| 245 |
|
|---|
| 246 | private void zapiszButton_Click(object sender, EventArgs e)
|
|---|
| 247 | {
|
|---|
| 248 | this.Cursor = Cursors.WaitCursor;
|
|---|
| 249 |
|
|---|
| 250 | //zapisanie zmian w polu "opis" faktury
|
|---|
| 251 | fAKTURYBindingSource.EndEdit();
|
|---|
| 252 | fAKTURYTableAdapter.Update(this.rEKLAMADataSet.FAKTURY);
|
|---|
| 253 | fAKTURYTableAdapter.FillByIdFaktury(this.rEKLAMADataSet.FAKTURY, idFaktury);
|
|---|
| 254 |
|
|---|
| 255 | reportViewer1.Reset();
|
|---|
| 256 | reportViewer1.LocalReport.ReportEmbeddedResource = this.rodzaj ? "Baza_Reklam.Raporty.fakturaReversed.rdlc" : "Baza_Reklam.Raporty.proformaReversed.rdlc";
|
|---|
| 257 |
|
|---|
| 258 | //ustawienie parametrów, nowych datasoure dla raportu
|
|---|
| 259 | List<ReportParameter> paramList = new List<ReportParameter>();
|
|---|
| 260 |
|
|---|
| 261 | if (this.rodzaj)
|
|---|
| 262 | {
|
|---|
| 263 | paramList.Add(new ReportParameter("jezyk", jezykComboBox.SelectedItem.ToString(), true));
|
|---|
| 264 | paramList.Add(new ReportParameter("podpis", podpisCheckBox.Checked.ToString(), true));
|
|---|
| 265 | this.reportViewer1.LocalReport.SetParameters(paramList);
|
|---|
| 266 | reportViewer1.LocalReport.DataSources.Clear();
|
|---|
| 267 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", fakturaTableAdapter1.GetDataByIdFaktury(idFaktury)));
|
|---|
| 268 |
|
|---|
| 269 | }
|
|---|
| 270 | else
|
|---|
| 271 | {
|
|---|
| 272 | paramList.Add(new ReportParameter("typ", typComboBox.SelectedItem.ToString(), true));
|
|---|
| 273 | paramList.Add(new ReportParameter("podpis", podpisCheckBox.Checked.ToString(), true));
|
|---|
| 274 | this.reportViewer1.LocalReport.SetParameters(paramList);
|
|---|
| 275 | reportViewer1.LocalReport.DataSources.Clear();
|
|---|
| 276 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", proformaTableAdapter.GetDataByIdFaktury(idFaktury)));
|
|---|
| 277 | }
|
|---|
| 278 |
|
|---|
| 279 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FakturaDetails", fakturA_DETAILSTableAdapter1.GetDataByIdFaktury(idFaktury)));
|
|---|
| 280 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("tlumaczenia", ds.Tables[0]));
|
|---|
| 281 |
|
|---|
| 282 | reportViewer1.RefreshReport();
|
|---|
| 283 | //MessageBox.Show(reportViewer1.LocalReport.ReportEmbeddedResource);
|
|---|
| 284 | this.Cursor = Cursors.Default;
|
|---|
| 285 |
|
|---|
| 286 | }
|
|---|
| 287 |
|
|---|
| 288 | /// <summary>
|
|---|
| 289 | /// WERSJA DLA POZNANIA
|
|---|
| 290 | /// </summary>
|
|---|
| 291 | private void zapiszPoznanButton_Click(object sender, EventArgs e)
|
|---|
| 292 | {
|
|---|
| 293 | this.Cursor = Cursors.WaitCursor;
|
|---|
| 294 |
|
|---|
| 295 | //zapisanie zmian w polu "opis" faktury
|
|---|
| 296 | fAKTURYBindingSource.EndEdit();
|
|---|
| 297 | fAKTURYTableAdapter.Update(this.rEKLAMADataSet.FAKTURY);
|
|---|
| [7] | 298 | fAKTURYTableAdapter.FillByIdFaktury(this.rEKLAMADataSet.FAKTURY,idKorekty);
|
|---|
| [2] | 299 |
|
|---|
| 300 | //ustawienie parametrów, nowych datasoure dla raportu
|
|---|
| 301 | List<ReportParameter> paramList = new List<ReportParameter>();
|
|---|
| 302 |
|
|---|
| 303 | paramList.Add(new ReportParameter("jezyk", jezykComboBox.SelectedItem.ToString(), true));
|
|---|
| 304 | paramList.Add(new ReportParameter("podpis", podpisCheckBox.Checked.ToString(), true));
|
|---|
| 305 | this.reportViewer1.LocalReport.SetParameters(paramList);
|
|---|
| 306 | reportViewer1.LocalReport.DataSources.Clear();
|
|---|
| 307 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", fakturaTableAdapter1.GetDataByIdFaktury(idFaktury)));
|
|---|
| [7] | 308 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Korekta", fakturaTableAdapter1.GetDataByIdFaktury(idKorekty)));
|
|---|
| [2] | 309 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FakturaDetails", fakturA_DETAILSTableAdapter1.GetDataByIdFaktury(idFaktury)));
|
|---|
| 310 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("tlumaczenia", ds.Tables[0]));
|
|---|
| 311 |
|
|---|
| 312 | reportViewer1.RefreshReport();
|
|---|
| 313 | //MessageBox.Show(reportViewer1.LocalReport.ReportEmbeddedResource);
|
|---|
| 314 | this.Cursor = Cursors.Default;
|
|---|
| 315 |
|
|---|
| 316 | }
|
|---|
| 317 |
|
|---|
| 318 | private void zapiszKorektaButton_Click(object sender, EventArgs e)
|
|---|
| 319 | {
|
|---|
| 320 | this.Cursor = Cursors.WaitCursor;
|
|---|
| 321 |
|
|---|
| 322 | //zapisanie zmian w polu "opis" faktury
|
|---|
| 323 | fAKTURYBindingSource.EndEdit();
|
|---|
| 324 | fAKTURYTableAdapter.Update(this.rEKLAMADataSet.FAKTURY);
|
|---|
| 325 | fAKTURYTableAdapter.FillByIdFaktury(this.rEKLAMADataSet.FAKTURY, idFaktury);
|
|---|
| 326 |
|
|---|
| 327 | //ustawienie parametrów, nowych datasoure dla raportu
|
|---|
| 328 | List<ReportParameter> paramList = new List<ReportParameter>();
|
|---|
| 329 |
|
|---|
| 330 | paramList.Add(new ReportParameter("jezyk", jezykComboBox.SelectedItem.ToString(), true));
|
|---|
| 331 | paramList.Add(new ReportParameter("podpis", podpisCheckBox.Checked.ToString(), true));
|
|---|
| 332 | this.reportViewer1.LocalReport.SetParameters(paramList);
|
|---|
| 333 | reportViewer1.LocalReport.DataSources.Clear();
|
|---|
| 334 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", fakturaTableAdapter1.GetDataByIdFaktury(idFaktury)));
|
|---|
| 335 |
|
|---|
| 336 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FakturaDetails2", fAKTURA_DETAILS2TableAdapter.GetDataIdFaktury(idFaktury)));
|
|---|
| 337 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FakturaDetailsKorekty", fAKTURA_DETAILS2TableAdapter.GetDataIdFaktury(idKorekty)));
|
|---|
| 338 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("tlumaczenia", ds.Tables[0]));
|
|---|
| 339 |
|
|---|
| 340 | reportViewer1.RefreshReport();
|
|---|
| 341 | //MessageBox.Show(reportViewer1.LocalReport.ReportEmbeddedResource);
|
|---|
| 342 | this.Cursor = Cursors.Default;
|
|---|
| 343 |
|
|---|
| 344 | }
|
|---|
| 345 |
|
|---|
| 346 | private void zapiszButton2_Click(object sender, EventArgs e)
|
|---|
| 347 | {
|
|---|
| 348 | this.Cursor = Cursors.WaitCursor;
|
|---|
| 349 |
|
|---|
| 350 | //zapisanie zmian w polu "opis" faktury
|
|---|
| 351 | fAKTURYBindingSource.EndEdit();
|
|---|
| 352 | fAKTURYTableAdapter.Update(this.rEKLAMADataSet.FAKTURY);
|
|---|
| 353 | fAKTURYTableAdapter.FillByIdFaktury(this.rEKLAMADataSet.FAKTURY, idFaktury);
|
|---|
| 354 |
|
|---|
| 355 | //ustawienie parametrów, nowych datasoure dla raportu
|
|---|
| 356 | List<ReportParameter> paramList = new List<ReportParameter>();
|
|---|
| 357 |
|
|---|
| 358 | paramList.Add(new ReportParameter("jezyk", jezykComboBox.SelectedItem.ToString(), true));
|
|---|
| 359 | paramList.Add(new ReportParameter("podpis", podpisCheckBox.Checked.ToString(), true));
|
|---|
| 360 | paramList.Add(new ReportParameter("proforma", proformaCheckBox.Checked.ToString(), true));
|
|---|
| 361 |
|
|---|
| 362 | this.reportViewer1.LocalReport.SetParameters(paramList);
|
|---|
| 363 | reportViewer1.LocalReport.DataSources.Clear();
|
|---|
| 364 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", fakturaTableAdapter1.GetDataByIdFaktury(idFaktury)));
|
|---|
| 365 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FakturaDetails2", fAKTURA_DETAILS2TableAdapter.GetDataIdFaktury(idFaktury)));
|
|---|
| 366 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("tlumaczenia", ds.Tables[0]));
|
|---|
| 367 |
|
|---|
| 368 | reportViewer1.RefreshReport();
|
|---|
| 369 | //MessageBox.Show(reportViewer1.LocalReport.ReportEmbeddedResource);
|
|---|
| 370 | this.Cursor = Cursors.Default;
|
|---|
| 371 |
|
|---|
| 372 | }
|
|---|
| 373 |
|
|---|
| 374 | //drukowanie raportu serwerowego
|
|---|
| 375 | /*
|
|---|
| 376 | private int m_currentPageIndex;
|
|---|
| 377 | private IList<Stream> m_streams;
|
|---|
| 378 |
|
|---|
| 379 |
|
|---|
| 380 | public void HandlePrint(object sender, CancelEventArgs e)
|
|---|
| 381 | {
|
|---|
| 382 | Run();
|
|---|
| 383 | //MessageBox.Show("Drukowanie");
|
|---|
| 384 | e.Cancel = true;
|
|---|
| 385 | }
|
|---|
| 386 |
|
|---|
| 387 | private void Print(PrinterSettings printerSettings)
|
|---|
| 388 | {
|
|---|
| 389 | MessageBox.Show("PrintBegin");
|
|---|
| 390 | if (m_streams == null || m_streams.Count == 0)
|
|---|
| 391 | return;
|
|---|
| 392 |
|
|---|
| 393 | PrintDocument printDoc = new PrintDocument();
|
|---|
| 394 | printDoc.PrinterSettings = printerSettings;
|
|---|
| 395 | printDoc.PrintPage += new PrintPageEventHandler(PrintPage);
|
|---|
| 396 | MessageBox.Show("Print");
|
|---|
| 397 | printDoc.Print();
|
|---|
| 398 | }
|
|---|
| 399 |
|
|---|
| 400 | private void Run()
|
|---|
| 401 | {
|
|---|
| 402 | PrintDialog printDialog = new PrintDialog();
|
|---|
| 403 | if (printDialog.ShowDialog() == DialogResult.OK)
|
|---|
| 404 | {
|
|---|
| 405 | MessageBox.Show("Export");
|
|---|
| 406 | Export(reportViewer1.ServerReport);
|
|---|
| 407 | m_currentPageIndex = 0;
|
|---|
| 408 | MessageBox.Show("Print");
|
|---|
| 409 | Print(printDialog.PrinterSettings);
|
|---|
| 410 | }
|
|---|
| 411 | }
|
|---|
| 412 |
|
|---|
| 413 | private void PrintPage(object sender, PrintPageEventArgs ev)
|
|---|
| 414 | {
|
|---|
| 415 | MessageBox.Show("PrintPage1");
|
|---|
| 416 | Metafile pageImage = new Metafile(m_streams[m_currentPageIndex]);
|
|---|
| 417 | pageImage.Save("C:\\testestPRO.emf");
|
|---|
| 418 |
|
|---|
| 419 | // Note: Coordinate (0,0) does not coincide with the top left corner of
|
|---|
| 420 | // the page; it coincides with the top left corner of the printable area
|
|---|
| 421 | // of the page. To account for this we have to subtract the hard margin.
|
|---|
| 422 |
|
|---|
| 423 | MessageBox.Show("PrintPage2nnn");
|
|---|
| 424 | RectangleF adjustedRect = new RectangleF(
|
|---|
| 425 | ev.PageBounds.Left - ev.PageSettings.HardMarginX,
|
|---|
| 426 | ev.PageBounds.Top - ev.PageSettings.HardMarginY,
|
|---|
| 427 | ev.PageBounds.Width, ev.PageBounds.Height);
|
|---|
| 428 | MessageBox.Show(adjustedRect.Top.ToString() + "*" + adjustedRect.Height.ToString() + "*" + adjustedRect.Width.ToString());
|
|---|
| 429 | ev.Graphics.DrawImage(pageImage, adjustedRect);
|
|---|
| 430 | MessageBox.Show("PrintPage4");
|
|---|
| 431 | m_currentPageIndex++;
|
|---|
| 432 | ev.HasMorePages = (m_currentPageIndex < m_streams.Count);
|
|---|
| 433 | MessageBox.Show("PrintPage5");
|
|---|
| 434 | }
|
|---|
| 435 |
|
|---|
| 436 | private void Export(ServerReport report)
|
|---|
| 437 | {
|
|---|
| 438 | MessageBox.Show("ExportBegin");
|
|---|
| 439 |
|
|---|
| 440 | string deviceInfo =
|
|---|
| 441 |
|
|---|
| 442 | "<DeviceInfo>" +
|
|---|
| 443 |
|
|---|
| 444 | " <OutputFormat>EMF</OutputFormat>" +
|
|---|
| 445 |
|
|---|
| 446 | " <PageWidth>21cm</PageWidth>" +
|
|---|
| 447 |
|
|---|
| 448 | " <PageHeight>29cm</PageHeight>" +
|
|---|
| 449 |
|
|---|
| 450 | " <MarginTop>1cm</MarginTop>" +
|
|---|
| 451 |
|
|---|
| 452 | " <MarginLeft>1cm</MarginLeft>" +
|
|---|
| 453 |
|
|---|
| 454 | " <MarginRight>1cm</MarginRight>" +
|
|---|
| 455 |
|
|---|
| 456 | " <MarginBottom>1cm</MarginBottom>" +
|
|---|
| 457 |
|
|---|
| 458 | "</DeviceInfo>";
|
|---|
| 459 |
|
|---|
| 460 | m_streams = new List<Stream>();
|
|---|
| 461 | string mimeType;
|
|---|
| 462 | string extension;
|
|---|
| 463 | System.Collections.Specialized.NameValueCollection urlAccessParameters = new System.Collections.Specialized.NameValueCollection();
|
|---|
| 464 | urlAccessParameters.Add("rs:PersistStreams", "True");
|
|---|
| 465 | Stream reportStream = report.Render("Image", deviceInfo, urlAccessParameters, out mimeType, out extension);
|
|---|
| 466 | m_streams.Add(reportStream);
|
|---|
| 467 | urlAccessParameters.Remove("rs:PersistStreams");
|
|---|
| 468 | urlAccessParameters.Add("rs:GetNextStream", "True");
|
|---|
| 469 | while (reportStream.Length != 0)
|
|---|
| 470 | {
|
|---|
| 471 | reportStream =
|
|---|
| 472 | report.Render("Image", deviceInfo, urlAccessParameters, out mimeType, out extension);
|
|---|
| 473 | m_streams.Add(reportStream);
|
|---|
| 474 | }
|
|---|
| 475 |
|
|---|
| 476 | m_streams.RemoveAt(m_streams.Count - 1);
|
|---|
| 477 |
|
|---|
| 478 | foreach (Stream stream in m_streams)
|
|---|
| 479 | stream.Position = 0;
|
|---|
| 480 |
|
|---|
| 481 | MessageBox.Show("ExportEnd");
|
|---|
| 482 | }
|
|---|
| 483 | */
|
|---|
| 484 |
|
|---|
| 485 | // drukowanie raportu lokalnego
|
|---|
| 486 | private int m_currentPageIndex;
|
|---|
| 487 | private IList<Stream> m_streams;
|
|---|
| 488 |
|
|---|
| 489 | private Stream CreateStream(string name,
|
|---|
| 490 | string fileNameExtension, Encoding encoding,
|
|---|
| 491 | string mimeType, bool willSeek)
|
|---|
| 492 | {
|
|---|
| 493 | Stream stream = new FileStream(name +
|
|---|
| 494 | "." + fileNameExtension, FileMode.Create);
|
|---|
| 495 | m_streams.Add(stream);
|
|---|
| 496 | return stream;
|
|---|
| 497 | }
|
|---|
| 498 |
|
|---|
| 499 | private void Export(LocalReport report)
|
|---|
| 500 | {
|
|---|
| 501 | string deviceInfo =
|
|---|
| 502 | "<DeviceInfo>" +
|
|---|
| 503 | " <OutputFormat>EMF</OutputFormat>" +
|
|---|
| 504 | " <PageWidth>19cm</PageWidth>" +
|
|---|
| 505 | " <PageHeight>25cm</PageHeight>" +
|
|---|
| 506 | " <MarginTop>1cm</MarginTop>" +
|
|---|
| 507 | " <MarginLeft>1cm</MarginLeft>" +
|
|---|
| 508 | " <MarginRight>1cm</MarginRight>" +
|
|---|
| 509 | " <MarginBottom>0cm</MarginBottom>" +
|
|---|
| 510 | "</DeviceInfo>";
|
|---|
| 511 | Warning[] warnings;
|
|---|
| 512 | m_streams = new List<Stream>();
|
|---|
| 513 | report.Render("Image", deviceInfo, CreateStream,
|
|---|
| 514 | out warnings);
|
|---|
| 515 | foreach (Stream stream in m_streams)
|
|---|
| 516 | stream.Position = 0;
|
|---|
| 517 | }
|
|---|
| 518 |
|
|---|
| 519 | private void PrintPage(object sender, PrintPageEventArgs ev)
|
|---|
| 520 | {
|
|---|
| 521 | Metafile pageImage = new
|
|---|
| 522 | Metafile(m_streams[m_currentPageIndex]);
|
|---|
| 523 | ev.Graphics.DrawImage(pageImage, ev.PageBounds);
|
|---|
| 524 | m_currentPageIndex++;
|
|---|
| 525 | ev.HasMorePages = (m_currentPageIndex < m_streams.Count);
|
|---|
| 526 | }
|
|---|
| 527 |
|
|---|
| 528 | private void Print(PrinterSettings printerSettings)
|
|---|
| 529 | {
|
|---|
| 530 | if (m_streams == null || m_streams.Count == 0)
|
|---|
| 531 | return;
|
|---|
| 532 |
|
|---|
| 533 | PrintDocument printDoc = new PrintDocument();
|
|---|
| 534 | printDoc.PrinterSettings = printerSettings;
|
|---|
| 535 | printDoc.PrinterSettings.Duplex = Duplex.Vertical;
|
|---|
| 536 | printDoc.PrintPage += new PrintPageEventHandler(PrintPage);
|
|---|
| 537 | printDoc.Print();
|
|---|
| 538 | }
|
|---|
| 539 |
|
|---|
| 540 | private void Run()
|
|---|
| 541 | {
|
|---|
| 542 | PrintDialog printDialog = new PrintDialog();
|
|---|
| 543 | if (printDialog.ShowDialog() == DialogResult.OK)
|
|---|
| 544 | {
|
|---|
| 545 | Export(reportViewer1.LocalReport);
|
|---|
| 546 | m_currentPageIndex = 0;
|
|---|
| 547 | Print(printDialog.PrinterSettings);
|
|---|
| 548 | Dispose();
|
|---|
| 549 | }
|
|---|
| 550 |
|
|---|
| 551 | }
|
|---|
| 552 |
|
|---|
| 553 | public void Dispose()
|
|---|
| 554 | {
|
|---|
| 555 | if (m_streams != null)
|
|---|
| 556 | {
|
|---|
| 557 | foreach (Stream stream in m_streams)
|
|---|
| 558 | stream.Close();
|
|---|
| 559 | m_streams = null;
|
|---|
| 560 | }
|
|---|
| 561 | }
|
|---|
| 562 |
|
|---|
| 563 | public void HandlePrint(object sender, CancelEventArgs e)
|
|---|
| 564 | {
|
|---|
| 565 | Run();
|
|---|
| 566 | e.Cancel = true;
|
|---|
| 567 | }
|
|---|
| 568 |
|
|---|
| 569 |
|
|---|
| 570 | }
|
|---|
| 571 | } |
|---|