Index: trunk/BazaReklam/ZamowieniaForm.cs
===================================================================
--- trunk/BazaReklam/ZamowieniaForm.cs (revision 268)
+++ trunk/BazaReklam/ZamowieniaForm.cs (revision 292)
@@ -1,9 +1,6 @@
 using System;
-using System.Collections.Generic;
-using System.ComponentModel;
 using System.Data;
 using System.Data.SqlClient;
 using System.Drawing;
-using System.Text;
 using System.Windows.Forms;
 
@@ -14,6 +11,6 @@
         private REKLAMADataSet.KLIENCIRow klient;
 
-        private int idZamowienia = 0;
-        private int idFaktury = 0;
+        private int idZamowienia;
+        private int idFaktury;
 
         private REKLAMADataSet.REKLAMADataTable reklamyBezZamowienia;
@@ -29,17 +26,17 @@
 
         private REKLAMADataSetTableAdapters.UKAZE_SIE_W_NRTableAdapter emisjeTableAdapter =
-            new Baza_Reklam.REKLAMADataSetTableAdapters.UKAZE_SIE_W_NRTableAdapter();
+            new REKLAMADataSetTableAdapters.UKAZE_SIE_W_NRTableAdapter();
 
         private REKLAMADataSetTableAdapters.FAKTURA_DETAILSTableAdapter fakturyDetailsTableAdapter =
-            new Baza_Reklam.REKLAMADataSetTableAdapters.FAKTURA_DETAILSTableAdapter();
+            new REKLAMADataSetTableAdapters.FAKTURA_DETAILSTableAdapter();
 
         private REKLAMADataSetTableAdapters.WplatyTableAdapter wplatyTableAdapter =
-            new Baza_Reklam.REKLAMADataSetTableAdapters.WplatyTableAdapter();
+            new REKLAMADataSetTableAdapters.WplatyTableAdapter();
 
         private REKLAMADataSetTableAdapters.DatyWydanTableAdapter datyWydanTableAdapter =
-            new Baza_Reklam.REKLAMADataSetTableAdapters.DatyWydanTableAdapter();
+            new REKLAMADataSetTableAdapters.DatyWydanTableAdapter();
 
         private SLOWNIKDataSetTableAdapters.Kursy_WalutTableAdapter kursyWalutTableAdapter =
-            new Baza_Reklam.SLOWNIKDataSetTableAdapters.Kursy_WalutTableAdapter();
+            new SLOWNIKDataSetTableAdapters.Kursy_WalutTableAdapter();
 
         #region properties
@@ -273,37 +270,34 @@
             if (zamowieniaBindingSource.Current != null && rEKLAMADataGridView.SelectedRows.Count != 0)
             {
+                DataRowView row = (DataRowView)rEKLAMADataGridView.SelectedRows[0].DataBoundItem;
+
+                if (Convert.ToBoolean(row["FAKTURA WYSTAWIONO"]))
+                {
+                    MessageBox.Show("Reklama ma zafakturowane emisje. Nie mo¿na usun¹æ reklamy.");
+                    return;
+                }
+
+                row["idZamowienia"] = DBNull.Value;
+                row.EndEdit();
+
+                ReklamyBezZamowienia.ImportRow(row.Row);
+                rEKLAMADataSet.REKLAMA.Rows.Remove(row.Row);
+
+                rEKLAMATableAdapter.Update(ReklamyBezZamowienia);
+                zamowieniaTableAdapter.Update(rEKLAMADataSet.zamowienia);
+            }
+        }
+
+        private void button1_Click(object sender, EventArgs e)
+        {
+            if (zamowieniaBindingSource.Current != null)
+            {
+                Cursor = Cursors.WaitCursor;
+
                 DataRowView z = (DataRowView)zamowieniaBindingSource.Current;
                 REKLAMADataSet.zamowieniaRow zamowienie = (REKLAMADataSet.zamowieniaRow)z.Row;
 
-                DataRowView row = (DataRowView)rEKLAMADataGridView.SelectedRows[0].DataBoundItem;
-
-                if (Convert.ToBoolean(row["FAKTURA WYSTAWIONO"]) == true)
-                {
-                    MessageBox.Show("Reklama ma zafakturowane emisje. Nie mo¿na usun¹æ reklamy.");
-                    return;
-                }
-
-                row["idZamowienia"] = DBNull.Value;
-                row.EndEdit();
-
-                ReklamyBezZamowienia.ImportRow(row.Row);
-                rEKLAMADataSet.REKLAMA.Rows.Remove(row.Row);
-
-                rEKLAMATableAdapter.Update(ReklamyBezZamowienia);
-                zamowieniaTableAdapter.Update(rEKLAMADataSet.zamowienia);
-            }
-        }
-
-        private void button1_Click(object sender, EventArgs e)
-        {
-            if (zamowieniaBindingSource.Current != null)
-            {
-                Cursor = Cursors.WaitCursor;
-
-                DataRowView z = (DataRowView)zamowieniaBindingSource.Current;
-                REKLAMADataSet.zamowieniaRow zamowienie = (REKLAMADataSet.zamowieniaRow)z.Row;
-
-                REKLAMADataSet.KLIENCIRow klient = (REKLAMADataSet.KLIENCIRow)klienciTableAdapter.GetDataByCustomerId(zamowienie.idKlienta).Rows[0];
-                string errorMessage = czyMoznaZafakturowac(zamowienie, klient);
+                REKLAMADataSet.KLIENCIRow _klient = (REKLAMADataSet.KLIENCIRow)klienciTableAdapter.GetDataByCustomerId(zamowienie.idKlienta).Rows[0];
+                string errorMessage = czyMoznaZafakturowac(zamowienie, _klient);
 
                 if (errorMessage != string.Empty)
@@ -314,5 +308,5 @@
                 }
 
-                wystawFakture(zamowienie, klient);
+                wystawFakture(zamowienie, _klient, false);
 
                 RestoreConnections();
@@ -324,5 +318,5 @@
         }
 
