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