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