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