-        private int wystawFakture(REKLAMADataSet.zamowieniaRow zamowienie, REKLAMADataSet.KLIENCIRow klient)
+        private int wystawFakture(REKLAMADataSet.zamowieniaRow zamowienie, REKLAMADataSet.KLIENCIRow klientRow, bool proforma)
         {
             int idNaglowka = 0;
@@ -330,8 +324,8 @@
             try
             {
-                REKLAMADataSet.FAKTURYRow naglowekFaktury = utworzNaglowekFaktury(zamowienie, klient);
+                REKLAMADataSet.FAKTURYRow naglowekFaktury = utworzNaglowekFaktury(zamowienie, klientRow, proforma);
                 rEKLAMADataSet.FAKTURY.AddFAKTURYRow(naglowekFaktury);
                 pobierzOznaczEmisje(zamowienie, naglowekFaktury);
-                utworzPozycjeFaktury(naglowekFaktury, klient);
+                utworzPozycjeFaktury(naglowekFaktury, klientRow);
                 dodajWplate(naglowekFaktury);
 
@@ -379,5 +373,5 @@
                     dtpZmianaDaty.Value = DateTime.Today;
                 }
-                catch (Exception e1)
+                catch (Exception)
                 {
                     transaction.Rollback();
@@ -390,9 +384,9 @@
                     fAKTURYBindingSource.ResetBindings(false);
                     fAKTURYDataGridView.Refresh();
-                    throw e1;
+                    throw;
                 }
                 finally
                 {
-                    if (conn != null && conn.State == ConnectionState.Open)
+                    if (conn.State == ConnectionState.Open)
                         conn.Close();
                 }
@@ -400,5 +394,5 @@
             catch (Exception e2)
             {
-                MessageBox.Show("Wyst¹pi³ b³¹d: \n" + e2.ToString());
+                MessageBox.Show("Wyst¹pi³ b³¹d: \n" + e2);
             }
             finally
@@ -426,5 +420,5 @@
         }
 
