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