Pokaż
Ignoruj:
Data:
2009-04-27 11:12:42 (17 years ago)
Autor:
marek
Opis:

re #165 - merged with latest trunk

Lokalizacja:
branches/ReklamaReorganizacja
Pliki:
7 usunięte
28 zmodyfikowane
9 skopiowane

Legenda:

Bez zmian
Dodane
Usunięte
  • branches/ReklamaReorganizacja/BazaReklam.sln

    r601 r613  
    1010Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExportToCDN", "TruckExpoCDN\ExportToCDN.csproj", "{E06D8F95-3C3F-4369-A60C-9DFF6703E8A0}" 
    1111EndProject 
    12 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Updater", "Updater\Updater.csproj", "{D79A9AD4-2E15-4A9B-98C9-467B25D47FEA}" 
     12Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BazaReklam.Updater", "BazaReklam.Updater\BazaReklam.Updater.csproj", "{D79A9AD4-2E15-4A9B-98C9-467B25D47FEA}" 
    1313EndProject 
    1414Global 
  • branches/ReklamaReorganizacja/BazaReklam/AddClient.Designer.cs

    r601 r613  
    10501050            this.Text = "Dodaj/modyfikuj klienta"; 
    10511051            this.Load += new System.EventHandler(this.AddClient_Load); 
     1052            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.AddClient_FormClosing); 
    10521053            this.gbAddress.ResumeLayout(false); 
    10531054            this.gbAddress.PerformLayout(); 
  • branches/ReklamaReorganizacja/BazaReklam/AddClient.cs

    r601 r613  
    246246            errorProvider.SetError(txtClientCode, sb.ToString()); 
    247247        } 
     248 
     249        private void AddClient_FormClosing(object sender, FormClosingEventArgs e) 
     250        { 
     251            rEKLAMADataSet.KLIENCI.RejectChanges(); 
     252        } 
    248253    } 
    249254} 
  • branches/ReklamaReorganizacja/BazaReklam/AddZamowienieForm.cs

    r593 r613  
    3838                row = (REKLAMADataSet.zamowieniaRow)r.Row; 
    3939 
    40                 row.nrZamowienia =  DbUtils.numerNowegoZamowienia(idKlienta, DateTime.Today.Year, User.Instance().Kod_agenta); 
    41                 row.rokZamowienia = DateTime.Today.Year; 
     40                row.nrZamowienia =  DbUtils.numerNowegoZamowienia(idKlienta, DateTime.Now.Year, User.Instance().Kod_agenta); 
     41                row.rokZamowienia = DateTime.Now.Year; 
    4242                row.kodAgenta = User.Instance().Kod_agenta; 
    4343                row.idKlienta = idKlienta; 
  • branches/ReklamaReorganizacja/BazaReklam/Baza Reklam.csproj

    r593 r613  
    108108    <Compile Include="Classes\DBBindings.cs" /> 
    109109    <Compile Include="Classes\EmailSender.cs" /> 
    110     <Compile Include="Classes\ExcelHelper.cs" /> 
    111     <Compile Include="Classes\FakturaHelper.cs" /> 
     110    <Compile Include="Classes\Helpers\ExcelHelper.cs" /> 
     111    <Compile Include="Classes\Helpers\FakturaHelper.cs" /> 
    112112    <Compile Include="Classes\Helpers\ConfigurationHelper.cs" /> 
    113113    <Compile Include="Classes\Helpers\PdfHelper.cs" /> 
    114114    <Compile Include="Classes\Helpers\StringHelper.cs" /> 
    115115    <Compile Include="Classes\Helpers\WebRequestHelper.cs" /> 
     116    <Compile Include="Classes\Interfaces\IInvoiceProvider.cs" /> 
    116117    <Compile Include="Classes\Interfaces\IForm.cs" /> 
    117118    <Compile Include="Classes\Model\Invoice.cs" /> 
     
    124125    <Compile Include="Classes\PrintDGV.cs" /> 
    125126    <Compile Include="Classes\Produkcja.cs" /> 
    126     <Compile Include="Classes\ReklamaHelper.cs" /> 
     127    <Compile Include="Classes\Helpers\ReklamaHelper.cs" /> 
    127128    <Compile Include="Classes\Repositories\UserAgencyRepository.cs" /> 
    128129    <Compile Include="Classes\User.cs" /> 
    129130    <Compile Include="Classes\DbUtils.cs" /> 
    130131    <Compile Include="Classes\Helpers\ValidationHelper.cs" /> 
    131     <Compile Include="Classes\VatHelper.cs" /> 
    132     <Compile Include="Classes\WordHandler.cs" /> 
     132    <Compile Include="Classes\Helpers\VatHelper.cs" /> 
     133    <Compile Include="Classes\Helpers\WordHelper.cs" /> 
    133134    <Compile Include="Classes\XTGFile.cs" /> 
    134     <Compile Include="Classes\ZamowienieHelper.cs" /> 
     135    <Compile Include="Classes\Helpers\ZamowienieHelper.cs" /> 
    135136    <Compile Include="ClientsForm.cs"> 
    136137      <SubType>Form</SubType> 
  • branches/ReklamaReorganizacja/BazaReklam/Classes/DbUtils.cs

    r593 r613  
    195195        } 
    196196 
    197         /// <summary> 
    198         /// Zwraca numer nastêpnej faktury danego agenta. 
    199         /// </summary> 
    200         public static int numerNowejFaktury(string tagAgenta, int year) 
    201         { 
    202             string query = "SELECT MAX(Numer) FROM Faktury WHERE Korekta=0 AND [Numer_Roz]='" + tagAgenta + "' AND [Numer_Rok]=" + year; 
    203  
    204             object nr = ExecuteQuery(query); 
    205             if (nr is DBNull) return 1; 
    206             return ((int)nr + 1); 
    207         } 
     197 
    208198 
    209199 
     
    273263 
    274264        /// <summary> 
    275         /// Zwraca numer nowego zamówienia 
    276         /// </summary> 
    277         public static int numerNowegoZamowienia(int idKlienta, int year, string kodAgenta) 
    278         { 
    279             string query = "SELECT MAX(nrZamowienia) FROM Zamowienia WHERE idKlienta=" + idKlienta + " AND rokZamowienia=" + year + " AND kodAgenta='" + kodAgenta + "'"; 
     265        /// Zwraca numer nastêpnej faktury danego agenta. 
     266        /// </summary> 
     267        public static int numerNowejFaktury(string tagAgenta, int year) 
     268        { 
     269            string query = "SELECT MAX(Numer) FROM Faktury WHERE Korekta=0 AND [Numer_Roz]='" + tagAgenta + "' AND [Numer_Rok]=" + year; 
    280270 
    281271            object nr = ExecuteQuery(query); 
     
    284274        } 
    285275 
    286         /// <summary> 
    287         /// Zwraca numer nastêpnej faktury korekty dla danego agenta. 
    288         /// </summary> 
    289         public static int numerNowejFakturyKorekty(int year) 
    290         { 
    291             string query = "SELECT MAX(Numer) FROM Faktury WHERE Korekta=1 AND [Numer_Rok]=" + year; 
     276 
     277        /// <summary> 
     278        /// Zwraca numer nowego zamówienia 
     279        /// </summary> 
     280        public static int numerNowegoZamowienia(int idKlienta, int year, string kodAgenta) 
     281        { 
     282            string query = "SELECT MAX(nrZamowienia) FROM Zamowienia WHERE idKlienta=" + idKlienta + " AND rokZamowienia=" + year + " AND kodAgenta='" + kodAgenta + "'"; 
    292283 
    293284            object nr = ExecuteQuery(query); 
  • branches/ReklamaReorganizacja/BazaReklam/Classes/Helpers/PdfHelper.cs

    r593 r613  
    33using System.Globalization; 
    44using System.IO; 
     5using System.Windows.Forms; 
    56 
    67namespace Baza_Reklam.Classes.Helpers 
     
    3334            if (!DateTime.TryParse(pdfDate, null, DateTimeStyles.None, out pdfDateTime)) 
    3435            { 
    35                 //MessageBox.Show("Nie znaleziono pliku PDF dla wybranej reklamy"); 
    3636                _errorMessage = "Nie znaleziono pliku PDF dla wybranej reklamy"; 
    3737                return false; 
     
    8484            } 
    8585        } 
     86 
     87        public static void HandleWebException(Exception exception) 
     88        { 
     89            string errorMsg = string.Format("{0}\n\n{1}\n{2}", 
     90                                "Problem z serwerem który dostarcza pliki PDF", 
     91                                "Szczegó³y wyj¹tku:", 
     92                                exception); 
     93            MessageBox.Show(errorMsg, "Baza Reklam - Podgl¹d PDF", MessageBoxButtons.OK, MessageBoxIcon.Warning); 
     94            Logger.LogException(exception, User.Instance().Login, DateTime.Now); 
     95        } 
    8696    } 
    8797} 
  • branches/ReklamaReorganizacja/BazaReklam/Classes/InvoiceProvider.cs

    r539 r613  
     1using Baza_Reklam.Classes.Interfaces; 
     2 
    13namespace Baza_Reklam 
    24{ 
    3     public class InvoiceProvider 
     5    public class InvoiceProvider : IInvoiceProvider 
    46    { 
    57        private string _city; 
  • branches/ReklamaReorganizacja/BazaReklam/Classes/InvoiceProviderFactory.cs

    r539 r613  
    33using System.Data; 
    44using System.Data.SqlClient; 
     5using Baza_Reklam.Classes.Interfaces; 
    56 
    67namespace Baza_Reklam 
     
    910    { 
    1011        private static InvoiceProviderFactory _instance; 
    11         private readonly List<InvoiceProvider> _invoiceProviders = new List<InvoiceProvider>(); 
     12        private readonly List<IInvoiceProvider> _invoiceProviders = new List<IInvoiceProvider>(); 
    1213 
    1314        private InvoiceProviderFactory() 
     
    8081        } 
    8182 
    82         public static List<InvoiceProvider> GetInvoiceProviders() 
     83        public static List<IInvoiceProvider> GetInvoiceProviders() 
    8384        { 
    8485            return Instance._invoiceProviders; 
    8586        } 
    8687 
    87         public static InvoiceProvider GetInvoiceProviderById(int invoiceProviderId) 
     88        public static IInvoiceProvider GetInvoiceProviderById(int invoiceProviderId) 
    8889        { 
    8990            return 
    9091                Instance._invoiceProviders.Find( 
    91                     delegate(InvoiceProvider invoiceProvider) { return invoiceProvider.Id == invoiceProviderId; }); 
     92                    delegate(IInvoiceProvider invoiceProvider) { return invoiceProvider.Id == invoiceProviderId; }); 
    9293        } 
    9394 
    94         public static List<InvoiceProvider> GetInvoiceProvidersById(int invoiceProviderId) 
     95        public static List<IInvoiceProvider> GetInvoiceProvidersById(int invoiceProviderId) 
    9596        { 
    9697            return 
    9798                Instance._invoiceProviders.FindAll( 
    98                     delegate(InvoiceProvider invoiceProvider) { return invoiceProvider.Id == invoiceProviderId; }); 
     99                    delegate(IInvoiceProvider invoiceProvider) { return invoiceProvider.Id == invoiceProviderId; }); 
    99100        } 
    100101    } 
  • branches/ReklamaReorganizacja/BazaReklam/ClientsForm.cs

    r601 r613  
    77using System.IO; 
    88using System.Text.RegularExpressions; 
     9using Baza_Reklam.Classes; 
    910using Baza_Reklam.Classes.Helpers; 
    1011using Baza_Reklam.Classes.Interfaces; 
     
    12171218                if (!pdfHelper.DisplayPdf()) 
    12181219                    MessageBox.Show(pdfHelper.ErrorMessage); 
     1220            } 
     1221            catch (System.Net.WebException exception) 
     1222            { 
     1223                PdfHelper.HandleWebException(exception); 
    12191224            } 
    12201225            finally 
  • branches/ReklamaReorganizacja/BazaReklam/Docs/versioninfo.html

    r601 r613  
    55</head> 
    66<body> 
    7     <h1>Baza reklam - Informacje o wersji</h1> 
     7   <h1>Baza reklam - Informacje o wersji</h1> 
     8   <div> 
     9        <a id="1.1.6" /> 
     10        <h2>Wersja 1.1.6 (2009-04-27)</h2> 
     11        <p>Opis zmian wprowadzonych do wersji 1.1.6</p> 
     12        <ul> 
     13            <li>Zgłoszenie #160: Bieżące poprawki na podstawie logu błędów</li> 
     14            <li>Zgłoszenie #165: Naprawa błędów występujących podczas aktualizacji</li> 
     15        </ul> 
     16   </div> 
     17   <div> 
     18        <a id="1.1.5" /> 
     19        <h2>Wersja 1.1.5 (2009-04-23)</h2> 
     20        <p>Opis zmian wprowadzonych do wersji 1.1.5</p> 
     21        <ul> 
     22            <li>Zgłoszenie #166: Umożliwić wystawianie korekt do faktur Sam Press</li> 
     23        </ul> 
     24   </div> 
    825   <div> 
    926        <a id="1.1.4" /> 
  • branches/ReklamaReorganizacja/BazaReklam/Facturer.cs

    r593 r613  
    33using System.Data.SqlClient; 
    44using System.Windows.Forms; 
     5using Baza_Reklam.Classes.Helpers; 
    56 
    67namespace Baza_Reklam 
     
    764765 
    765766            naglowekKorekty.NUMER_ROZ = faktura.NUMER_ROZ; 
    766             naglowekKorekty.NUMER = DbUtils.numerNowejFakturyKorekty(DateTime.Today.Year); 
     767            naglowekKorekty.NUMER = FakturaHelper.GetNewCorrectionInvoiceNumber(DateTime.Today.Year, faktura.SystemKsiegowyId); 
    767768            naglowekKorekty.NUMER_ROK = DateTime.Today.Year; 
    768769            naglowekKorekty.DATA_WYSTAWIENIA = DateTime.Today; 
  • branches/ReklamaReorganizacja/BazaReklam/FacturesForm.cs

    r593 r613  
    44using System.Data.SqlClient; 
    55using System.Windows.Forms; 
     6using Baza_Reklam.Classes.Helpers; 
    67using Baza_Reklam.Classes.Interfaces; 
    78 
  • branches/ReklamaReorganizacja/BazaReklam/FacturesFormNEW.cs

    r593 r613  
    55using System.Drawing; 
    66using System.Windows.Forms; 
     7using Baza_Reklam.Classes.Helpers; 
    78using Baza_Reklam.Classes.Interfaces; 
    89 
  • branches/ReklamaReorganizacja/BazaReklam/FakturowaniePoznanKatowice.cs

    r593 r613  
    66using System.Globalization; 
    77using System.Data.SqlClient; 
     8using Baza_Reklam.Classes.Helpers; 
    89using Baza_Reklam.Classes.Model; 
    910 
     
    4849            _agencjaRedakcja = agencjeTableAdapter.GetDataByIdAgencji((int)FakturaHelper.OfficeId.Redakcja)[0]; 
    4950 
    50             _konto = kontaTableAdapter.GetDataById((int)FakturaHelper.BankAccount.CentralaPLN)[0]; 
     51            _konto = kontaTableAdapter.GetDataById((int)FakturaHelper.BankAccount.CentralaPln)[0]; 
    5152        } 
    5253 
     
    542543 
    543544            naglowekKorekty.NUMER_ROZ = faktura.NUMER_ROZ; 
    544             naglowekKorekty.NUMER = DbUtils.numerNowejFakturyKorekty(DateTime.Today.Year); 
     545            naglowekKorekty.NUMER = FakturaHelper.GetNewCorrectionInvoiceNumber(DateTime.Today.Year, faktura.SystemKsiegowyId); 
    545546            naglowekKorekty.NUMER_ROK = DateTime.Today.Year; 
    546547            naglowekKorekty.DATA_WYSTAWIENIA = DateTime.Today; 
     
    593594            if (pozycjeFakturDlaKlientow.Rows.Count == 0 || naglowkiFakturDlaKlientow.Rows.Count == 0) 
    594595            { 
    595                 throw new Exception("Nie ma co fakturowaæ"); 
     596                //TODO: check is there is anythig to invoice before callind that method 
     597                throw new ApplicationException("Nie ma co fakturowaæ - Poznañ | Katowice"); 
    596598            } 
    597599 
  • branches/ReklamaReorganizacja/BazaReklam/FormBadVer.cs

    r601 r613  
    1212    public partial class FormBadVer : Form 
    1313    { 
    14         readonly string _updaterUrl = ConfigurationHelper.GetSettingByKey("Application.Update.Exe") ?? "http://www.infocity.pl/baza_reklam/update/updater.exe"; 
     14        readonly string _updaterUrl = ConfigurationHelper.GetSettingByKey("Application.Update.Exe") ?? "http://www.infocity.pl/baza_reklam/update/BazaReklam.Updater.exe"; 
    1515        readonly string _zipUrl = ConfigurationHelper.GetSettingByKey("Application.Update.Zip") ?? "http://www.infocity.pl/baza_reklam/update/BazaReklam.zip"; 
    1616 
     
    2828        { 
    2929            button1.Enabled = false; 
    30             Cursor = Cursors.WaitCursor; 
    31             button1.Cursor = Cursors.WaitCursor; 
    32             webClient.DownloadFileAsync(new Uri(_updaterUrl), Environment.CurrentDirectory + "\\Updater.exe"); 
    33             return; 
     30             
     31            string updater = Environment.CurrentDirectory + "\\BazaReklam.Updater.exe"; 
    3432 
    35             //TODO: Uncomment after every user will get updated version of the Updater 
    36             //string updater = Environment.CurrentDirectory + "\\Updater.exe"; 
    37  
    38             //if (System.IO.File.Exists(updater)) 
    39             //    StartUpdater(); 
    40             //else 
    41             //    webClient.DownloadFileAsync(new Uri(_updaterUrl), Environment.CurrentDirectory + "\\Updater.exe"); 
     33            if (System.IO.File.Exists(updater)) 
     34                StartUpdater(); 
     35            else 
     36                webClient.DownloadFileAsync(new Uri(_updaterUrl), Environment.CurrentDirectory + "\\BazaReklam.Updater.exe"); 
    4237        } 
    4338 
     
    5853        private void StartUpdater() 
    5954        { 
    60             string updater = Environment.CurrentDirectory + "\\Updater.exe"; 
     55            string updater = Environment.CurrentDirectory + "\\BazaReklam.Updater.exe"; 
    6156            Cursor = Cursors.Default; 
    6257            button1.Cursor = Cursors.Default; 
  • branches/ReklamaReorganizacja/BazaReklam/InfoForm.cs

    r593 r613  
    55using System.Windows.Forms; 
    66using System.Globalization; 
     7using Baza_Reklam.Classes.Helpers; 
    78using Baza_Reklam.Classes.Interfaces; 
    89 
  • branches/ReklamaReorganizacja/BazaReklam/KorektyForm.cs

    r593 r613  
    77using System.Text; 
    88using System.Windows.Forms; 
     9using Baza_Reklam.Classes.Helpers; 
    910using Baza_Reklam.Classes.Interfaces; 
    1011 
  • branches/ReklamaReorganizacja/BazaReklam/ListaReklamNaWydanieForm.cs

    r593 r613  
    55using System.Drawing; 
    66using System.Windows.Forms; 
     7using Baza_Reklam.Classes; 
    78using Baza_Reklam.Classes.Helpers; 
    89using Baza_Reklam.Classes.Interfaces; 
     
    350351                    MessageBox.Show(pdfHelper.ErrorMessage); 
    351352            } 
     353            catch (System.Net.WebException exception) 
     354            { 
     355                PdfHelper.HandleWebException(exception); 
     356            } 
    352357            finally 
    353358            { 
  • branches/ReklamaReorganizacja/BazaReklam/OferForm.cs

    r593 r613  
    77using System.Windows.Forms; 
    88using System.IO; 
     9using Baza_Reklam.Classes.Helpers; 
    910 
    1011 
     
    139140        private static void OpenOfer(string filename) 
    140141        { 
    141             WordHandler wh = new WordHandler(); 
    142  
    143             wh.openFile(filename); 
    144             wh.setWordVisible(); 
     142            WordHelper wh = new WordHelper(); 
     143 
     144            wh.OpenFile(filename); 
     145            wh.SetWordVisible(); 
    145146        } 
    146147 
    147148        private void CreateNewOfer(string filename, string newFileName) 
    148149        { 
    149             WordHandler wh = new WordHandler(); 
    150  
    151             wh.openFile(filename); 
    152  
    153             wh.findAndReplace("<<Oferta_Numer>>", id_ofertyTextBox.Text + "/" + User.Instance().Kod_agenta.ToUpper() + "/" + DateTime.Today.Year); 
    154             wh.findAndReplace("<<Osoba_Do_Kontaktu>>", id_klienci_os_kontaktComboBox.Text); 
    155             wh.findAndReplace("<<Nazwa_i_Adres_Klienta>>", adres_KorTextBox.Text); 
    156             wh.findAndReplace("<<Miasto>>", User.Instance().Miasto); 
    157             wh.findAndReplace("<<Data_Oferty>>", data_OfertyDateTimePicker.Value.ToShortDateString()); 
    158             wh.findAndReplace("<<Podpis_Agenta>>", User.Instance().Imie + " " + User.Instance().Nazwisko); 
    159             wh.findAndReplace("<<Email_Agenta>>", User.Instance().Email); 
    160             wh.findAndReplace("<<tel_wew_Agenta>>", User.Instance().TelWewnetrzny); 
    161             wh.findAndReplace("<<tel_mobile_Agenta>>", User.Instance().KomSluzbowa); 
    162             wh.findAndReplace("<<Adres_Biura>>", User.Instance().AdresBiura); 
    163             wh.findAndReplace("<<Tel_Biura>>", User.Instance().TelSekretariat); 
    164             wh.findAndReplace("<<Fax_Biura>>", User.Instance().FaxSekretariat); 
    165             wh.findAndReplace("<<Oferta_Opis_Dod>>", opis_DolTextBox.Text); 
    166             wh.findAndReplace("<<Stanowisko_Agenta>>", User.Instance().Stanowisko); 
    167  
    168             wh.saveAs(newFileName); 
    169  
    170             wh.setWordVisible(); 
     150            WordHelper wh = new WordHelper(); 
     151 
     152            wh.OpenFile(filename); 
     153 
     154            wh.FindAndReplace("<<Oferta_Numer>>", id_ofertyTextBox.Text + "/" + User.Instance().Kod_agenta.ToUpper() + "/" + DateTime.Today.Year); 
     155            wh.FindAndReplace("<<Osoba_Do_Kontaktu>>", id_klienci_os_kontaktComboBox.Text); 
     156            wh.FindAndReplace("<<Nazwa_i_Adres_Klienta>>", adres_KorTextBox.Text); 
     157            wh.FindAndReplace("<<Miasto>>", User.Instance().Miasto); 
     158            wh.FindAndReplace("<<Data_Oferty>>", data_OfertyDateTimePicker.Value.ToShortDateString()); 
     159            wh.FindAndReplace("<<Podpis_Agenta>>", User.Instance().Imie + " " + User.Instance().Nazwisko); 
     160            wh.FindAndReplace("<<Email_Agenta>>", User.Instance().Email); 
     161            wh.FindAndReplace("<<tel_wew_Agenta>>", User.Instance().TelWewnetrzny); 
     162            wh.FindAndReplace("<<tel_mobile_Agenta>>", User.Instance().KomSluzbowa); 
     163            wh.FindAndReplace("<<Adres_Biura>>", User.Instance().AdresBiura); 
     164            wh.FindAndReplace("<<Tel_Biura>>", User.Instance().TelSekretariat); 
     165            wh.FindAndReplace("<<Fax_Biura>>", User.Instance().FaxSekretariat); 
     166            wh.FindAndReplace("<<Oferta_Opis_Dod>>", opis_DolTextBox.Text); 
     167            wh.FindAndReplace("<<Stanowisko_Agenta>>", User.Instance().Stanowisko); 
     168 
     169            wh.SaveAs(newFileName); 
     170 
     171            wh.SetWordVisible(); 
    171172        } 
    172173 
  • branches/ReklamaReorganizacja/BazaReklam/OrderDetails.cs

    r593 r613  
    77using System.Windows.Forms; 
    88using System.Text.RegularExpressions; 
    9 using Baza_Reklam.Classes; 
     9using Baza_Reklam.Classes.Helpers; 
    1010using Baza_Reklam.Classes.Helpers; 
    1111 
  • branches/ReklamaReorganizacja/BazaReklam/OrdersForm.cs

    r593 r613  
    44using System.Data.SqlClient; 
    55using System.Windows.Forms; 
     6using Baza_Reklam.Classes; 
    67using Baza_Reklam.Classes.Helpers; 
    78using Baza_Reklam.Classes.Interfaces; 
     
    12041205                if (!pdfHelper.DisplayPdf()) 
    12051206                    MessageBox.Show(pdfHelper.ErrorMessage); 
     1207            } 
     1208            catch (System.Net.WebException exception) 
     1209            { 
     1210                PdfHelper.HandleWebException(exception); 
    12061211            } 
    12071212            finally 
  • branches/ReklamaReorganizacja/BazaReklam/ProductionForm.cs

    r601 r613  
    907907                    MessageBox.Show(pdfHelper.ErrorMessage); 
    908908            } 
     909            catch (System.Net.WebException exception) 
     910            { 
     911                PdfHelper.HandleWebException(exception); 
     912            } 
    909913            finally 
    910914            { 
  • branches/ReklamaReorganizacja/BazaReklam/Properties/AssemblyInfo.cs

    r601 r613  
    3030// 
    3131[assembly: AssemblyVersion("1.0.0.0")] 
    32 [assembly: AssemblyFileVersion("1.1.4")] 
     32[assembly: AssemblyFileVersion("1.1.6")] 
  • branches/ReklamaReorganizacja/BazaReklam/ZamowieniaForm.cs

    r593 r613  
    66using System.Windows.Forms; 
    77using Baza_Reklam.Classes.Helpers; 
     8using Baza_Reklam.Classes.Interfaces; 
    89 
    910namespace Baza_Reklam 
     
    294295            if (zamowieniaBindingSource.Current == null) return; 
    295296 
    296             if (rEKLAMADataSet.REKLAMA.Rows.Count <= 0) 
    297             { 
    298                 MessageBox.Show("Proszê dodaæ przynajmniej jedn¹ reklamê do zamówienia.", "Faktura"); 
    299                 return; 
    300             } 
    301              
    302             Cursor = Cursors.WaitCursor; 
    303  
    304             DataRowView z = (DataRowView) zamowieniaBindingSource.Current; 
    305             REKLAMADataSet.zamowieniaRow zamowienie = (REKLAMADataSet.zamowieniaRow) z.Row; 
    306  
    307             REKLAMADataSet.KLIENCIRow _klient = 
    308                 (REKLAMADataSet.KLIENCIRow) klienciTableAdapter.GetDataByCustomerId(zamowienie.idKlienta).Rows[0]; 
    309             string errorMessage = czyMoznaZafakturowac(zamowienie, _klient); 
    310  
    311             if (errorMessage != string.Empty) 
    312             { 
    313                 MessageBox.Show(errorMessage); 
     297            try 
     298            { 
     299                Cursor = Cursors.WaitCursor; 
     300 
     301                DataRowView z = (DataRowView) zamowieniaBindingSource.Current; 
     302                REKLAMADataSet.zamowieniaRow zamowienie = (REKLAMADataSet.zamowieniaRow) z.Row; 
     303 
     304                REKLAMADataSet.KLIENCIRow klientRow = 
     305                    (REKLAMADataSet.KLIENCIRow) klienciTableAdapter.GetDataByCustomerId(zamowienie.idKlienta).Rows[0]; 
     306 
     307                InitIssueTables(zamowienie); 
     308 
     309                string errorMessage = CzyMoznaZafakturowac(zamowienie, klientRow); 
     310 
     311                if (errorMessage != string.Empty) 
     312                { 
     313                    MessageBox.Show(errorMessage, "Fakturowanie"); 
     314                    Cursor = Cursors.Default; 
     315                    return; 
     316                } 
     317 
     318                WystawFakture(zamowienie, klientRow, false); 
     319 
     320                RestoreConnections(); 
     321 
     322                zamowieniaBindingSource.ResetBindings(false); 
     323 
     324                fAKTURYBindingSource.MoveLast(); 
     325            } 
     326            finally 
     327            { 
    314328                Cursor = Cursors.Default; 
    315                 return; 
    316             } 
    317  
    318             WystawFakture(zamowienie, _klient, false); 
    319  
    320             RestoreConnections(); 
    321  
    322             zamowieniaBindingSource.ResetBindings(false); 
    323  
    324             fAKTURYBindingSource.MoveLast(); 
    325  
    326             Cursor = Cursors.Default; 
     329            } 
    327330        } 
    328331 
     
    523526        } 
    524527 
    525         private void PobierzOznaczEmisje(REKLAMADataSet.zamowieniaRow zamowienie, REKLAMADataSet.FAKTURYRow naglowekFaktury) 
     528 
     529        private void InitIssueTables(REKLAMADataSet.zamowieniaRow zamowienie) 
    526530        { 
    527531            emisjeTableAdapter.ClearBeforeFill = false; 
    528532            datyWydanTableAdapter.ClearBeforeFill = false; 
     533            rEKLAMADataSet.UKAZE_SIE_W_NR.Clear(); 
     534            rEKLAMADataSet.DatyWydan.Clear(); 
    529535 
    530536            REKLAMADataSet.DatyWydanDataTable t = datyWydanTableAdapter.GetDataByPierwszaEmisjaWZamowieniu(zamowienie.idZamowienia); 
    531  
    532             if (t.Rows.Count == 0) 
    533             { 
    534                 //TODO: moze lepiej uzyc MessageBox'a i return niz wywalac wyjatek...? 
    535                 // wyjatki sa dosc kosztowne dla aplikacji 
    536                 throw new Exception("Nie ma co fakturowaæ!"); 
    537             } 
     537            if (t.Rows.Count <= 0) return; 
    538538 
    539539            DateTime d = t[0].DATA_W; 
     
    575575                reklama.EndEdit(); 
    576576            } 
    577  
    578             if (rEKLAMADataSet.UKAZE_SIE_W_NR.Rows.Count <= 0) 
    579                 throw new ApplicationException("Nie znaleziono ¿adnych emisji do zafakturowania! (" + 
    580                                                zamowienie.idZamowienia + ": " + StringHelper.ListToString(adIds, ",") + ")"); 
    581  
     577        } 
     578 
     579 
     580        private void PobierzOznaczEmisje(REKLAMADataSet.zamowieniaRow zamowienie, REKLAMADataSet.FAKTURYRow naglowekFaktury) 
     581        { 
     582            //InitIssueTables(zamowienie); 
    582583 
    583584            if (zamowienie.IsdataOstatniejZafakturowanejEmisjiNull()) 
     
    635636        { 
    636637            SLOWNIKDataSet.AGENCIRow agent = (SLOWNIKDataSet.AGENCIRow)agenciTableAdapter.GetDataByKodAgenta(zamowienie.kodAgenta).Rows[0]; 
    637             InvoiceProvider invoiceProvider = InvoiceProviderFactory.GetInvoiceProviderById(agent.InvoiceProviderId); 
     638            IInvoiceProvider invoiceProvider = InvoiceProviderFactory.GetInvoiceProviderById(agent.InvoiceProviderId); 
    638639 
    639640 
     
    709710                if (kurs.Count == 0) 
    710711                { 
    711                     throw new Exception("B³¹d przy pobieraniu kursu waluty."); 
     712                    throw new ApplicationException("B³¹d przy pobieraniu kursu waluty."); 
    712713                } 
    713714 
     
    730731         
    731732 
    732         private string czyMoznaZafakturowac(REKLAMADataSet.zamowieniaRow zamowienie, REKLAMADataSet.KLIENCIRow klientRow) 
     733        private string CzyMoznaZafakturowac(REKLAMADataSet.zamowieniaRow zamowienie, REKLAMADataSet.KLIENCIRow klientRow) 
    733734        { 
    734735            string errorMessage = string.Empty; 
     
    738739            errorMessage += zamowienie.IsidKontaNull() ? "Nie wybrano konta. \n" : ""; 
    739740            errorMessage += zamowienie.IssposobZaplatyNull() ? "Nie wybrano sposobu zap³aty. \n" : ""; 
    740             errorMessage += klientRow.IsCountryNull() || klientRow.Country == string.Empty ? "Brak pañstwa klienta. \n" : ""; 
    741             errorMessage += klientRow.IsAdres_FkaturaNull() || klientRow.Adres_Fkatura == string.Empty ? "Brak adresu faktury klienta. \n" : ""; 
    742             errorMessage += klientRow.IsNipNull() || klientRow.Nip == string.Empty ? "Brak nipu klienta. \n" : ""; 
     741            errorMessage += string.IsNullOrEmpty(klientRow.Country) ? "Brak pañstwa klienta. \n" : ""; 
     742            errorMessage += string.IsNullOrEmpty(klientRow.Adres_Fkatura) ? "Brak adresu faktury klienta. \n" : ""; 
     743            errorMessage +=  string.IsNullOrEmpty(klientRow.Nip) ? "Brak nipu klienta. \n" : ""; 
    743744 
    744745            if (klientRow.Country != "Polska") 
    745             { 
    746                 errorMessage += klientRow.IsnipKrajNull() || klientRow.nipKraj == string.Empty ? "Brak symbolu kraju w nipie klienta. \n" : ""; 
     746                errorMessage += string.IsNullOrEmpty(klientRow.nipKraj) ? "Brak symbolu kraju w nipie klienta. \n" : ""; 
     747 
     748            if (rEKLAMADataSet.REKLAMA.Rows.Count <= 0) 
     749            { 
     750                // try to load the ads once again in case something went wrong before... 
     751                rEKLAMATableAdapter.FillByIdZamowienia(rEKLAMADataSet.REKLAMA, zamowienie.idZamowienia); 
     752 
     753                if (rEKLAMADataSet.REKLAMA.Rows.Count <= 0) 
     754                    errorMessage += "Proszê dodaæ przynajmniej jedn¹ reklamê do zamówienia \n"; 
    747755            } 
    748756 
    749757            if (rEKLAMADataSet.REKLAMA.Select("[ZATWIERDZONO DO DRUKU] = 0").Length > 0) 
    750             { 
    751758                errorMessage += "W zamówieniu s¹ reklamy niezatwierdzone do druku \n"; 
    752             } 
     759 
     760            if (errorMessage.Length > 0) 
     761                return errorMessage; 
     762 
     763            if (rEKLAMADataSet.UKAZE_SIE_W_NR.Rows.Count <= 0) 
     764            { 
     765                errorMessage += "Nie znaleziono ¿adnych emisji do zafakturowania \n"; 
     766                return errorMessage; 
     767            } 
     768 
     769            REKLAMADataSet.DatyWydanDataTable t = datyWydanTableAdapter.GetDataByPierwszaEmisjaWZamowieniu(zamowienie.idZamowienia); 
     770            if (t.Rows.Count == 0) 
     771                errorMessage += "Nie znaleziono ¿adnych emisji do zafakturowania \n"; 
    753772 
    754773            return errorMessage; 
     
    893912        private REKLAMADataSet.FAKTURYRow utworzNaglowekKorekty(REKLAMADataSet.FAKTURYRow faktura) 
    894913        { 
    895             SLOWNIKDataSet.AGENCIRow agent = (SLOWNIKDataSet.AGENCIRow)agenciTableAdapter.GetDataByKodAgenta(faktura.NUMER_ROZ).Rows[0]; 
    896             InvoiceProvider invoiceProvider = InvoiceProviderFactory.GetInvoiceProviderById(agent.InvoiceProviderId); 
    897  
    898  
    899914            REKLAMADataSet.FAKTURYRow naglowekKorekty = rEKLAMADataSet.FAKTURY.NewFAKTURYRow(); 
    900915            naglowekKorekty.KOREKTA = true; 
     
    906921 
    907922            naglowekKorekty.NUMER_ROZ = faktura.NUMER_ROZ; 
    908             naglowekKorekty.NUMER = DbUtils.numerNowejFakturyKorekty(DateTime.Today.Year); 
     923            naglowekKorekty.NUMER = FakturaHelper.GetNewCorrectionInvoiceNumber(DateTime.Today.Year, faktura.SystemKsiegowyId); 
    909924            naglowekKorekty.NUMER_ROK = DateTime.Today.Year; 
    910925            naglowekKorekty.DATA_WYSTAWIENIA = DateTime.Today; 
     
    919934 
    920935            naglowekKorekty.MIEJSCOWOSC_WYSTAWIENIA = faktura.MIEJSCOWOSC_WYSTAWIENIA; 
    921             naglowekKorekty.SPRZEDAWCA_ADRES = invoiceProvider.GetAddress(); 
    922             naglowekKorekty.SPRZEDAWCA_NIP = invoiceProvider.TaxNumber; 
     936            naglowekKorekty.SPRZEDAWCA_ADRES = faktura.SPRZEDAWCA_ADRES; 
     937            naglowekKorekty.SPRZEDAWCA_NIP = faktura.SPRZEDAWCA_NIP; 
    923938            naglowekKorekty.SystemKsiegowyId = faktura.SystemKsiegowyId; 
    924939 
     
    944959            if (!faktura.Iswaluta_mianoNull()) 
    945960            { 
    946                 naglowekKorekty.SPRZEDAWCA_NIP = invoiceProvider.TaxCountryPrefix + " " + invoiceProvider.TaxNumber; 
     961                naglowekKorekty.SPRZEDAWCA_NIP = faktura.SPRZEDAWCA_NIP; 
    947962                naglowekKorekty.NABYWCA_NIP = faktura.NABYWCA_NIP; 
    948963                naglowekKorekty.waluta_miano = faktura.waluta_miano; 
     
    13631378            if (zamowieniaBindingSource.Current == null) return; 
    13641379 
    1365             if (rEKLAMADataSet.REKLAMA.Rows.Count <= 0) 
    1366             { 
    1367                 MessageBox.Show("Proszê dodaæ przynajmniej jedn¹ reklamê do zamówienia.", "Faktura proforma"); 
    1368                 return; 
    1369             } 
    1370  
    13711380            Cursor = Cursors.WaitCursor; 
    13721381 
     
    13761385            REKLAMADataSet.KLIENCIRow _klient = 
    13771386                (REKLAMADataSet.KLIENCIRow) klienciTableAdapter.GetDataByCustomerId(zamowienie.idKlienta).Rows[0]; 
    1378             string errorMessage = czyMoznaZafakturowac(zamowienie, _klient); 
     1387 
     1388            InitIssueTables(zamowienie); 
     1389 
     1390            string errorMessage = CzyMoznaZafakturowac(zamowienie, _klient); 
    13791391 
    13801392            if (errorMessage != string.Empty) 
    13811393            { 
    1382                 MessageBox.Show(errorMessage); 
     1394                MessageBox.Show(errorMessage, "Fakturowanie - Proforma"); 
    13831395                Cursor = Cursors.Default; 
    13841396                return; 
     
    13951407            { 
    13961408                DataRow[] rows = rEKLAMADataSet.FAKTURY.Select("id_faktury=" + id); 
    1397                 usunFakture((REKLAMADataSet.FAKTURYRow) rows[0]); 
     1409                if (rows.Length > 0) 
     1410                    usunFakture((REKLAMADataSet.FAKTURYRow) rows[0]); 
     1411                 
    13981412                RestoreConnections(); 
    13991413                Cursor = Cursors.Default; 
  • branches/ReklamaReorganizacja/BazaReklam/ZestawienieZamowienForm.cs

    r593 r613  
    55using System.Drawing; 
    66using System.Windows.Forms; 
     7using Baza_Reklam.Classes.Helpers; 
    78using Baza_Reklam.Classes.Interfaces; 
    89 
  • branches/ReklamaReorganizacja/BazaReklam/app.config

    r601 r613  
    3636    <add key="Application.Pdf.Date" value="http://truck.pl/ogloszenia/_getFile.asp?pdfdate,{0},," /> 
    3737 
    38     <add key="Application.Update.Exe" value="http://www.infocity.pl/baza_reklam/update/updater.exe" /> 
     38    <add key="Application.Update.Exe" value="http://www.infocity.pl/baza_reklam/update/BazaReklam.Updater.exe" /> 
    3939    <add key="Application.Update.Zip" value="http://www.infocity.pl/baza_reklam/update/BazaReklam.zip" /> 
    4040  </appSettings> 
  • branches/ReklamaReorganizacja/BazaReklamSetup/BazaReklamSetup.vdproj

    r601 r613  
    725725        "Name" = "8:Microsoft Visual Studio" 
    726726        "ProductName" = "8:Baza Reklam" 
    727         "ProductCode" = "8:{F6601D04-8574-4347-9F7A-5B57FD3E63AD}" 
    728         "PackageCode" = "8:{232E4671-6E2D-40C9-B63E-EFEC643B3CAE}" 
     727        "ProductCode" = "8:{E94CA729-B311-4DE5-BF21-DF116210CC02}" 
     728        "PackageCode" = "8:{724D56E2-C502-4EF3-9B3E-C5044DE7D117}" 
    729729        "UpgradeCode" = "8:{4E2DBBA4-3139-4790-8DDB-7AADFC963A7D}" 
    730730        "RestartWWWService" = "11:FALSE" 
     
    732732        "DetectNewerInstalledVersion" = "11:TRUE" 
    733733        "InstallAllUsers" = "11:TRUE" 
    734         "ProductVersion" = "8:1.1.4" 
     734        "ProductVersion" = "8:1.1.6" 
    735735        "Manufacturer" = "8:AACT" 
    736736        "ARPHELPTELEPHONE" = "8:" 
     
    12741274            "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_65508AB999A44FC7909AAE84E5BD5F45" 
    12751275            { 
    1276             "SourcePath" = "8:..\\Updater\\obj\\Debug\\Updater.exe" 
     1276            "SourcePath" = "8:..\\BazaReklam.Updater\\obj\\Debug\\BazaReklam.Updater.exe" 
    12771277            "TargetName" = "8:" 
    12781278            "Tag" = "8:"