-        private void utworzPozycjeFaktury(REKLAMADataSet.FAKTURYRow naglowekFaktury, REKLAMADataSet.KLIENCIRow klient)
+        private void utworzPozycjeFaktury(REKLAMADataSet.FAKTURYRow naglowekFaktury, REKLAMADataSet.KLIENCIRow klientRow)
         {
             decimal brutto_waluta = 0;
@@ -451,5 +445,5 @@
                 fakturaDetailsRow.JM = "szt.";
 
-                if (naglowekFaktury.Iswaluta_mianoNull() && klient.Country.ToUpper() == "POLSKA")
+                if (naglowekFaktury.Iswaluta_mianoNull() && klientRow.Country.ToUpper() == "POLSKA")
                 {
                     fakturaDetailsRow.UPUST_NETTO = Convert.ToDecimal(reklama.RABAT) * fakturaDetailsRow.CENA_JEDN;
@@ -462,11 +456,11 @@
                     fakturaDetailsRow.NETTO = netto;
                     fakturaDetailsRow.S_VAT = reklama.VAT;
-                    decimal VAT = Convert.ToDecimal(reklama.VAT);
-                    fakturaDetailsRow.VAT = Convert.ToDecimal(VAT * netto);
-                    fakturaDetailsRow.BRUTTO = Convert.ToDecimal((1 + VAT) * netto);
-                }
-                else if(naglowekFaktury.Iswaluta_mianoNull() && klient.Country.ToUpper() != "POLSKA")
-                {
-                    decimal VAT = Convert.ToDecimal(reklama.VAT);
+                    decimal _vat = Convert.ToDecimal(reklama.VAT);
+                    fakturaDetailsRow.VAT = Convert.ToDecimal(_vat * netto);
+                    fakturaDetailsRow.BRUTTO = Convert.ToDecimal((1 + _vat) * netto);
+                }
+                else if(naglowekFaktury.Iswaluta_mianoNull() && klientRow.Country.ToUpper() != "POLSKA")
+                {
+                    decimal _vat = Convert.ToDecimal(reklama.VAT);
                     decimal netto = (1 - Convert.ToDecimal(reklama.RABAT)) * fakturaDetailsRow.CENA_JEDN;
                     if (reklama.wyroznienie)
@@ -474,9 +468,9 @@
                     fakturaDetailsRow.NETTO = netto;
                     fakturaDetailsRow.S_VAT = reklama.VAT;
-                    fakturaDetailsRow.BRUTTO = Convert.ToDecimal((1 + VAT) * netto);
+                    fakturaDetailsRow.BRUTTO = Convert.ToDecimal((1 + _vat) * netto);
                     
                     decimal brutto = fakturaDetailsRow.BRUTTO;
 
-                    fakturaDetailsRow.VAT = Convert.ToDecimal(VAT * brutto / (1 + VAT));
+                    fakturaDetailsRow.VAT = Convert.ToDecimal(_vat * brutto / (1 + _vat));
 
                     fakturaDetailsRow.UPUST_PR = reklama.RABAT;
@@ -493,7 +487,7 @@
                     brutto_waluta += Convert.ToDecimal(reklama.Brutto_Euro / reklama.KROTNOÆ);
                     fakturaDetailsRow.S_VAT = reklama.VAT;
-                    decimal VAT = Convert.ToDecimal(reklama.VAT);
+                    decimal _vat = Convert.ToDecimal(reklama.VAT);
                     decimal brutto = fakturaDetailsRow.BRUTTO;
-                    fakturaDetailsRow.VAT = Convert.ToDecimal(VAT * brutto / (1 + VAT));
+                    fakturaDetailsRow.VAT = Convert.ToDecimal(_vat * brutto / (1 + _vat));
                     decimal netto = brutto - fakturaDetailsRow.VAT;
                     fakturaDetailsRow.NETTO = netto;
@@ -633,10 +627,11 @@
         }
 
-        private REKLAMADataSet.FAKTURYRow utworzNaglowekFaktury(REKLAMADataSet.zamowieniaRow zamowienie, REKLAMADataSet.KLIENCIRow klient)
+        private REKLAMADataSet.FAKTURYRow utworzNaglowekFaktury(REKLAMADataSet.zamowieniaRow zamowienie, REKLAMADataSet.KLIENCIRow klientRow, bool proforma)
         {
             REKLAMADataSet.FAKTURYRow naglowekFaktury = (REKLAMADataSet.FAKTURYRow)rEKLAMADataSet.FAKTURY.NewRow();
             naglowekFaktury.idZamowienia = zamowienie.idZamowienia;
             naglowekFaktury.NUMER_ROZ = zamowienie.kodAgenta;
-            naglowekFaktury.NUMER = Utils.numerNowejFaktury(naglowekFaktury.NUMER_ROZ, DateTime.Today.Year);
+            naglowekFaktury.NUMER = proforma ? zamowienie.nrZamowienia : Utils.numerNowejFaktury(naglowekFaktury.NUMER_ROZ, DateTime.Today.Year);
+
             naglowekFaktury.NUMER_ROK = DateTime.Today.Year;
             naglowekFaktury.DATA_WYSTAWIENIA = DateTime.Today;
@@ -668,30 +663,14 @@
 
             naglowekFaktury.ID_NABYWCY = zamowienie.idKlienta;
-            naglowekFaktury.NABYWCA_ADRES = klient.Adres_Fkatura;
-            naglowekFaktury.NABYWCA_NIP = klient.Nip;
+            naglowekFaktury.NABYWCA_ADRES = klientRow.Adres_Fkatura;
+            naglowekFaktury.NABYWCA_NIP = klientRow.Nip;
             naglowekFaktury.opis = "Faktura za reklamy zgodnie z zamówieniem: " 
-                + klient.kodKlienta + 
+                + klientRow.kodKlienta + 
                 "/" + zamowienie.nrZamowienia + 
                 "/" + zamowienie.kodAgenta + 
                 "/" + zamowienie.rokZamowienia;
 
-            switch (zamowienie.sposobZaplaty)
-            {
-                case 0:
-                    naglowekFaktury.SPOSOB_ZAPLATY = "Karta kredytowa";
-                    break;
-                case 1:
-                    naglowekFaktury.SPOSOB_ZAPLATY = "Przelew";
-                    break;
-                case 2:
-                    naglowekFaktury.SPOSOB_ZAPLATY = "Gotówka";
-                    break;
-                case 3:
-                    naglowekFaktury.SPOSOB_ZAPLATY = "Barter";
-                    break;
-                default:
-                    break;
-            }
-
+
+            naglowekFaktury.SPOSOB_ZAPLATY = FakturaHelper.GetPaymentType(zamowienie.sposobZaplaty);
             naglowekFaktury.TERMIN_ZAPLATY = naglowekFaktury.DATA_SPRZEDAZY.AddDays(zamowienie.czasPlatnosci);
             naglowekFaktury.ZAPLACONO = false;
@@ -707,5 +686,5 @@
             {
                 naglowekFaktury.SPRZEDAWCA_NIP = agencja.vies;
-                naglowekFaktury.NABYWCA_NIP = klient.nipKraj + " " + klient.Nip;
+                naglowekFaktury.NABYWCA_NIP = klientRow.nipKraj + " " + klientRow.Nip;
                 naglowekFaktury.waluta_miano = rEKLAMADataSet.REKLAMA[0].Brutto_Euro_Miano;
 
@@ -725,9 +704,9 @@
                 naglowekFaktury.waluta_tabela_nr = kurs[0].Numer_Tabeli;
             }
-            // jesli klient jest zagraniczny a waluta ciagle PLN
-            else if (klient.Country.ToUpper() != "POLSKA")
+            // jesli klientRow jest zagraniczny a waluta ciagle PLN
+            else if (klientRow.Country.ToUpper() != "POLSKA")
             {
                 naglowekFaktury.SPRZEDAWCA_NIP = agencja.vies;
-                naglowekFaktury.NABYWCA_NIP = klient.nipKraj + " " + klient.Nip;
+                naglowekFaktury.NABYWCA_NIP = klientRow.nipKraj + " " + klientRow.Nip;
             }
 
@@ -736,5 +715,7 @@
         }
 
-        private string czyMoznaZafakturowac(REKLAMADataSet.zamowieniaRow zamowienie, REKLAMADataSet.KLIENCIRow klient)
+        
+
+        private string czyMoznaZafakturowac(REKLAMADataSet.zamowieniaRow zamowienie, REKLAMADataSet.KLIENCIRow klientRow)
         {
             string errorMessage = string.Empty;
@@ -744,11 +725,11 @@
             errorMessage += zamowienie.IsidKontaNull() ? "Nie wybrano konta. \n" : "";
             errorMessage += zamowienie.IssposobZaplatyNull() ? "Nie wybrano sposobu zap³aty. \n" : "";
-            errorMessage += klient.IsCountryNull() || klient.Country == string.Empty ? "Brak pañstwa klienta. \n" : "";
-            errorMessage += klient.IsAdres_FkaturaNull() || klient.Adres_Fkatura == string.Empty ? "Brak adresu faktury klienta. \n" : "";
-            errorMessage += klient.IsNipNull() || klient.Nip == string.Empty ? "Brak nipu klienta. \n" : "";
-
-            if (klient.Country != "Polska")
-            {
-                errorMessage += klient.IsnipKrajNull() || klient.nipKraj == string.Empty ? "Brak symbolu kraju w nipie klienta. \n" : "";
+            errorMessage += klientRow.IsCountryNull() || klientRow.Country == string.Empty ? "Brak pañstwa klienta. \n" : "";
+            errorMessage += klientRow.IsAdres_FkaturaNull() || klientRow.Adres_Fkatura == string.Empty ? "Brak adresu faktury klienta. \n" : "";
+            errorMessage += klientRow.IsNipNull() || klientRow.Nip == string.Empty ? "Brak nipu klienta. \n" : "";
+
+            if (klientRow.Country != "Polska")
+            {
+                errorMessage += klientRow.IsnipKrajNull() || klientRow.nipKraj == string.Empty ? "Brak symbolu kraju w nipie klienta. \n" : "";
             }
 
@@ -876,14 +857,14 @@
                         transaction.Commit();
                     }
-                    catch (Exception e1)
+                    catch (Exception)
                     {
                         transaction.Rollback();
                         conn.Close();
-                        throw e1;
+                        throw;
                     }
                 }
                 catch (Exception e2)
                 {
-                    MessageBox.Show("Wyst¹pi³ b³¹d: \n" + e2.ToString());
+                    MessageBox.Show("Wyst¹pi³ b³¹d: \n" + e2);
                 }
                 finally
@@ -912,5 +893,5 @@
             naglowekKorekty.idFakturyVAT = faktura.ID_FAKTURY;
 
-            naglowekKorekty.NUMER_ROZ = faktura.NUMER_ROZ; ;
+            naglowekKorekty.NUMER_ROZ = faktura.NUMER_ROZ;
             naglowekKorekty.NUMER = Utils.numerNowejFakturyKorekty(naglowekKorekty.NUMER_ROZ, DateTime.Today.Year);
             naglowekKorekty.NUMER_ROK = DateTime.Today.Year;
@@ -1009,7 +990,7 @@
                         fakturaDetailsRow.NETTO = netto;
                         fakturaDetailsRow.S_VAT = reklama.VAT;
-                        decimal VAT = Convert.ToDecimal(reklama.VAT);
-                        fakturaDetailsRow.VAT = Convert.ToDecimal(Math.Round(VAT * netto, 2));
-                        fakturaDetailsRow.BRUTTO = Convert.ToDecimal(Math.Round((1 + VAT) * netto, 2));
+                        decimal _vat = Convert.ToDecimal(reklama.VAT);
+                        fakturaDetailsRow.VAT = Convert.ToDecimal(Math.Round(_vat * netto, 2));
+                        fakturaDetailsRow.BRUTTO = Convert.ToDecimal(Math.Round((1 + _vat) * netto, 2));
                     }
                     else
