| [65] | 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 |
|
|---|
| [70] | 162 | fAKTURYTableAdapter.FillByIdFaktury(this.rEKLAMADataSet.FAKTURY, idKorekty);
|
|---|
| [65] | 163 |
|
|---|
| 164 | //ustawienie parametrów, nowych datasoure dla raportu
|
|---|
| 165 |
|
|---|
| 166 | typComboBox.Enabled = false;
|
|---|
| [80] | 167 |
|
|---|
| 168 | raporty.FakturaDataTable korektaTable = fakturaTableAdapter1.GetDataByIdFaktury(idKorekty);
|
|---|
| 169 | raporty.FakturaRow korekta = korektaTable[0];
|
|---|
| 170 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Korekta",korektaTable));
|
|---|
| [65] | 171 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", fakturaTableAdapter1.GetDataByIdFaktury(idFakt)));
|
|---|
| [80] | 172 |
|
|---|
| 173 | //piersza korekta
|
|---|
| 174 | if (korekta.idFakturyKorekta == idFaktury)
|
|---|
| 175 | {
|
|---|
| 176 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FakturaDetails2", fAKTURA_DETAILS2TableAdapter.GetDataIdFaktury(idFakt)));
|
|---|
| 177 | }
|
|---|
| 178 | else
|
|---|
| 179 | {
|
|---|
| 180 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FakturaDetails2", fAKTURA_DETAILS2TableAdapter.GetDataIdFaktury(korekta.idFakturyKorekta)));
|
|---|
| 181 | }
|
|---|
| [65] | 182 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FakturaDetailsKorekty", fAKTURA_DETAILS2TableAdapter.GetDataIdFaktury(idKorekty)));
|
|---|
| 183 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("tlumaczenia", ds.Tables[0]));
|
|---|
| 184 |
|
|---|
| 185 | List<ReportParameter> paramList = new List<ReportParameter>();
|
|---|
| 186 |
|
|---|
| 187 | //Produkcja ma domylnie bez podpisu
|
|---|
| 188 |
|
|---|
| 189 | if (User.getUser().St_produkcja)
|
|---|
| 190 | {
|
|---|
| 191 | podpisCheckBox.CheckState = CheckState.Unchecked;
|
|---|
| 192 | paramList.Add(new ReportParameter("podpis", podpisCheckBox.Checked.ToString(), true));
|
|---|
| 193 | this.reportViewer1.LocalReport.SetParameters(paramList);
|
|---|
| 194 | }
|
|---|
| 195 |
|
|---|
| 196 | //nadpisanie drukowania
|
|---|
| 197 | //this.reportViewer1.Print += new CancelEventHandler(HandlePrint);
|
|---|
| 198 | /*
|
|---|
| 199 | if (rodzaj)
|
|---|
| 200 | {
|
|---|
| 201 | this.reportViewer1.Print += new CancelEventHandler(HandlePrint);
|
|---|
| 202 | }
|
|---|
| 203 | */
|
|---|
| 204 |
|
|---|
| 205 | jezykComboBox.SelectedIndex = 0;
|
|---|
| 206 | typComboBox.SelectedIndex = 1;
|
|---|
| 207 |
|
|---|
| 208 | }
|
|---|
| 209 |
|
|---|
| 210 | /*
|
|---|
| 211 | /// <summary>
|
|---|
| 212 | /// FAKTURA DLA POZNANIA
|
|---|
| 213 | /// </summary>
|
|---|
| 214 | /// <param name="idFakt"></param>
|
|---|
| 215 | public FactureViewer(int idFakt)
|
|---|
| 216 | {
|
|---|
| 217 | InitializeComponent();
|
|---|
| 218 |
|
|---|
| 219 | idFaktury = idFakt;
|
|---|
| 220 |
|
|---|
| 221 | this.zapiszButton.Click += new EventHandler(zapiszPoznanButton_Click);
|
|---|
| 222 |
|
|---|
| 223 | fakturaTableAdapter1.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 224 | fakturA_DETAILSTableAdapter1.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 225 | fAKTURYTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 226 | proformaTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 227 |
|
|---|
| 228 | ds = new DataSet();
|
|---|
| 229 |
|
|---|
| 230 | //zczytuje dane z pliku z tlumaczeniami
|
|---|
| 231 | Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream("Baza_Reklam.Raporty.faktura.xml");
|
|---|
| 232 | ds.ReadXml(s);
|
|---|
| 233 |
|
|---|
| 234 | fAKTURYTableAdapter.FillByIdFaktury(this.rEKLAMADataSet.FAKTURY, idFakt);
|
|---|
| 235 |
|
|---|
| 236 | typComboBox.Enabled = false;
|
|---|
| 237 | // wersjaComboBox.Enabled = false;
|
|---|
| 238 | // jezykComboBox.Enabled = false;
|
|---|
| 239 |
|
|---|
| 240 | reportViewer1.LocalReport.ReportEmbeddedResource = "Baza_Reklam.Raporty.fakturaPoznan.rdlc";
|
|---|
| 241 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", fakturaTableAdapter1.GetDataByIdFaktury(idFakt)));
|
|---|
| 242 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FakturaDetails", fakturA_DETAILSTableAdapter1.GetDataByIdFaktury(idFakt)));
|
|---|
| 243 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("tlumaczenia", ds.Tables[0]));
|
|---|
| 244 |
|
|---|
| 245 | jezykComboBox.SelectedIndex = 0;
|
|---|
| 246 | typComboBox.SelectedIndex = 1;
|
|---|
| 247 | // wersjaComboBox.SelectedIndex = 0;
|
|---|
| 248 | }
|
|---|
| 249 | */
|
|---|
| 250 |
|
|---|
| 251 |
|
|---|
| 252 | private void FactureViewer_Load(object sender, EventArgs e)
|
|---|
| 253 | {
|
|---|
| 254 | this.reportViewer1.RefreshReport();
|
|---|
| 255 | this.reportViewer1.RefreshReport();
|
|---|
| [73] | 256 |
|
|---|
| 257 | nUMERTextBox.Enabled = User.getUser().St_kierownik;
|
|---|
| [65] | 258 | }
|
|---|
| 259 |
|
|---|
| 260 | private void zapiszButton_Click(object sender, EventArgs e)
|
|---|
| 261 | {
|
|---|
| 262 | this.Cursor = Cursors.WaitCursor;
|
|---|
| 263 |
|
|---|
| 264 | //zapisanie zmian w polu "opis" faktury
|
|---|
| 265 | fAKTURYBindingSource.EndEdit();
|
|---|
| 266 | fAKTURYTableAdapter.Update(this.rEKLAMADataSet.FAKTURY);
|
|---|
| 267 | fAKTURYTableAdapter.FillByIdFaktury(this.rEKLAMADataSet.FAKTURY, idFaktury);
|
|---|
| 268 |
|
|---|
| 269 | reportViewer1.Reset();
|
|---|
| 270 | reportViewer1.LocalReport.ReportEmbeddedResource = this.rodzaj ? "Baza_Reklam.Raporty.fakturaReversed.rdlc" : "Baza_Reklam.Raporty.proformaReversed.rdlc";
|
|---|
| 271 |
|
|---|
| 272 | //ustawienie parametrów, nowych datasoure dla raportu
|
|---|
| 273 | List<ReportParameter> paramList = new List<ReportParameter>();
|
|---|
| 274 |
|
|---|
| 275 | if (this.rodzaj)
|
|---|
| 276 | {
|
|---|
| 277 | paramList.Add(new ReportParameter("jezyk", jezykComboBox.SelectedItem.ToString(), true));
|
|---|
| 278 | paramList.Add(new ReportParameter("podpis", podpisCheckBox.Checked.ToString(), true));
|
|---|
| 279 | this.reportViewer1.LocalReport.SetParameters(paramList);
|
|---|
| 280 | reportViewer1.LocalReport.DataSources.Clear();
|
|---|
| 281 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", fakturaTableAdapter1.GetDataByIdFaktury(idFaktury)));
|
|---|
| 282 |
|
|---|
| 283 | }
|
|---|
| 284 | else
|
|---|
| 285 | {
|
|---|
| 286 | paramList.Add(new ReportParameter("typ", typComboBox.SelectedItem.ToString(), true));
|
|---|
| 287 | paramList.Add(new ReportParameter("podpis", podpisCheckBox.Checked.ToString(), true));
|
|---|
| 288 | this.reportViewer1.LocalReport.SetParameters(paramList);
|
|---|
| 289 | reportViewer1.LocalReport.DataSources.Clear();
|
|---|
| 290 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", proformaTableAdapter.GetDataByIdFaktury(idFaktury)));
|
|---|
| 291 | }
|
|---|
| 292 |
|
|---|
| 293 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FakturaDetails", fakturA_DETAILSTableAdapter1.GetDataByIdFaktury(idFaktury)));
|
|---|
| 294 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("tlumaczenia", ds.Tables[0]));
|
|---|
| 295 |
|
|---|
| 296 | reportViewer1.RefreshReport();
|
|---|
| 297 | //MessageBox.Show(reportViewer1.LocalReport.ReportEmbeddedResource);
|
|---|
| 298 | this.Cursor = Cursors.Default;
|
|---|
| 299 |
|
|---|
| 300 | }
|
|---|
| 301 |
|
|---|
| 302 | /// <summary>
|
|---|
| 303 | /// WERSJA DLA POZNANIA
|
|---|
| 304 | /// </summary>
|
|---|
| 305 | private void zapiszPoznanButton_Click(object sender, EventArgs e)
|
|---|
| 306 | {
|
|---|
| 307 | this.Cursor = Cursors.WaitCursor;
|
|---|
| 308 |
|
|---|
| 309 | //zapisanie zmian w polu "opis" faktury
|
|---|
| 310 | fAKTURYBindingSource.EndEdit();
|
|---|
| 311 | fAKTURYTableAdapter.Update(this.rEKLAMADataSet.FAKTURY);
|
|---|
| [70] | 312 | fAKTURYTableAdapter.FillByIdFaktury(this.rEKLAMADataSet.FAKTURY,idKorekty);
|
|---|
| [65] | 313 |
|
|---|
| 314 | //ustawienie parametrów, nowych datasoure dla raportu
|
|---|
| 315 | List<ReportParameter> paramList = new List<ReportParameter>();
|
|---|
| 316 |
|
|---|
| 317 | paramList.Add(new ReportParameter("jezyk", jezykComboBox.SelectedItem.ToString(), true));
|
|---|
| 318 | paramList.Add(new ReportParameter("podpis", podpisCheckBox.Checked.ToString(), true));
|
|---|
| 319 | this.reportViewer1.LocalReport.SetParameters(paramList);
|
|---|
| 320 | reportViewer1.LocalReport.DataSources.Clear();
|
|---|
| 321 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", fakturaTableAdapter1.GetDataByIdFaktury(idFaktury)));
|
|---|
| [70] | 322 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Korekta", fakturaTableAdapter1.GetDataByIdFaktury(idKorekty)));
|
|---|
| [65] | 323 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FakturaDetails", fakturA_DETAILSTableAdapter1.GetDataByIdFaktury(idFaktury)));
|
|---|
| 324 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("tlumaczenia", ds.Tables[0]));
|
|---|
| 325 |
|
|---|
| 326 | reportViewer1.RefreshReport();
|
|---|
| 327 | //MessageBox.Show(reportViewer1.LocalReport.ReportEmbeddedResource);
|
|---|
| 328 | this.Cursor = Cursors.Default;
|
|---|
| 329 |
|
|---|
| 330 | }
|
|---|
| 331 |
|
|---|
| 332 | private void zapiszKorektaButton_Click(object sender, EventArgs e)
|
|---|
| 333 | {
|
|---|
| 334 | this.Cursor = Cursors.WaitCursor;
|
|---|
| 335 |
|
|---|
| 336 | //zapisanie zmian w polu "opis" faktury
|
|---|
| 337 | fAKTURYBindingSource.EndEdit();
|
|---|
| 338 | fAKTURYTableAdapter.Update(this.rEKLAMADataSet.FAKTURY);
|
|---|
| 339 | fAKTURYTableAdapter.FillByIdFaktury(this.rEKLAMADataSet.FAKTURY, idFaktury);
|
|---|
| 340 |
|
|---|
| 341 | //ustawienie parametrów, nowych datasoure dla raportu
|
|---|
| 342 | List<ReportParameter> paramList = new List<ReportParameter>();
|
|---|
| 343 |
|
|---|
| 344 | paramList.Add(new ReportParameter("jezyk", jezykComboBox.SelectedItem.ToString(), true));
|
|---|
| 345 | paramList.Add(new ReportParameter("podpis", podpisCheckBox.Checked.ToString(), true));
|
|---|
| 346 | this.reportViewer1.LocalReport.SetParameters(paramList);
|
|---|
| 347 | reportViewer1.LocalReport.DataSources.Clear();
|
|---|
| 348 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", fakturaTableAdapter1.GetDataByIdFaktury(idFaktury)));
|
|---|
| 349 |
|
|---|
| 350 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FakturaDetails2", fAKTURA_DETAILS2TableAdapter.GetDataIdFaktury(idFaktury)));
|
|---|
| 351 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FakturaDetailsKorekty", fAKTURA_DETAILS2TableAdapter.GetDataIdFaktury(idKorekty)));
|
|---|
| 352 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("tlumaczenia", ds.Tables[0]));
|
|---|
| 353 |
|
|---|
| 354 | reportViewer1.RefreshReport();
|
|---|
| 355 | //MessageBox.Show(reportViewer1.LocalReport.ReportEmbeddedResource);
|
|---|
| 356 | this.Cursor = Cursors.Default;
|
|---|
| 357 |
|
|---|
| 358 | }
|
|---|
| 359 |
|
|---|
| 360 | private void zapiszButton2_Click(object sender, EventArgs e)
|
|---|
| 361 | {
|
|---|
| 362 | this.Cursor = Cursors.WaitCursor;
|
|---|
| 363 |
|
|---|
| 364 | //zapisanie zmian w polu "opis" faktury
|
|---|
| 365 | fAKTURYBindingSource.EndEdit();
|
|---|
| 366 | fAKTURYTableAdapter.Update(this.rEKLAMADataSet.FAKTURY);
|
|---|
| 367 | fAKTURYTableAdapter.FillByIdFaktury(this.rEKLAMADataSet.FAKTURY, idFaktury);
|
|---|
| 368 |
|
|---|
| 369 | //ustawienie parametrów, nowych datasoure dla raportu
|
|---|
| 370 | List<ReportParameter> paramList = new List<ReportParameter>();
|
|---|
| 371 |
|
|---|
| 372 | paramList.Add(new ReportParameter("jezyk", jezykComboBox.SelectedItem.ToString(), true));
|
|---|
| 373 | paramList.Add(new ReportParameter("podpis", podpisCheckBox.Checked.ToString(), true));
|
|---|
| 374 | paramList.Add(new ReportParameter("proforma", proformaCheckBox.Checked.ToString(), true));
|
|---|
| 375 |
|
|---|
| 376 | this.reportViewer1.LocalReport.SetParameters(paramList);
|
|---|
| 377 | reportViewer1.LocalReport.DataSources.Clear();
|
|---|
| 378 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", fakturaTableAdapter1.GetDataByIdFaktury(idFaktury)));
|
|---|
| 379 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FakturaDetails2", fAKTURA_DETAILS2TableAdapter.GetDataIdFaktury(idFaktury)));
|
|---|
| 380 | reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("tlumaczenia", ds.Tables[0]));
|
|---|
| 381 |
|
|---|
| 382 | reportViewer1.RefreshReport();
|
|---|
| 383 | //MessageBox.Show(reportViewer1.LocalReport.ReportEmbeddedResource);
|
|---|
| 384 | this.Cursor = Cursors.Default;
|
|---|
| 385 |
|
|---|
| 386 | }
|
|---|
| 387 |
|
|---|
| 388 | //drukowanie raportu serwerowego
|
|---|
| 389 | /*
|
|---|
| 390 | private int m_currentPageIndex;
|
|---|
| 391 | private IList<Stream> m_streams;
|
|---|
| 392 |
|
|---|
| 393 |
|
|---|
| 394 | public void HandlePrint(object sender, CancelEventArgs e)
|
|---|
| 395 | {
|
|---|
| 396 | Run();
|
|---|
| 397 | //MessageBox.Show("Drukowanie");
|
|---|
| 398 | e.Cancel = true;
|
|---|
| 399 | }
|
|---|
| 400 |
|
|---|
| 401 | private void Print(PrinterSettings printerSettings)
|
|---|
| 402 | {
|
|---|
| 403 | MessageBox.Show("PrintBegin");
|
|---|
| 404 | if (m_streams == null || m_streams.Count == 0)
|
|---|
| 405 | return;
|
|---|
| 406 |
|
|---|
| 407 | PrintDocument printDoc = new PrintDocument();
|
|---|
| 408 | printDoc.PrinterSettings = printerSettings;
|
|---|
| 409 | printDoc.PrintPage += new PrintPageEventHandler(PrintPage);
|
|---|
| 410 | MessageBox.Show("Print");
|
|---|
| 411 | printDoc.Print();
|
|---|
| 412 | }
|
|---|
| 413 |
|
|---|
| 414 | private void Run()
|
|---|
| 415 | {
|
|---|
| 416 | PrintDialog printDialog = new PrintDialog();
|
|---|
| 417 | if (printDialog.ShowDialog() == DialogResult.OK)
|
|---|
| 418 | {
|
|---|
| 419 | MessageBox.Show("Export");
|
|---|
| 420 | Export(reportViewer1.ServerReport);
|
|---|
| 421 | m_currentPageIndex = 0;
|
|---|
| 422 | MessageBox.Show("Print");
|
|---|
| 423 | Print(printDialog.PrinterSettings);
|
|---|
| 424 | }
|
|---|
| 425 | }
|
|---|
| 426 |
|
|---|
| 427 | private void PrintPage(object sender, PrintPageEventArgs ev)
|
|---|
| 428 | {
|
|---|
| 429 | MessageBox.Show("PrintPage1");
|
|---|
| 430 | Metafile pageImage = new Metafile(m_streams[m_currentPageIndex]);
|
|---|
| 431 | pageImage.Save("C:\\testestPRO.emf");
|
|---|
| 432 |
|
|---|
| 433 | // Note: Coordinate (0,0) does not coincide with the top left corner of
|
|---|
| 434 | // the page; it coincides with the top left corner of the printable area
|
|---|
| 435 | // of the page. To account for this we have to subtract the hard margin.
|
|---|
| 436 |
|
|---|
| 437 | MessageBox.Show("PrintPage2nnn");
|
|---|
| 438 | RectangleF adjustedRect = new RectangleF(
|
|---|
| 439 | ev.PageBounds.Left - ev.PageSettings.HardMarginX,
|
|---|
| 440 | ev.PageBounds.Top - ev.PageSettings.HardMarginY,
|
|---|
| 441 | ev.PageBounds.Width, ev.PageBounds.Height);
|
|---|
| 442 | MessageBox.Show(adjustedRect.Top.ToString() + "*" + adjustedRect.Height.ToString() + "*" + adjustedRect.Width.ToString());
|
|---|
| 443 | ev.Graphics.DrawImage(pageImage, adjustedRect);
|
|---|
| 444 | MessageBox.Show("PrintPage4");
|
|---|
| 445 | m_currentPageIndex++;
|
|---|
| 446 | ev.HasMorePages = (m_currentPageIndex < m_streams.Count);
|
|---|
| 447 | MessageBox.Show("PrintPage5");
|
|---|
| 448 | }
|
|---|
| 449 |
|
|---|
| 450 | private void Export(ServerReport report)
|
|---|
| 451 | {
|
|---|
| 452 | MessageBox.Show("ExportBegin");
|
|---|
| 453 |
|
|---|
| 454 | string deviceInfo =
|
|---|
| 455 |
|
|---|
| 456 | "<DeviceInfo>" +
|
|---|
| 457 |
|
|---|
| 458 | " <OutputFormat>EMF</OutputFormat>" +
|
|---|
| 459 |
|
|---|
| 460 | " <PageWidth>21cm</PageWidth>" +
|
|---|
| 461 |
|
|---|
| 462 | " <PageHeight>29cm</PageHeight>" +
|
|---|
| 463 |
|
|---|
| 464 | " <MarginTop>1cm</MarginTop>" +
|
|---|
| 465 |
|
|---|
| 466 | " <MarginLeft>1cm</MarginLeft>" +
|
|---|
| 467 |
|
|---|
| 468 | " <MarginRight>1cm</MarginRight>" +
|
|---|
| 469 |
|
|---|
| 470 | " <MarginBottom>1cm</MarginBottom>" +
|
|---|
| 471 |
|
|---|
| 472 | "</DeviceInfo>";
|
|---|
| 473 |
|
|---|
| 474 | m_streams = new List<Stream>();
|
|---|
| 475 | string mimeType;
|
|---|
| 476 | string extension;
|
|---|
| 477 | System.Collections.Specialized.NameValueCollection urlAccessParameters = new System.Collections.Specialized.NameValueCollection();
|
|---|
| 478 | urlAccessParameters.Add("rs:PersistStreams", "True");
|
|---|
| 479 | Stream reportStream = report.Render("Image", deviceInfo, urlAccessParameters, out mimeType, out extension);
|
|---|
| 480 | m_streams.Add(reportStream);
|
|---|
| 481 | urlAccessParameters.Remove("rs:PersistStreams");
|
|---|
| 482 | urlAccessParameters.Add("rs:GetNextStream", "True");
|
|---|
| 483 | while (reportStream.Length != 0)
|
|---|
| 484 | {
|
|---|
| 485 | reportStream =
|
|---|
| 486 | report.Render("Image", deviceInfo, urlAccessParameters, out mimeType, out extension);
|
|---|
| 487 | m_streams.Add(reportStream);
|
|---|
| 488 | }
|
|---|
| 489 |
|
|---|
| 490 | m_streams.RemoveAt(m_streams.Count - 1);
|
|---|
| 491 |
|
|---|
| 492 | foreach (Stream stream in m_streams)
|
|---|
| 493 | stream.Position = 0;
|
|---|
| 494 |
|
|---|
| 495 | MessageBox.Show("ExportEnd");
|
|---|
| 496 | }
|
|---|
| 497 | */
|
|---|
| 498 |
|
|---|
| 499 | // drukowanie raportu lokalnego
|
|---|
| 500 | private int m_currentPageIndex;
|
|---|
| 501 | private IList<Stream> m_streams;
|
|---|
| 502 |
|
|---|
| 503 | private Stream CreateStream(string name,
|
|---|
| 504 | string fileNameExtension, Encoding encoding,
|
|---|
| 505 | string mimeType, bool willSeek)
|
|---|
| 506 | {
|
|---|
| 507 | Stream stream = new FileStream(name +
|
|---|
| 508 | "." + fileNameExtension, FileMode.Create);
|
|---|
| 509 | m_streams.Add(stream);
|
|---|
| 510 | return stream;
|
|---|
| 511 | }
|
|---|
| 512 |
|
|---|
| 513 | private void Export(LocalReport report)
|
|---|
| 514 | {
|
|---|
| 515 | string deviceInfo =
|
|---|
| 516 | "<DeviceInfo>" +
|
|---|
| 517 | " <OutputFormat>EMF</OutputFormat>" +
|
|---|
| 518 | " <PageWidth>19cm</PageWidth>" +
|
|---|
| 519 | " <PageHeight>25cm</PageHeight>" +
|
|---|
| 520 | " <MarginTop>1cm</MarginTop>" +
|
|---|
| 521 | " <MarginLeft>1cm</MarginLeft>" +
|
|---|
| 522 | " <MarginRight>1cm</MarginRight>" +
|
|---|
| 523 | " <MarginBottom>0cm</MarginBottom>" +
|
|---|
| 524 | "</DeviceInfo>";
|
|---|
| 525 | Warning[] warnings;
|
|---|
| 526 | m_streams = new List<Stream>();
|
|---|
| 527 | report.Render("Image", deviceInfo, CreateStream,
|
|---|
| 528 | out warnings);
|
|---|
| 529 | foreach (Stream stream in m_streams)
|
|---|
| 530 | stream.Position = 0;
|
|---|
| 531 | }
|
|---|
| 532 |
|
|---|
| 533 | private void PrintPage(object sender, PrintPageEventArgs ev)
|
|---|
| 534 | {
|
|---|
| 535 | Metafile pageImage = new
|
|---|
| 536 | Metafile(m_streams[m_currentPageIndex]);
|
|---|
| 537 | ev.Graphics.DrawImage(pageImage, ev.PageBounds);
|
|---|
| 538 | m_currentPageIndex++;
|
|---|
| 539 | ev.HasMorePages = (m_currentPageIndex < m_streams.Count);
|
|---|
| 540 | }
|
|---|
| 541 |
|
|---|
| 542 | private void Print(PrinterSettings printerSettings)
|
|---|
| 543 | {
|
|---|
| 544 | if (m_streams == null || m_streams.Count == 0)
|
|---|
| 545 | return;
|
|---|
| 546 |
|
|---|
| 547 | PrintDocument printDoc = new PrintDocument();
|
|---|
| 548 | printDoc.PrinterSettings = printerSettings;
|
|---|
| 549 | printDoc.PrinterSettings.Duplex = Duplex.Vertical;
|
|---|
| 550 | printDoc.PrintPage += new PrintPageEventHandler(PrintPage);
|
|---|
| 551 | printDoc.Print();
|
|---|
| 552 | }
|
|---|
| 553 |
|
|---|
| 554 | private void Run()
|
|---|
| 555 | {
|
|---|
| 556 | PrintDialog printDialog = new PrintDialog();
|
|---|
| 557 | if (printDialog.ShowDialog() == DialogResult.OK)
|
|---|
| 558 | {
|
|---|
| 559 | Export(reportViewer1.LocalReport);
|
|---|
| 560 | m_currentPageIndex = 0;
|
|---|
| 561 | Print(printDialog.PrinterSettings);
|
|---|
| 562 | Dispose();
|
|---|
| 563 | }
|
|---|
| 564 |
|
|---|
| 565 | }
|
|---|
| 566 |
|
|---|
| 567 | public void Dispose()
|
|---|
| 568 | {
|
|---|
| 569 | if (m_streams != null)
|
|---|
| 570 | {
|
|---|
| 571 | foreach (Stream stream in m_streams)
|
|---|
| 572 | stream.Close();
|
|---|
| 573 | m_streams = null;
|
|---|
| 574 | }
|
|---|
| 575 | }
|
|---|
| 576 |
|
|---|
| 577 | public void HandlePrint(object sender, CancelEventArgs e)
|
|---|
| 578 | {
|
|---|
| 579 | Run();
|
|---|
| 580 | e.Cancel = true;
|
|---|
| 581 | }
|
|---|
| 582 |
|
|---|
| 583 | }
|
|---|
| 584 | } |
|---|