Zbiór zmian 292 dla trunk

Pokaż
Ignoruj:
Data:
2009-02-03 16:38:56 (17 years ago)
Autor:
marek
Opis:

fixes #71 - nr proformy jest taki jak nr zamowienia

Lokalizacja:
trunk/BazaReklam
Pliki:
4 zmodyfikowane

Legenda:

Bez zmian
Dodane
Usunięte
  • trunk/BazaReklam/Classes/FakturaHelper.cs

    r270 r292  
    2727            CentralaPLN = 43 
    2828        } 
     29 
     30        public static string GetPaymentType(int paymentType) 
     31        { 
     32            switch (paymentType) 
     33            { 
     34                case 0: 
     35                    return "Karta kredytowa"; 
     36                case 1: 
     37                    return "Przelew"; 
     38                case 2: 
     39                    return "Gotówka"; 
     40                case 3: 
     41                    return "Barter"; 
     42                default: 
     43                    return string.Empty; 
     44            } 
     45        } 
    2946    } 
    3047} 
  • trunk/BazaReklam/FactureViewer.cs

    r249 r292  
    33using System.ComponentModel; 
    44using System.Data; 
    5 using System.Data.SqlClient; 
    6 using System.Diagnostics; 
    75using System.Drawing; 
    86using System.Text; 
     
    2927        DataSet ds; 
    3028 
    31         public FactureViewer(int idFakt,bool rodzaj, int old) 
     29        public FactureViewer(int idFakt, bool rodzaj, int old) 
    3230        { 
    3331            InitializeComponent(); 
    34              
     32 
    3533            idFaktury = idFakt; 
    3634 
     
    5351 
    5452            //ustawienie parametrów, nowych datasoure dla raportu 
    55              
     53 
    5654            //ustawianie danych dla raportu 
    5755            if (this.rodzaj) 
    5856            { 
    59                 typComboBox.Enabled = false;                
     57                typComboBox.Enabled = false; 
    6058                reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", fakturaTableAdapter1.GetDataByIdFaktury(idFakt))); 
    61              
    62             } 
    63             else { 
     59 
     60            } 
     61            else 
     62            { 
    6463                jezykComboBox.Enabled = false; 
    6564                reportViewer1.LocalReport.ReportEmbeddedResource = "Baza_Reklam.Raporty.proformaReversed.rdlc"; 
    6665                reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", proformaTableAdapter.GetDataByIdFaktury(idFakt))); 
    67             }             
    68              
     66            } 
     67 
    6968            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FakturaDetails", fakturA_DETAILSTableAdapter1.GetDataByIdFaktury(idFakt))); 
    7069            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("tlumaczenia", ds.Tables[0])); 
     
    101100        } 
    102101 
    103     /// <param name="idFakt">ID_Faktury</param> 
    104     /// <param name="r">true = proforma</param> 
    105     public FactureViewer(int idFakt, bool r) 
    106     { 
    107         InitializeComponent(); 
    108  
    109  
    110         idFaktury = idFakt; 
    111         this.rodzaj = r; 
    112  
    113         this.zapiszButton.Click += zapiszButton2_Click; 
    114  
    115         fakturaTableAdapter1.Connection.ConnectionString = ConnString.getConnString().Value; 
    116         fAKTURA_DETAILS2TableAdapter.Connection.ConnectionString = ConnString.getConnString().Value; 
    117         fAKTURYTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value; 
    118         proformaTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value; 
    119  
    120         ds = new DataSet(); 
    121  
    122         //zczytuje dane z pliku z tlumaczeniami 
    123         Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream("Baza_Reklam.Raporty.faktura.xml"); 
    124         ds.ReadXml(s); 
    125  
    126         fAKTURYTableAdapter.FillByIdFaktury(this.rEKLAMADataSet.FAKTURY, idFakt); 
    127  
    128         //ustawienie parametrów, nowych datasoure dla raportu 
    129  
    130         //ustawianie danych dla raportu 
    131         typComboBox.Enabled = false; 
    132  
    133         raporty.FakturaDataTable fakturaDataTable = fakturaTableAdapter1.GetDataByIdFaktury(idFakt); 
    134         raporty.FakturaRow faktura = (raporty.FakturaRow)fakturaDataTable.Rows[0]; 
    135  
    136         if (IsFakturaPoznanOrKatowice(faktura.NUMER_ROZ, faktura.ID_NABYWCY)) 
    137             reportViewer1.LocalReport.ReportEmbeddedResource = "Baza_Reklam.Raporty.fakturaKatowicePoznan.rdlc"; 
    138         else 
    139             reportViewer1.LocalReport.ReportEmbeddedResource = "Baza_Reklam.Raporty.fakturaReversed2.rdlc"; 
    140  
    141  
    142         reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", fakturaDataTable)); 
    143         reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FakturaDetails2", 
    144                                                                        fAKTURA_DETAILS2TableAdapter.GetDataIdFaktury( 
    145                                                                            idFakt))); 
    146         reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("tlumaczenia", ds.Tables[0])); 
    147  
    148         List<ReportParameter> paramList = new List<ReportParameter>(); 
    149  
    150         //Produkcja ma domyœlnie bez podpisu  
    151         if (User.getUser().St_produkcja) 
    152         { 
    153             podpisCheckBox.CheckState = CheckState.Unchecked; 
    154         } 
    155  
    156         paramList.Add(new ReportParameter("podpis", podpisCheckBox.Checked.ToString(), true)); 
    157  
    158         if (this.rodzaj) 
    159         { 
    160             paramList.Add(new ReportParameter("proforma", "True", true)); 
    161         } 
    162         else 
    163         { 
    164             paramList.Add(new ReportParameter("proforma", "False", true)); 
    165         } 
    166  
    167         paramList.Add(new ReportParameter("zaplacono", zaplaconoCheckBox.Checked.ToString(), true)); 
    168  
    169         this.reportViewer1.LocalReport.SetParameters(paramList); 
    170  
    171         jezykComboBox.SelectedIndex = 0; 
    172         typComboBox.SelectedIndex = 1; 
    173     } 
     102        public FactureViewer(int idFakt, bool r) 
     103        { 
     104            Init(idFakt, r, string.Empty); 
     105        } 
     106 
     107        /// <param name="idFakt">ID_Faktury</param> 
     108        /// <param name="r">true = proforma</param> 
     109        /// <param name="kodKlienta"></param> 
     110        public FactureViewer(int idFakt, bool r, string kodKlienta) 
     111        { 
     112 
     113            Init(idFakt, r, kodKlienta); 
     114 
     115            //InitializeComponent(); 
     116 
     117 
     118            //idFaktury = idFakt; 
     119            //this.rodzaj = r; 
     120 
     121            //this.zapiszButton.Click += zapiszButton2_Click; 
     122 
     123            //fakturaTableAdapter1.Connection.ConnectionString = ConnString.getConnString().Value; 
     124            //fAKTURA_DETAILS2TableAdapter.Connection.ConnectionString = ConnString.getConnString().Value; 
     125            //fAKTURYTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value; 
     126            //proformaTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value; 
     127 
     128            //ds = new DataSet(); 
     129 
     130            ////zczytuje dane z pliku z tlumaczeniami 
     131            //Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream("Baza_Reklam.Raporty.faktura.xml"); 
     132            //ds.ReadXml(s); 
     133 
     134            //fAKTURYTableAdapter.FillByIdFaktury(this.rEKLAMADataSet.FAKTURY, idFakt); 
     135 
     136            ////ustawienie parametrów, nowych datasoure dla raportu 
     137 
     138            ////ustawianie danych dla raportu 
     139            //typComboBox.Enabled = false; 
     140 
     141            //raporty.FakturaDataTable fakturaDataTable = fakturaTableAdapter1.GetDataByIdFaktury(idFakt); 
     142            //raporty.FakturaRow faktura = (raporty.FakturaRow)fakturaDataTable.Rows[0]; 
     143 
     144            //if (IsFakturaPoznanOrKatowice(faktura.NUMER_ROZ, faktura.ID_NABYWCY)) 
     145            //    reportViewer1.LocalReport.ReportEmbeddedResource = "Baza_Reklam.Raporty.fakturaKatowicePoznan.rdlc"; 
     146            //else 
     147            //    reportViewer1.LocalReport.ReportEmbeddedResource = "Baza_Reklam.Raporty.fakturaReversed2.rdlc"; 
     148 
     149 
     150            //reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", fakturaDataTable)); 
     151            //reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FakturaDetails2", 
     152            //                                                               fAKTURA_DETAILS2TableAdapter.GetDataIdFaktury( 
     153            //                                                                   idFakt))); 
     154            //reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("tlumaczenia", ds.Tables[0])); 
     155 
     156            //List<ReportParameter> paramList = new List<ReportParameter>(); 
     157 
     158            ////Produkcja ma domyœlnie bez podpisu  
     159            //if (User.getUser().St_produkcja) 
     160            //{ 
     161            //    podpisCheckBox.CheckState = CheckState.Unchecked; 
     162            //} 
     163 
     164            //paramList.Add(new ReportParameter("podpis", podpisCheckBox.Checked.ToString(), true)); 
     165 
     166            //if (this.rodzaj) 
     167            //{ 
     168            //    paramList.Add(new ReportParameter("proforma", "True", true)); 
     169            //} 
     170            //else 
     171            //{ 
     172            //    paramList.Add(new ReportParameter("proforma", "False", true)); 
     173            //} 
     174 
     175            //paramList.Add(new ReportParameter("zaplacono", zaplaconoCheckBox.Checked.ToString(), true)); 
     176 
     177            //this.reportViewer1.LocalReport.SetParameters(paramList); 
     178 
     179            //jezykComboBox.SelectedIndex = 0; 
     180            //typComboBox.SelectedIndex = 1; 
     181        } 
     182 
     183        public void Init(int idFakt, bool r, string kodKlienta) 
     184        { 
     185            InitializeComponent(); 
     186 
     187 
     188            idFaktury = idFakt; 
     189            this.rodzaj = r; 
     190 
     191            this.zapiszButton.Click += zapiszButton2_Click; 
     192 
     193            fakturaTableAdapter1.Connection.ConnectionString = ConnString.getConnString().Value; 
     194            fAKTURA_DETAILS2TableAdapter.Connection.ConnectionString = ConnString.getConnString().Value; 
     195            fAKTURYTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value; 
     196            proformaTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value; 
     197 
     198            ds = new DataSet(); 
     199 
     200            //zczytuje dane z pliku z tlumaczeniami 
     201            Stream s = Assembly.GetExecutingAssembly().GetManifestResourceStream("Baza_Reklam.Raporty.faktura.xml"); 
     202            ds.ReadXml(s); 
     203 
     204            fAKTURYTableAdapter.FillByIdFaktury(this.rEKLAMADataSet.FAKTURY, idFakt); 
     205 
     206            //ustawienie parametrów, nowych datasoure dla raportu 
     207 
     208            //ustawianie danych dla raportu 
     209            typComboBox.Enabled = false; 
     210 
     211            raporty.FakturaDataTable fakturaDataTable = fakturaTableAdapter1.GetDataByIdFaktury(idFakt); 
     212            raporty.FakturaRow faktura = (raporty.FakturaRow)fakturaDataTable.Rows[0]; 
     213 
     214            if (IsFakturaPoznanOrKatowice(faktura.NUMER_ROZ, faktura.ID_NABYWCY)) 
     215                reportViewer1.LocalReport.ReportEmbeddedResource = "Baza_Reklam.Raporty.fakturaKatowicePoznan.rdlc"; 
     216            else 
     217                reportViewer1.LocalReport.ReportEmbeddedResource = "Baza_Reklam.Raporty.fakturaReversed2.rdlc"; 
     218 
     219 
     220            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", fakturaDataTable)); 
     221            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FakturaDetails2", 
     222                                                                           fAKTURA_DETAILS2TableAdapter.GetDataIdFaktury( 
     223                                                                               idFakt))); 
     224            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("tlumaczenia", ds.Tables[0])); 
     225 
     226            List<ReportParameter> paramList = new List<ReportParameter>(); 
     227 
     228            //Produkcja ma domyœlnie bez podpisu  
     229            if (User.getUser().St_produkcja) 
     230            { 
     231                podpisCheckBox.CheckState = CheckState.Unchecked; 
     232            } 
     233 
     234            paramList.Add(new ReportParameter("podpis", podpisCheckBox.Checked.ToString(), true)); 
     235 
     236            if (this.rodzaj) 
     237            { 
     238                paramList.Add(new ReportParameter("proforma", "True", true)); 
     239                paramList.Add(new ReportParameter("kodKlienta", kodKlienta, true)); 
     240            } 
     241            else 
     242            { 
     243                paramList.Add(new ReportParameter("proforma", "False", true)); 
     244                paramList.Add(new ReportParameter("kodKlienta", string.Empty, true)); 
     245            } 
     246 
     247            paramList.Add(new ReportParameter("zaplacono", zaplaconoCheckBox.Checked.ToString(), true)); 
     248 
     249            this.reportViewer1.LocalReport.SetParameters(paramList); 
     250 
     251            jezykComboBox.SelectedIndex = 0; 
     252            typComboBox.SelectedIndex = 1; 
     253        } 
    174254 
    175255        /// <summary> 
     
    191271 
    192272            this.zapiszButton.Click += zapiszKorektaButton_Click; 
    193                          
     273 
    194274            fakturaTableAdapter1.Connection.ConnectionString = ConnString.getConnString().Value; 
    195275            fAKTURA_DETAILS2TableAdapter.Connection.ConnectionString = ConnString.getConnString().Value; 
     
    208288 
    209289            typComboBox.Enabled = false; 
    210             
    211             reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Korekta",fakturaTableAdapter1.GetDataByIdFaktury(idKorekty))); 
     290 
     291            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Korekta", fakturaTableAdapter1.GetDataByIdFaktury(idKorekty))); 
    212292            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", fakturaTableAdapter1.GetDataByIdFaktury(idFaktury))); 
    213       
     293 
    214294            //piersza korekta 
    215295            if (idPoprzedniejKorekty == idFaktury) 
     
    300380            reportViewer1.Reset(); 
    301381            reportViewer1.LocalReport.ReportEmbeddedResource = this.rodzaj ? "Baza_Reklam.Raporty.fakturaReversed.rdlc" : "Baza_Reklam.Raporty.proformaReversed.rdlc"; 
    302             
     382 
    303383            //ustawienie parametrów, nowych datasoure dla raportu 
    304384            List<ReportParameter> paramList = new List<ReportParameter>(); 
    305385 
    306386            if (this.rodzaj) 
    307             {                
     387            { 
    308388                paramList.Add(new ReportParameter("jezyk", jezykComboBox.SelectedItem.ToString(), true)); 
    309389                paramList.Add(new ReportParameter("podpis", podpisCheckBox.Checked.ToString(), true)); 
     
    311391                reportViewer1.LocalReport.DataSources.Clear(); 
    312392                reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", fakturaTableAdapter1.GetDataByIdFaktury(idFaktury))); 
    313             
     393 
    314394            } 
    315395            else 
     
    320400                reportViewer1.LocalReport.DataSources.Clear(); 
    321401                reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", proformaTableAdapter.GetDataByIdFaktury(idFaktury))); 
    322             }      
     402            } 
    323403 
    324404            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FakturaDetails", fakturA_DETAILSTableAdapter1.GetDataByIdFaktury(idFaktury))); 
     
    341421            fAKTURYBindingSource.EndEdit(); 
    342422            fAKTURYTableAdapter.Update(this.rEKLAMADataSet.FAKTURY); 
    343             fAKTURYTableAdapter.FillByIdFaktury(this.rEKLAMADataSet.FAKTURY,idKorekty); 
     423            fAKTURYTableAdapter.FillByIdFaktury(this.rEKLAMADataSet.FAKTURY, idKorekty); 
    344424 
    345425            //ustawienie parametrów, nowych datasoure dla raportu 
     
    377457            paramList.Add(new ReportParameter("podpis", podpisCheckBox.Checked.ToString(), true)); 
    378458 
    379             reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Korekta",fakturaTableAdapter1.GetDataByIdFaktury(idKorekty))); 
     459            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Korekta", fakturaTableAdapter1.GetDataByIdFaktury(idKorekty))); 
    380460            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Faktura", fakturaTableAdapter1.GetDataByIdFaktury(idFaktury))); 
    381       
     461 
    382462            //piersza korekta 
    383463            if (idPoprzedniejKorekty == idFaktury) 
     
    390470            } 
    391471            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("FakturaDetailsKorekty", fAKTURA_DETAILS2TableAdapter.GetDataIdFaktury(idKorekty))); 
    392             
     472 
    393473            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("tlumaczenia", ds.Tables[0])); 
    394474 
     
    426506            } 
    427507            paramList.Add(new ReportParameter("zaplacono", zaplaconoCheckBox.Checked.ToString(), true)); 
    428          
     508 
    429509            this.reportViewer1.LocalReport.SetParameters(paramList); 
    430510            reportViewer1.LocalReport.DataSources.Clear(); 
     
    439519        } 
    440520 
    441        //drukowanie raportu serwerowego 
     521        //drukowanie raportu serwerowego 
    442522        /* 
    443523        private int m_currentPageIndex; 
     
    639719            row["opis"] = powodKorektyComboBox.SelectedItem.ToString(); 
    640720            fAKTURYBindingSource.EndEdit(); 
    641              
     721 
    642722            opisTextBox.Text = powodKorektyComboBox.SelectedItem.ToString(); 
    643723        } 
    644724 
    645    } 
     725    } 
    646726} 
  • trunk/BazaReklam/Raporty/fakturaReversed2.rdlc

    r281 r292  
    116116        </ParameterValues> 
    117117      </ValidValues> 
     118    </ReportParameter> 
     119    <ReportParameter Name="kodKlienta"> 
     120      <DataType>String</DataType> 
     121      <AllowBlank>true</AllowBlank> 
     122      <Prompt>kodKlienta</Prompt> 
     123      <Hidden>true</Hidden> 
    118124    </ReportParameter> 
    119125  </ReportParameters> 
     
    43214327                <CanGrow>true</CanGrow> 
    43224328                <Height>0.63492cm</Height> 
    4323                 <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> 
     4329                <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> 
    43244330              </Textbox> 
    43254331              <Textbox Name="FAKTURY_DRUK_INTERNATIONALlabel_oryginal_kopia"> 
  • trunk/BazaReklam/ZamowieniaForm.cs

    r268 r292  
    11using System; 
    2 using System.Collections.Generic; 
    3 using System.ComponentModel; 
    42using System.Data; 
    53using System.Data.SqlClient; 
    64using System.Drawing; 
    7 using System.Text; 
    85using System.Windows.Forms; 
    96 
     
    1411        private REKLAMADataSet.KLIENCIRow klient; 
    1512 
    16         private int idZamowienia = 0; 
    17         private int idFaktury = 0; 
     13        private int idZamowienia; 
     14        private int idFaktury; 
    1815 
    1916        private REKLAMADataSet.REKLAMADataTable reklamyBezZamowienia; 
     
    2926 
    3027        private REKLAMADataSetTableAdapters.UKAZE_SIE_W_NRTableAdapter emisjeTableAdapter = 
    31             new Baza_Reklam.REKLAMADataSetTableAdapters.UKAZE_SIE_W_NRTableAdapter(); 
     28            new REKLAMADataSetTableAdapters.UKAZE_SIE_W_NRTableAdapter(); 
    3229 
    3330        private REKLAMADataSetTableAdapters.FAKTURA_DETAILSTableAdapter fakturyDetailsTableAdapter = 
    34             new Baza_Reklam.REKLAMADataSetTableAdapters.FAKTURA_DETAILSTableAdapter(); 
     31            new REKLAMADataSetTableAdapters.FAKTURA_DETAILSTableAdapter(); 
    3532 
    3633        private REKLAMADataSetTableAdapters.WplatyTableAdapter wplatyTableAdapter = 
    37             new Baza_Reklam.REKLAMADataSetTableAdapters.WplatyTableAdapter(); 
     34            new REKLAMADataSetTableAdapters.WplatyTableAdapter(); 
    3835 
    3936        private REKLAMADataSetTableAdapters.DatyWydanTableAdapter datyWydanTableAdapter = 
    40             new Baza_Reklam.REKLAMADataSetTableAdapters.DatyWydanTableAdapter(); 
     37            new REKLAMADataSetTableAdapters.DatyWydanTableAdapter(); 
    4138 
    4239        private SLOWNIKDataSetTableAdapters.Kursy_WalutTableAdapter kursyWalutTableAdapter = 
    43             new Baza_Reklam.SLOWNIKDataSetTableAdapters.Kursy_WalutTableAdapter(); 
     40            new SLOWNIKDataSetTableAdapters.Kursy_WalutTableAdapter(); 
    4441 
    4542        #region properties 
     
    273270            if (zamowieniaBindingSource.Current != null && rEKLAMADataGridView.SelectedRows.Count != 0) 
    274271            { 
     272                DataRowView row = (DataRowView)rEKLAMADataGridView.SelectedRows[0].DataBoundItem; 
     273 
     274                if (Convert.ToBoolean(row["FAKTURA WYSTAWIONO"])) 
     275                { 
     276                    MessageBox.Show("Reklama ma zafakturowane emisje. Nie mo¿na usun¹æ reklamy."); 
     277                    return; 
     278                } 
     279 
     280                row["idZamowienia"] = DBNull.Value; 
     281                row.EndEdit(); 
     282 
     283                ReklamyBezZamowienia.ImportRow(row.Row); 
     284                rEKLAMADataSet.REKLAMA.Rows.Remove(row.Row); 
     285 
     286                rEKLAMATableAdapter.Update(ReklamyBezZamowienia); 
     287                zamowieniaTableAdapter.Update(rEKLAMADataSet.zamowienia); 
     288            } 
     289        } 
     290 
     291        private void button1_Click(object sender, EventArgs e) 
     292        { 
     293            if (zamowieniaBindingSource.Current != null) 
     294            { 
     295                Cursor = Cursors.WaitCursor; 
     296 
    275297                DataRowView z = (DataRowView)zamowieniaBindingSource.Current; 
    276298                REKLAMADataSet.zamowieniaRow zamowienie = (REKLAMADataSet.zamowieniaRow)z.Row; 
    277299 
    278                 DataRowView row = (DataRowView)rEKLAMADataGridView.SelectedRows[0].DataBoundItem; 
    279  
    280                 if (Convert.ToBoolean(row["FAKTURA WYSTAWIONO"]) == true) 
    281                 { 
    282                     MessageBox.Show("Reklama ma zafakturowane emisje. Nie mo¿na usun¹æ reklamy."); 
    283                     return; 
    284                 } 
    285  
    286                 row["idZamowienia"] = DBNull.Value; 
    287                 row.EndEdit(); 
    288  
    289                 ReklamyBezZamowienia.ImportRow(row.Row); 
    290                 rEKLAMADataSet.REKLAMA.Rows.Remove(row.Row); 
    291  
    292                 rEKLAMATableAdapter.Update(ReklamyBezZamowienia); 
    293                 zamowieniaTableAdapter.Update(rEKLAMADataSet.zamowienia); 
    294             } 
    295         } 
    296  
    297         private void button1_Click(object sender, EventArgs e) 
    298         { 
    299             if (zamowieniaBindingSource.Current != null) 
    300             { 
    301                 Cursor = Cursors.WaitCursor; 
    302  
    303                 DataRowView z = (DataRowView)zamowieniaBindingSource.Current; 
    304                 REKLAMADataSet.zamowieniaRow zamowienie = (REKLAMADataSet.zamowieniaRow)z.Row; 
    305  
    306                 REKLAMADataSet.KLIENCIRow klient = (REKLAMADataSet.KLIENCIRow)klienciTableAdapter.GetDataByCustomerId(zamowienie.idKlienta).Rows[0]; 
    307                 string errorMessage = czyMoznaZafakturowac(zamowienie, klient); 
     300                REKLAMADataSet.KLIENCIRow _klient = (REKLAMADataSet.KLIENCIRow)klienciTableAdapter.GetDataByCustomerId(zamowienie.idKlienta).Rows[0]; 
     301                string errorMessage = czyMoznaZafakturowac(zamowienie, _klient); 
    308302 
    309303                if (errorMessage != string.Empty) 
     
    314308                } 
    315309 
    316                 wystawFakture(zamowienie, klient); 
     310                wystawFakture(zamowienie, _klient, false); 
    317311 
    318312                RestoreConnections(); 
     
    324318        } 
    325319 
    326         private int wystawFakture(REKLAMADataSet.zamowieniaRow zamowienie, REKLAMADataSet.KLIENCIRow klient) 
     320        private int wystawFakture(REKLAMADataSet.zamowieniaRow zamowienie, REKLAMADataSet.KLIENCIRow klientRow, bool proforma) 
    327321        { 
    328322            int idNaglowka = 0; 
     
    330324            try 
    331325            { 
    332                 REKLAMADataSet.FAKTURYRow naglowekFaktury = utworzNaglowekFaktury(zamowienie, klient); 
     326                REKLAMADataSet.FAKTURYRow naglowekFaktury = utworzNaglowekFaktury(zamowienie, klientRow, proforma); 
    333327                rEKLAMADataSet.FAKTURY.AddFAKTURYRow(naglowekFaktury); 
    334328                pobierzOznaczEmisje(zamowienie, naglowekFaktury); 
    335                 utworzPozycjeFaktury(naglowekFaktury, klient); 
     329                utworzPozycjeFaktury(naglowekFaktury, klientRow); 
    336330                dodajWplate(naglowekFaktury); 
    337331 
     
    379373                    dtpZmianaDaty.Value = DateTime.Today; 
    380374                } 
    381                 catch (Exception e1) 
     375                catch (Exception) 
    382376                { 
    383377                    transaction.Rollback(); 
     
    390384                    fAKTURYBindingSource.ResetBindings(false); 
    391385                    fAKTURYDataGridView.Refresh(); 
    392                     throw e1; 
     386                    throw; 
    393387                } 
    394388                finally 
    395389                { 
    396                     if (conn != null && conn.State == ConnectionState.Open) 
     390                    if (conn.State == ConnectionState.Open) 
    397391                        conn.Close(); 
    398392                } 
     
    400394            catch (Exception e2) 
    401395            { 
    402                 MessageBox.Show("Wyst¹pi³ b³¹d: \n" + e2.ToString()); 
     396                MessageBox.Show("Wyst¹pi³ b³¹d: \n" + e2); 
    403397            } 
    404398            finally 
     
    426420        } 
    427421 
    428         private void utworzPozycjeFaktury(REKLAMADataSet.FAKTURYRow naglowekFaktury, REKLAMADataSet.KLIENCIRow klient) 
     422        private void utworzPozycjeFaktury(REKLAMADataSet.FAKTURYRow naglowekFaktury, REKLAMADataSet.KLIENCIRow klientRow) 
    429423        { 
    430424            decimal brutto_waluta = 0; 
     
    451445                fakturaDetailsRow.JM = "szt."; 
    452446 
    453                 if (naglowekFaktury.Iswaluta_mianoNull() && klient.Country.ToUpper() == "POLSKA") 
     447                if (naglowekFaktury.Iswaluta_mianoNull() && klientRow.Country.ToUpper() == "POLSKA") 
    454448                { 
    455449                    fakturaDetailsRow.UPUST_NETTO = Convert.ToDecimal(reklama.RABAT) * fakturaDetailsRow.CENA_JEDN; 
     
    462456                    fakturaDetailsRow.NETTO = netto; 
    463457                    fakturaDetailsRow.S_VAT = reklama.VAT; 
    464                     decimal VAT = Convert.ToDecimal(reklama.VAT); 
    465                     fakturaDetailsRow.VAT = Convert.ToDecimal(VAT * netto); 
    466                     fakturaDetailsRow.BRUTTO = Convert.ToDecimal((1 + VAT) * netto); 
    467                 } 
    468                 else if(naglowekFaktury.Iswaluta_mianoNull() && klient.Country.ToUpper() != "POLSKA") 
    469                 { 
    470                     decimal VAT = Convert.ToDecimal(reklama.VAT); 
     458                    decimal _vat = Convert.ToDecimal(reklama.VAT); 
     459                    fakturaDetailsRow.VAT = Convert.ToDecimal(_vat * netto); 
     460                    fakturaDetailsRow.BRUTTO = Convert.ToDecimal((1 + _vat) * netto); 
     461                } 
     462                else if(naglowekFaktury.Iswaluta_mianoNull() && klientRow.Country.ToUpper() != "POLSKA") 
     463                { 
     464                    decimal _vat = Convert.ToDecimal(reklama.VAT); 
    471465                    decimal netto = (1 - Convert.ToDecimal(reklama.RABAT)) * fakturaDetailsRow.CENA_JEDN; 
    472466                    if (reklama.wyroznienie) 
     
    474468                    fakturaDetailsRow.NETTO = netto; 
    475469                    fakturaDetailsRow.S_VAT = reklama.VAT; 
    476                     fakturaDetailsRow.BRUTTO = Convert.ToDecimal((1 + VAT) * netto); 
     470                    fakturaDetailsRow.BRUTTO = Convert.ToDecimal((1 + _vat) * netto); 
    477471                     
    478472                    decimal brutto = fakturaDetailsRow.BRUTTO; 
    479473 
    480                     fakturaDetailsRow.VAT = Convert.ToDecimal(VAT * brutto / (1 + VAT)); 
     474                    fakturaDetailsRow.VAT = Convert.ToDecimal(_vat * brutto / (1 + _vat)); 
    481475 
    482476                    fakturaDetailsRow.UPUST_PR = reklama.RABAT; 
     
    493487                    brutto_waluta += Convert.ToDecimal(reklama.Brutto_Euro / reklama.KROTNOŒÆ); 
    494488                    fakturaDetailsRow.S_VAT = reklama.VAT; 
    495                     decimal VAT = Convert.ToDecimal(reklama.VAT); 
     489                    decimal _vat = Convert.ToDecimal(reklama.VAT); 
    496490                    decimal brutto = fakturaDetailsRow.BRUTTO; 
    497                     fakturaDetailsRow.VAT = Convert.ToDecimal(VAT * brutto / (1 + VAT)); 
     491                    fakturaDetailsRow.VAT = Convert.ToDecimal(_vat * brutto / (1 + _vat)); 
    498492                    decimal netto = brutto - fakturaDetailsRow.VAT; 
    499493                    fakturaDetailsRow.NETTO = netto; 
     
    633627        } 
    634628 
    635         private REKLAMADataSet.FAKTURYRow utworzNaglowekFaktury(REKLAMADataSet.zamowieniaRow zamowienie, REKLAMADataSet.KLIENCIRow klient) 
     629        private REKLAMADataSet.FAKTURYRow utworzNaglowekFaktury(REKLAMADataSet.zamowieniaRow zamowienie, REKLAMADataSet.KLIENCIRow klientRow, bool proforma) 
    636630        { 
    637631            REKLAMADataSet.FAKTURYRow naglowekFaktury = (REKLAMADataSet.FAKTURYRow)rEKLAMADataSet.FAKTURY.NewRow(); 
    638632            naglowekFaktury.idZamowienia = zamowienie.idZamowienia; 
    639633            naglowekFaktury.NUMER_ROZ = zamowienie.kodAgenta; 
    640             naglowekFaktury.NUMER = Utils.numerNowejFaktury(naglowekFaktury.NUMER_ROZ, DateTime.Today.Year); 
     634            naglowekFaktury.NUMER = proforma ? zamowienie.nrZamowienia : Utils.numerNowejFaktury(naglowekFaktury.NUMER_ROZ, DateTime.Today.Year); 
     635 
    641636            naglowekFaktury.NUMER_ROK = DateTime.Today.Year; 
    642637            naglowekFaktury.DATA_WYSTAWIENIA = DateTime.Today; 
     
    668663 
    669664            naglowekFaktury.ID_NABYWCY = zamowienie.idKlienta; 
    670             naglowekFaktury.NABYWCA_ADRES = klient.Adres_Fkatura; 
    671             naglowekFaktury.NABYWCA_NIP = klient.Nip; 
     665            naglowekFaktury.NABYWCA_ADRES = klientRow.Adres_Fkatura; 
     666            naglowekFaktury.NABYWCA_NIP = klientRow.Nip; 
    672667            naglowekFaktury.opis = "Faktura za reklamy zgodnie z zamówieniem: "  
    673                 + klient.kodKlienta +  
     668                + klientRow.kodKlienta +  
    674669                "/" + zamowienie.nrZamowienia +  
    675670                "/" + zamowienie.kodAgenta +  
    676671                "/" + zamowienie.rokZamowienia; 
    677672 
    678             switch (zamowienie.sposobZaplaty) 
    679             { 
    680                 case 0: 
    681                     naglowekFaktury.SPOSOB_ZAPLATY = "Karta kredytowa"; 
    682                     break; 
    683                 case 1: 
    684                     naglowekFaktury.SPOSOB_ZAPLATY = "Przelew"; 
    685                     break; 
    686                 case 2: 
    687                     naglowekFaktury.SPOSOB_ZAPLATY = "Gotówka"; 
    688                     break; 
    689                 case 3: 
    690                     naglowekFaktury.SPOSOB_ZAPLATY = "Barter"; 
    691                     break; 
    692                 default: 
    693                     break; 
    694             } 
    695  
     673 
     674            naglowekFaktury.SPOSOB_ZAPLATY = FakturaHelper.GetPaymentType(zamowienie.sposobZaplaty); 
    696675            naglowekFaktury.TERMIN_ZAPLATY = naglowekFaktury.DATA_SPRZEDAZY.AddDays(zamowienie.czasPlatnosci); 
    697676            naglowekFaktury.ZAPLACONO = false; 
     
    707686            { 
    708687                naglowekFaktury.SPRZEDAWCA_NIP = agencja.vies; 
    709                 naglowekFaktury.NABYWCA_NIP = klient.nipKraj + " " + klient.Nip; 
     688                naglowekFaktury.NABYWCA_NIP = klientRow.nipKraj + " " + klientRow.Nip; 
    710689                naglowekFaktury.waluta_miano = rEKLAMADataSet.REKLAMA[0].Brutto_Euro_Miano; 
    711690 
     
    725704                naglowekFaktury.waluta_tabela_nr = kurs[0].Numer_Tabeli; 
    726705            } 
    727             // jesli klient jest zagraniczny a waluta ciagle PLN 
    728             else if (klient.Country.ToUpper() != "POLSKA") 
     706            // jesli klientRow jest zagraniczny a waluta ciagle PLN 
     707            else if (klientRow.Country.ToUpper() != "POLSKA") 
    729708            { 
    730709                naglowekFaktury.SPRZEDAWCA_NIP = agencja.vies; 
    731                 naglowekFaktury.NABYWCA_NIP = klient.nipKraj + " " + klient.Nip; 
     710                naglowekFaktury.NABYWCA_NIP = klientRow.nipKraj + " " + klientRow.Nip; 
    732711            } 
    733712 
     
    736715        } 
    737716 
    738         private string czyMoznaZafakturowac(REKLAMADataSet.zamowieniaRow zamowienie, REKLAMADataSet.KLIENCIRow klient) 
     717         
     718 
     719        private string czyMoznaZafakturowac(REKLAMADataSet.zamowieniaRow zamowienie, REKLAMADataSet.KLIENCIRow klientRow) 
    739720        { 
    740721            string errorMessage = string.Empty; 
     
    744725            errorMessage += zamowienie.IsidKontaNull() ? "Nie wybrano konta. \n" : ""; 
    745726            errorMessage += zamowienie.IssposobZaplatyNull() ? "Nie wybrano sposobu zap³aty. \n" : ""; 
    746             errorMessage += klient.IsCountryNull() || klient.Country == string.Empty ? "Brak pañstwa klienta. \n" : ""; 
    747             errorMessage += klient.IsAdres_FkaturaNull() || klient.Adres_Fkatura == string.Empty ? "Brak adresu faktury klienta. \n" : ""; 
    748             errorMessage += klient.IsNipNull() || klient.Nip == string.Empty ? "Brak nipu klienta. \n" : ""; 
    749  
    750             if (klient.Country != "Polska") 
    751             { 
    752                 errorMessage += klient.IsnipKrajNull() || klient.nipKraj == string.Empty ? "Brak symbolu kraju w nipie klienta. \n" : ""; 
     727            errorMessage += klientRow.IsCountryNull() || klientRow.Country == string.Empty ? "Brak pañstwa klienta. \n" : ""; 
     728            errorMessage += klientRow.IsAdres_FkaturaNull() || klientRow.Adres_Fkatura == string.Empty ? "Brak adresu faktury klienta. \n" : ""; 
     729            errorMessage += klientRow.IsNipNull() || klientRow.Nip == string.Empty ? "Brak nipu klienta. \n" : ""; 
     730 
     731            if (klientRow.Country != "Polska") 
     732            { 
     733                errorMessage += klientRow.IsnipKrajNull() || klientRow.nipKraj == string.Empty ? "Brak symbolu kraju w nipie klienta. \n" : ""; 
    753734            } 
    754735 
     
    876857                        transaction.Commit(); 
    877858                    } 
    878                     catch (Exception e1) 
     859                    catch (Exception) 
    879860                    { 
    880861                        transaction.Rollback(); 
    881862                        conn.Close(); 
    882                         throw e1; 
     863                        throw; 
    883864                    } 
    884865                } 
    885866                catch (Exception e2) 
    886867                { 
    887                     MessageBox.Show("Wyst¹pi³ b³¹d: \n" + e2.ToString()); 
     868                    MessageBox.Show("Wyst¹pi³ b³¹d: \n" + e2); 
    888869                } 
    889870                finally 
     
    912893            naglowekKorekty.idFakturyVAT = faktura.ID_FAKTURY; 
    913894 
    914             naglowekKorekty.NUMER_ROZ = faktura.NUMER_ROZ; ; 
     895            naglowekKorekty.NUMER_ROZ = faktura.NUMER_ROZ; 
    915896            naglowekKorekty.NUMER = Utils.numerNowejFakturyKorekty(naglowekKorekty.NUMER_ROZ, DateTime.Today.Year); 
    916897            naglowekKorekty.NUMER_ROK = DateTime.Today.Year; 
     
    1009990                        fakturaDetailsRow.NETTO = netto; 
    1010991                        fakturaDetailsRow.S_VAT = reklama.VAT; 
    1011                         decimal VAT = Convert.ToDecimal(reklama.VAT); 
    1012                         fakturaDetailsRow.VAT = Convert.ToDecimal(Math.Round(VAT * netto, 2)); 
    1013                         fakturaDetailsRow.BRUTTO = Convert.ToDecimal(Math.Round((1 + VAT) * netto, 2)); 
     992                        decimal _vat = Convert.ToDecimal(reklama.VAT); 
     993                        fakturaDetailsRow.VAT = Convert.ToDecimal(Math.Round(_vat * netto, 2)); 
     994                        fakturaDetailsRow.BRUTTO = Convert.ToDecimal(Math.Round((1 + _vat) * netto, 2)); 
    1014995                    } 
    1015996                    else 
     
    10201001                        brutto_waluta += Convert.ToDecimal(reklama.Brutto_Euro / reklama.KROTNOŒÆ); 
    10211002                        fakturaDetailsRow.S_VAT = reklama.VAT; 
    1022                         decimal VAT = Convert.ToDecimal(reklama.VAT); 
     1003                        decimal _vat = Convert.ToDecimal(reklama.VAT); 
    10231004                        decimal brutto = fakturaDetailsRow.BRUTTO; 
    1024                         fakturaDetailsRow.VAT = Convert.ToDecimal(Math.Round(VAT * brutto / (1 + VAT), 2)); 
     1005                        fakturaDetailsRow.VAT = Convert.ToDecimal(Math.Round(_vat * brutto / (1 + _vat), 2)); 
    10251006                        decimal netto = brutto - fakturaDetailsRow.VAT; 
    10261007                        fakturaDetailsRow.NETTO = netto; 
     
    10961077            { 
    10971078                DataRowView row = (DataRowView)fAKTURYBindingSource.Current; 
    1098                 REKLAMADataSet.FAKTURYRow f = 
    1099                     (REKLAMADataSet.FAKTURYRow)row.Row; 
    1100  
    1101                 REKLAMADataSetTableAdapters.WplatyTableAdapter wplatyTableAdapter 
    1102                 = new Baza_Reklam.REKLAMADataSetTableAdapters.WplatyTableAdapter(); 
    1103                 wplatyTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value; 
    1104                 REKLAMADataSet.WplatyDataTable table = wplatyTableAdapter.GetDataByIdFaktury(f.ID_FAKTURY); 
    1105  
    1106                 PaymentForm2 pf2; 
    1107  
    1108                 if (table.Count == 0) 
    1109                 { 
    1110                     pf2 = new PaymentForm2(0, f.ID_FAKTURY); 
    1111                 } 
    1112                 else 
    1113                 { 
    1114                     pf2 = new PaymentForm2(table[0].idWplaty, f.ID_FAKTURY); 
    1115                 } 
     1079                REKLAMADataSet.FAKTURYRow f = (REKLAMADataSet.FAKTURYRow)row.Row; 
     1080 
     1081                REKLAMADataSetTableAdapters.WplatyTableAdapter wplaty = new REKLAMADataSetTableAdapters.WplatyTableAdapter(); 
     1082                wplaty.Connection.ConnectionString = ConnString.getConnString().Value; 
     1083                REKLAMADataSet.WplatyDataTable table = wplaty.GetDataByIdFaktury(f.ID_FAKTURY); 
     1084 
     1085                PaymentForm2 pf2 = table.Count == 0 ? new PaymentForm2(0, f.ID_FAKTURY) : new PaymentForm2(table[0].idWplaty, f.ID_FAKTURY); 
    11161086 
    11171087                pf2.ShowDialog(); 
     
    11571127        private void fAKTURYBindingSource_CurrentChanged(object sender, EventArgs e) 
    11581128        { 
    1159             if (fAKTURYBindingSource.Current != null) 
    1160             { 
    1161                 if ( 
    1162                     ((REKLAMADataSet.FAKTURYRow) 
    1163                     ((DataRowView)fAKTURYBindingSource.Current).Row).KOREKTA) 
    1164                 { 
    1165                     wplataButton.Enabled = false; 
    1166                 } 
    1167                 else 
    1168                 { 
    1169                     wplataButton.Enabled = true; 
    1170                 } 
    1171             } 
     1129            if (fAKTURYBindingSource.Current == null) return; 
     1130 
     1131            wplataButton.Enabled = !((REKLAMADataSet.FAKTURYRow)((DataRowView)fAKTURYBindingSource.Current).Row).KOREKTA; 
    11721132        } 
    11731133 
     
    12881248                transaction.Commit(); 
    12891249            } 
    1290             catch (Exception ex) 
     1250            catch (Exception) 
    12911251            { 
    12921252                transaction.Rollback(); 
     
    13951355                REKLAMADataSet.zamowieniaRow zamowienie = (REKLAMADataSet.zamowieniaRow)z.Row; 
    13961356 
    1397                 REKLAMADataSet.KLIENCIRow klient = (REKLAMADataSet.KLIENCIRow)klienciTableAdapter.GetDataByCustomerId(zamowienie.idKlienta).Rows[0]; 
    1398                 string errorMessage = czyMoznaZafakturowac(zamowienie, klient); 
     1357                REKLAMADataSet.KLIENCIRow _klient = (REKLAMADataSet.KLIENCIRow)klienciTableAdapter.GetDataByCustomerId(zamowienie.idKlienta).Rows[0]; 
     1358                string errorMessage = czyMoznaZafakturowac(zamowienie, _klient); 
    13991359 
    14001360                if (errorMessage != string.Empty) 
     
    14051365                } 
    14061366 
    1407                 int id = wystawFakture(zamowienie, klient); 
    1408                 FactureViewer fv = new FactureViewer(id, true); 
     1367                int id = wystawFakture(zamowienie, _klient, true); 
     1368                FactureViewer fv = new FactureViewer(id, true, _klient.kodKlienta); 
    14091369 
    14101370                fv.ShowDialog();