@@ -1020,7 +1001,7 @@
                         brutto_waluta += Convert.ToDecimal(reklama.Brutto_Euro / reklama.KROTNOÆ);
                         fakturaDetailsRow.S_VAT = reklama.VAT;
-                        decimal VAT = Convert.ToDecimal(reklama.VAT);
+                        decimal _vat = Convert.ToDecimal(reklama.VAT);
                         decimal brutto = fakturaDetailsRow.BRUTTO;
-                        fakturaDetailsRow.VAT = Convert.ToDecimal(Math.Round(VAT * brutto / (1 + VAT), 2));
+                        fakturaDetailsRow.VAT = Convert.ToDecimal(Math.Round(_vat * brutto / (1 + _vat), 2));
                         decimal netto = brutto - fakturaDetailsRow.VAT;
                         fakturaDetailsRow.NETTO = netto;
@@ -1096,22 +1077,11 @@
             {
                 DataRowView row = (DataRowView)fAKTURYBindingSource.Current;
-                REKLAMADataSet.FAKTURYRow f =
-                    (REKLAMADataSet.FAKTURYRow)row.Row;
-
-                REKLAMADataSetTableAdapters.WplatyTableAdapter wplatyTableAdapter
-                = new Baza_Reklam.REKLAMADataSetTableAdapters.WplatyTableAdapter();
-                wplatyTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
-                REKLAMADataSet.WplatyDataTable table = wplatyTableAdapter.GetDataByIdFaktury(f.ID_FAKTURY);
-
-                PaymentForm2 pf2;
-
-                if (table.Count == 0)
-                {
-                    pf2 = new PaymentForm2(0, f.ID_FAKTURY);
-                }
-                else
-                {
-                    pf2 = new PaymentForm2(table[0].idWplaty, f.ID_FAKTURY);
-                }
+                REKLAMADataSet.FAKTURYRow f = (REKLAMADataSet.FAKTURYRow)row.Row;
+
+                REKLAMADataSetTableAdapters.WplatyTableAdapter wplaty = new REKLAMADataSetTableAdapters.WplatyTableAdapter();
+                wplaty.Connection.ConnectionString = ConnString.getConnString().Value;
+                REKLAMADataSet.WplatyDataTable table = wplaty.GetDataByIdFaktury(f.ID_FAKTURY);
+
+                PaymentForm2 pf2 = table.Count == 0 ? new PaymentForm2(0, f.ID_FAKTURY) : new PaymentForm2(table[0].idWplaty, f.ID_FAKTURY);
 
                 pf2.ShowDialog();
@@ -1157,17 +1127,7 @@
         private void fAKTURYBindingSource_CurrentChanged(object sender, EventArgs e)
         {
-            if (fAKTURYBindingSource.Current != null)
-            {
-                if (
-                    ((REKLAMADataSet.FAKTURYRow)
-                    ((DataRowView)fAKTURYBindingSource.Current).Row).KOREKTA)
-                {
-                    wplataButton.Enabled = false;
-                }
-                else
-                {
-                    wplataButton.Enabled = true;
-                }
-            }
+            if (fAKTURYBindingSource.Current == null) return;
+
+            wplataButton.Enabled = !((REKLAMADataSet.FAKTURYRow)((DataRowView)fAKTURYBindingSource.Current).Row).KOREKTA;
         }
 
@@ -1288,5 +1248,5 @@
                 transaction.Commit();
             }
-            catch (Exception ex)
+            catch (Exception)
             {
                 transaction.Rollback();
@@ -1395,6 +1355,6 @@
                 REKLAMADataSet.zamowieniaRow zamowienie = (REKLAMADataSet.zamowieniaRow)z.Row;
 
-                REKLAMADataSet.KLIENCIRow klient = (REKLAMADataSet.KLIENCIRow)klienciTableAdapter.GetDataByCustomerId(zamowienie.idKlienta).Rows[0];
-                string errorMessage = czyMoznaZafakturowac(zamowienie, klient);
+                REKLAMADataSet.KLIENCIRow _klient = (REKLAMADataSet.KLIENCIRow)klienciTableAdapter.GetDataByCustomerId(zamowienie.idKlienta).Rows[0];
+                string errorMessage = czyMoznaZafakturowac(zamowienie, _klient);
 
                 if (errorMessage != string.Empty)
@@ -1405,6 +1365,6 @@
                 }
 
-                int id = wystawFakture(zamowienie, klient);
-                FactureViewer fv = new FactureViewer(id, true);
+                int id = wystawFakture(zamowienie, _klient, true);
+                FactureViewer fv = new FactureViewer(id, true, _klient.kodKlienta);
 
                 fv.ShowDialog();
Index: trunk/BazaReklam/FactureViewer.cs
===================================================================
--- trunk/BazaReklam/FactureViewer.cs (revision 249)
+++ trunk/BazaReklam/FactureViewer.cs (revision 292)
@@ -3,6 +3,4 @@
 using System.ComponentModel;
 using System.Data;
-using System.Data.SqlClient;
-using System.Diagnostics;
 using System.Drawing;
 using System.Text;
@@ -29,8 +27,8 @@
         DataSet ds;
 
-        public FactureViewer(int idFakt,bool rodzaj, int old)
+        public FactureViewer(int idFakt, bool rodzaj, int old)
         {
             InitializeComponent();
-            
+
             idFaktury = idFakt;
 
@@ -53,18 +51,19 @@
 
             //ustawienie parametrów, nowych datasoure dla raportu
-            
+
             //ustawianie danych dla raportu
             if (this.rodzaj)
             {
-                typComboBox.Enabled = false;               
+                typComboBox.Enabled = false;
                 reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", fakturaTableAdapter1.GetDataByIdFaktury(idFakt)));
-            
-            }
-            else {
+
+            }
+            else
+            {
                 jezykComboBox.Enabled = false;
                 reportViewer1.LocalReport.ReportEmbeddedResource = "Baza_Reklam.Raporty.proformaReversed.rdlc";
                 reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", proformaTableAdapter.GetDataByIdFaktury(idFakt)));
-            }            
-            
+            }
+
             reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FakturaDetails", fakturA_DETAILSTableAdapter1.GetDataByIdFaktury(idFakt)));
             reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("tlumaczenia", ds.Tables[0]));
@@ -101,75 +100,156 @@
         }
 
-    /// <param name="idFakt">ID_Faktury</param>
-    /// <param name="r">true = proforma</param>
-    public FactureViewer(int idFakt, bool r)
-    {
-        InitializeComponent();
-
-
-        idFaktury = idFakt;
-        this.rodzaj = r;
-
-        this.zapiszButton.Click += zapiszButton2_Click;
-
-        fakturaTableAdapter1.Connection.ConnectionString = ConnString.getConnString().Value;
-        fAKTURA_DETAILS2TableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
-        fAKTURYTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
-        proformaTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
-
-        ds = new DataSet();
-
-        //zczytuje dane z pliku z tlumaczeniami
-        Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream("Baza_Reklam.Raporty.faktura.xml");
-        ds.ReadXml(s);
-
-        fAKTURYTableAdapter.FillByIdFaktury(this.rEKLAMADataSet.FAKTURY, idFakt);
-
-        //ustawienie parametrów, nowych datasoure dla raportu
-
-        //ustawianie danych dla raportu
-        typComboBox.Enabled = false;
-
-        raporty.FakturaDataTable fakturaDataTable = fakturaTableAdapter1.GetDataByIdFaktury(idFakt);
-        raporty.FakturaRow faktura = (raporty.FakturaRow)fakturaDataTable.Rows[0];
-
-        if (IsFakturaPoznanOrKatowice(faktura.NUMER_ROZ, faktura.ID_NABYWCY))
-            reportViewer1.LocalReport.ReportEmbeddedResource = "Baza_Reklam.Raporty.fakturaKatowicePoznan.rdlc";
-        else
-            reportViewer1.LocalReport.ReportEmbeddedResource = "Baza_Reklam.Raporty.fakturaReversed2.rdlc";
-
-
-        reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", fakturaDataTable));
-        reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FakturaDetails2",
-                                                                       fAKTURA_DETAILS2TableAdapter.GetDataIdFaktury(
-                                                                           idFakt)));
-        reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("tlumaczenia", ds.Tables[0]));
-
-        List<ReportParameter> paramList = new List<ReportParameter>();
-
-        //Produkcja ma domylnie bez podpisu 
-        if (User.getUser().St_produkcja)
-        {
-            podpisCheckBox.CheckState = CheckState.Unchecked;
-        }
-
-        paramList.Add(new ReportParameter("podpis", podpisCheckBox.Checked.ToString(), true));
-
-        if (this.rodzaj)
-        {
-            paramList.Add(new ReportParameter("proforma", "True", true));
-        }
-        else
-        {
-            paramList.Add(new ReportParameter("proforma", "False", true));
-        }
-
-        paramList.Add(new ReportParameter("zaplacono", zaplaconoCheckBox.Checked.ToString(), true));
-
-        this.reportViewer1.LocalReport.SetParameters(paramList);
-
-        jezykComboBox.SelectedIndex = 0;
-        typComboBox.SelectedIndex = 1;
-    }
+        public FactureViewer(int idFakt, bool r)
+        {
+            Init(idFakt, r, string.Empty);
+        }
+
+        /// <param name="idFakt">ID_Faktury</param>
+        /// <param name="r">true = proforma</param>
+        /// <param name="kodKlienta"></param>
+        public FactureViewer(int idFakt, bool r, string kodKlienta)
+        {
+
+            Init(idFakt, r, kodKlienta);
+
+            //InitializeComponent();
+
+
+            //idFaktury = idFakt;
+            //this.rodzaj = r;
+
+            //this.zapiszButton.Click += zapiszButton2_Click;
+
+            //fakturaTableAdapter1.Connection.ConnectionString = ConnString.getConnString().Value;
+            //fAKTURA_DETAILS2TableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
+            //fAKTURYTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
+            //proformaTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
+
+            //ds = new DataSet();
+
+            ////zczytuje dane z pliku z tlumaczeniami
+            //Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream("Baza_Reklam.Raporty.faktura.xml");
+            //ds.ReadXml(s);
+
+            //fAKTURYTableAdapter.FillByIdFaktury(this.rEKLAMADataSet.FAKTURY, idFakt);
+
+            ////ustawienie parametrów, nowych datasoure dla raportu
+
+            ////ustawianie danych dla raportu
+            //typComboBox.Enabled = false;
+
+            //raporty.FakturaDataTable fakturaDataTable = fakturaTableAdapter1.GetDataByIdFaktury(idFakt);
+            //raporty.FakturaRow faktura = (raporty.FakturaRow)fakturaDataTable.Rows[0];
+
+            //if (IsFakturaPoznanOrKatowice(faktura.NUMER_ROZ, faktura.ID_NABYWCY))
+            //    reportViewer1.LocalReport.ReportEmbeddedResource = "Baza_Reklam.Raporty.fakturaKatowicePoznan.rdlc";
+            //else
+            //    reportViewer1.LocalReport.ReportEmbeddedResource = "Baza_Reklam.Raporty.fakturaReversed2.rdlc";
+
+
+            //reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", fakturaDataTable));
+            //reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FakturaDetails2",
+            //                                                               fAKTURA_DETAILS2TableAdapter.GetDataIdFaktury(
+            //                                                                   idFakt)));
+            //reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("tlumaczenia", ds.Tables[0]));
+
+            //List<ReportParameter> paramList = new List<ReportParameter>();
+
+            ////Produkcja ma domylnie bez podpisu 
+            //if (User.getUser().St_produkcja)
+            //{
+            //    podpisCheckBox.CheckState = CheckState.Unchecked;
+            //}
+
+            //paramList.Add(new ReportParameter("podpis", podpisCheckBox.Checked.ToString(), true));
+
+            //if (this.rodzaj)
+            //{
+            //    paramList.Add(new ReportParameter("proforma", "True", true));
+            //}
+            //else
+            //{
+            //    paramList.Add(new ReportParameter("proforma", "False", true));
+            //}
+
+            //paramList.Add(new ReportParameter("zaplacono", zaplaconoCheckBox.Checked.ToString(), true));
+
+            //this.reportViewer1.LocalReport.SetParameters(paramList);
+
+            //jezykComboBox.SelectedIndex = 0;
+            //typComboBox.SelectedIndex = 1;
+        }
+
+        public void Init(int idFakt, bool r, string kodKlienta)
+        {
+            InitializeComponent();
+
+
+            idFaktury = idFakt;
+            this.rodzaj = r;
+
+            this.zapiszButton.Click += zapiszButton2_Click;
+
+            fakturaTableAdapter1.Connection.ConnectionString = ConnString.getConnString().Value;
+            fAKTURA_DETAILS2TableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
+            fAKTURYTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
+            proformaTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
+
+            ds = new DataSet();
+
+            //zczytuje dane z pliku z tlumaczeniami
+            Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream("Baza_Reklam.Raporty.faktura.xml");
+            ds.ReadXml(s);
+
+            fAKTURYTableAdapter.FillByIdFaktury(this.rEKLAMADataSet.FAKTURY, idFakt);
+
+            //ustawienie parametrów, nowych datasoure dla raportu
+
+            //ustawianie danych dla raportu
+            typComboBox.Enabled = false;
+
+            raporty.FakturaDataTable fakturaDataTable = fakturaTableAdapter1.GetDataByIdFaktury(idFakt);
+            raporty.FakturaRow faktura = (raporty.FakturaRow)fakturaDataTable.Rows[0];
+
+            if (IsFakturaPoznanOrKatowice(faktura.NUMER_ROZ, faktura.ID_NABYWCY))
+                reportViewer1.LocalReport.ReportEmbeddedResource = "Baza_Reklam.Raporty.fakturaKatowicePoznan.rdlc";
+            else
+                reportViewer1.LocalReport.ReportEmbeddedResource = "Baza_Reklam.Raporty.fakturaReversed2.rdlc";
+
+
+            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", fakturaDataTable));
+            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FakturaDetails2",
+                                                                           fAKTURA_DETAILS2TableAdapter.GetDataIdFaktury(
+                                                                               idFakt)));
+            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("tlumaczenia", ds.Tables[0]));
+
+            List<ReportParameter> paramList = new List<ReportParameter>();
+
+            //Produkcja ma domylnie bez podpisu 
+            if (User.getUser().St_produkcja)
+            {
+                podpisCheckBox.CheckState = CheckState.Unchecked;
+            }
+
+            paramList.Add(new ReportParameter("podpis", podpisCheckBox.Checked.ToString(), true));
+
+            if (this.rodzaj)
+            {
+                paramList.Add(new ReportParameter("proforma", "True", true));
+                paramList.Add(new ReportParameter("kodKlienta", kodKlienta, true));
+            }
+            else
+            {
+                paramList.Add(new ReportParameter("proforma", "False", true));
+                paramList.Add(new ReportParameter("kodKlienta", string.Empty, true));
+            }
+
+            paramList.Add(new ReportParameter("zaplacono", zaplaconoCheckBox.Checked.ToString(), true));
+
+            this.reportViewer1.LocalReport.SetParameters(paramList);
+
+            jezykComboBox.SelectedIndex = 0;
+            typComboBox.SelectedIndex = 1;
+        }
 
         /// <summary>
@@ -191,5 +271,5 @@
 
             this.zapiszButton.Click += zapiszKorektaButton_Click;
-                        
+
             fakturaTableAdapter1.Connection.ConnectionString = ConnString.getConnString().Value;
             fAKTURA_DETAILS2TableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
@@ -208,8 +288,8 @@
 
             typComboBox.Enabled = false;
-           
-            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Korekta",fakturaTableAdapter1.GetDataByIdFaktury(idKorekty)));
+
+            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Korekta", fakturaTableAdapter1.GetDataByIdFaktury(idKorekty)));
             reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", fakturaTableAdapter1.GetDataByIdFaktury(idFaktury)));
-     
+
             //piersza korekta
             if (idPoprzedniejKorekty == idFaktury)
@@ -300,10 +380,10 @@
             reportViewer1.Reset();
             reportViewer1.LocalReport.ReportEmbeddedResource = this.rodzaj ? "Baza_Reklam.Raporty.fakturaReversed.rdlc" : "Baza_Reklam.Raporty.proformaReversed.rdlc";
-           
+
             //ustawienie parametrów, nowych datasoure dla raportu
             List<ReportParameter> paramList = new List<ReportParameter>();
 
             if (this.rodzaj)
-            {               
+            {
                 paramList.Add(new ReportParameter("jezyk", jezykComboBox.SelectedItem.ToString(), true));
                 paramList.Add(new ReportParameter("podpis", podpisCheckBox.Checked.ToString(), true));
@@ -311,5 +391,5 @@
                 reportViewer1.LocalReport.DataSources.Clear();
                 reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", fakturaTableAdapter1.GetDataByIdFaktury(idFaktury)));
-           
+
             }
             else
@@ -320,5 +400,5 @@
                 reportViewer1.LocalReport.DataSources.Clear();
                 reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", proformaTableAdapter.GetDataByIdFaktury(idFaktury)));
-            }     
+            }
 
             reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FakturaDetails", fakturA_DETAILSTableAdapter1.GetDataByIdFaktury(idFaktury)));
@@ -341,5 +421,5 @@
             fAKTURYBindingSource.EndEdit();
             fAKTURYTableAdapter.Update(this.rEKLAMADataSet.FAKTURY);
-            fAKTURYTableAdapter.FillByIdFaktury(this.rEKLAMADataSet.FAKTURY,idKorekty);
+            fAKTURYTableAdapter.FillByIdFaktury(this.rEKLAMADataSet.FAKTURY, idKorekty);
 
             //ustawienie parametrów, nowych datasoure dla raportu
@@ -377,7 +457,7 @@
             paramList.Add(new ReportParameter("podpis", podpisCheckBox.Checked.ToString(), true));
 
-            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Korekta",fakturaTableAdapter1.GetDataByIdFaktury(idKorekty)));
+            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Korekta", fakturaTableAdapter1.GetDataByIdFaktury(idKorekty)));
             reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", fakturaTableAdapter1.GetDataByIdFaktury(idFaktury)));
-     
+
             //piersza korekta
             if (idPoprzedniejKorekty == idFaktury)
@@ -390,5 +470,5 @@
             }
             reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FakturaDetailsKorekty", fAKTURA_DETAILS2TableAdapter.GetDataIdFaktury(idKorekty)));
-           
+
             reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("tlumaczenia", ds.Tables[0]));
 
@@ -426,5 +506,5 @@
             }
             paramList.Add(new ReportParameter("zaplacono", zaplaconoCheckBox.Checked.ToString(), true));
-        
+
             this.reportViewer1.LocalReport.SetParameters(paramList);
             reportViewer1.LocalReport.DataSources.Clear();
@@ -439,5 +519,5 @@
         }
 
-       //drukowanie raportu serwerowego
+        //drukowanie raportu serwerowego
         /*
         private int m_currentPageIndex;
@@ -639,8 +719,8 @@
             row["opis"] = powodKorektyComboBox.SelectedItem.ToString();
             fAKTURYBindingSource.EndEdit();
-            
+
             opisTextBox.Text = powodKorektyComboBox.SelectedItem.ToString();
         }
 
-   }
+    }
 }
Index: trunk/BazaReklam/Classes/FakturaHelper.cs
===================================================================
--- trunk/BazaReklam/Classes/FakturaHelper.cs (revision 270)
+++ trunk/BazaReklam/Classes/FakturaHelper.cs (revision 292)
@@ -27,4 +27,21 @@
             CentralaPLN = 43
         }
+
+        public static string GetPaymentType(int paymentType)
+        {
+            switch (paymentType)
+            {
+                case 0:
+                    return "Karta kredytowa";
+                case 1:
+                    return "Przelew";
+                case 2:
+                    return "Gotówka";
+                case 3:
+                    return "Barter";
+                default:
+                    return string.Empty;
+            }
+        }
     }
 }
Index: trunk/BazaReklam/Raporty/fakturaReversed2.rdlc
===================================================================
--- trunk/BazaReklam/Raporty/fakturaReversed2.rdlc (revision 281)
+++ trunk/BazaReklam/Raporty/fakturaReversed2.rdlc (revision 292)
@@ -116,4 +116,10 @@
         </ParameterValues>
       </ValidValues>
+    </ReportParameter>
+    <ReportParameter Name="kodKlienta">
+      <DataType>String</DataType>
+      <AllowBlank>true</AllowBlank>
+      <Prompt>kodKlienta</Prompt>
+      <Hidden>true</Hidden>
     </ReportParameter>
   </ReportParameters>
@@ -4321,5 +4327,5 @@
                 <CanGrow>true</CanGrow>
                 <Height>0.63492cm</Height>
-                <Value>=iif(Parameters!proforma.Value = false,First(Fields!FAKTURY_DRUK_INTERNATIONALlabel_faktura_vat.Value, "tlumaczenia"),"Faktura proforma nr: ") &amp; " " &amp; Fields!NUMER.Value &amp; "/" &amp; Fields!NUMER_ROZ.Value &amp; "/" &amp; Fields!NUMER_ROK.Value</Value>
+                <Value>=iif(Not Parameters!proforma.Value, First(Fields!FAKTURY_DRUK_INTERNATIONALlabel_faktura_vat.Value, "tlumaczenia"), "Faktura proforma nr: " &amp; Parameters!kodKlienta.Value &amp; "/") &amp; Fields!NUMER.Value &amp; "/" &amp; Fields!NUMER_ROZ.Value &amp; "/" &amp; Fields!NUMER_ROK.Value</Value>
               </Textbox>
               <Textbox Name="FAKTURY_DRUK_INTERNATIONALlabel_oryginal_kopia">
