Zbiór zmian 702 dla branches

Pokaż
Ignoruj:
Data:
2009-06-10 18:00:05 (17 years ago)
Autor:
marek
Opis:

re #184 - proba Repository Pattern dla SQL

Lokalizacja:
branches/Abonament/BazaReklam
Pliki:
5 dodane
5 zmodyfikowane

Legenda:

Bez zmian
Dodane
Usunięte
  • branches/Abonament/BazaReklam/AddClient.cs

    r660 r702  
    1313    public partial class AddClient : Form 
    1414    { 
     15        private readonly string _connectionString = ConnString.getConnString().Value; 
     16 
    1517        private readonly int _clientId; 
    1618        private REKLAMADataSet.KLIENCIRow _client; 
     
    6163            cbState.ValueMember = "Name"; 
    6264 
    63             BindComboBox(new AgentRepository().FindAllActive(), cbUserName); 
     65            BindComboBox(new AgentRepository(_connectionString).FindAllActive(), cbUserName); 
    6466            cbUserName.DisplayMember = "LoginName"; 
    6567            cbUserName.ValueMember = "LoginName"; 
    6668 
    67             BindComboBox(new AgentRepository().FindAllActive(), cbAgentExpo); 
     69            BindComboBox(new AgentRepository(_connectionString).FindAllActive(), cbAgentExpo); 
    6870            cbAgentExpo.DisplayMember = "LoginName"; 
    6971            cbAgentExpo.ValueMember = "LoginName"; 
  • branches/Abonament/BazaReklam/Baza Reklam.csproj

    r678 r702  
    143143    <Compile Include="Classes\Model\Agent.cs" /> 
    144144    <Compile Include="Classes\Model\Country.cs" /> 
     145    <Compile Include="Classes\Model\Customer.cs" /> 
    145146    <Compile Include="Classes\Model\Invoice.cs" /> 
    146147    <Compile Include="Classes\InvoiceProvider.cs" /> 
     
    156157    <Compile Include="Classes\Repositories\AgentRepository.cs" /> 
    157158    <Compile Include="Classes\Repositories\CountryRepository.cs" /> 
     159    <Compile Include="Classes\Repositories\CustomerRepository.cs" /> 
    158160    <Compile Include="Classes\Repositories\IRepository.cs" /> 
    159161    <Compile Include="Classes\Repositories\Repository.cs" /> 
     
    204206      <DependentUpon>FacturesFormNew.cs</DependentUpon> 
    205207    </Compile> 
     208    <Compile Include="Subscription.cs"> 
     209      <SubType>Form</SubType> 
     210    </Compile> 
     211    <Compile Include="Subscription.Designer.cs"> 
     212      <DependentUpon>Subscription.cs</DependentUpon> 
     213    </Compile> 
    206214    <Compile Include="ZestawienieZamowienForm.cs"> 
    207215      <SubType>Form</SubType> 
     
    601609    <EmbeddedResource Include="Raporty\fakturaKatowicePoznan.rdlc" /> 
    602610    <EmbeddedResource Include="Raporty\fakturaKorekta.rdlc" /> 
     611    <EmbeddedResource Include="Subscription.resx"> 
     612      <SubType>Designer</SubType> 
     613      <DependentUpon>Subscription.cs</DependentUpon> 
     614    </EmbeddedResource> 
    603615    <EmbeddedResource Include="ZestawienieZamowienForm.resx"> 
    604616      <DependentUpon>ZestawienieZamowienForm.cs</DependentUpon> 
  • branches/Abonament/BazaReklam/Classes/Repositories/AgentRepository.cs

    r621 r702  
    77    public class AgentRepository : Repository<Agent> 
    88    { 
     9        public AgentRepository(string connectionString) : base(connectionString) 
     10        { 
     11        } 
     12         
    913        public List<Agent> FindAllActive() 
    1014        { 
  • branches/Abonament/BazaReklam/Classes/Repositories/Repository.cs

    r614 r702  
    11using System; 
    22using System.Collections.Generic; 
     3using System.Data.SqlClient; 
    34 
    45namespace Baza_Reklam.Classes.Repositories 
     
    67    public class Repository<T> : IRepository<T> 
    78    { 
     9        protected SqlConnection _connection; 
     10        protected SqlCommand _command; 
     11        protected SqlDataReader _reader; 
     12        protected SqlTransaction _transaction; 
     13 
     14        public Repository(string connectionString) 
     15        { 
     16            _connection = new SqlConnection(connectionString); 
     17        } 
     18 
    819        public virtual T Find(int id) 
    920        { 
     
    1122        } 
    1223 
    13         public List<T> FindAll() 
     24        public virtual List<T> FindAll() 
    1425        { 
    1526            throw new NotImplementedException(); 
    1627        } 
    1728 
    18         public void Save() 
     29        public virtual void Save() 
    1930        { 
    2031            throw new NotImplementedException(); 
    2132        } 
    2233 
    23         public void Delete() 
     34        public virtual void Delete() 
    2435        { 
    2536            throw new NotImplementedException(); 
    2637        } 
    2738    } 
     39 
     40    public class SqlRepository<T> : Repository<T> 
     41    { 
     42        public SqlRepository(string connectionString) : base(connectionString) 
     43        { 
     44        } 
     45    } 
    2846} 
  • branches/Abonament/BazaReklam/Facturer.cs

    r676 r702  
    1414        private int reklamaId; 
    1515        private int customerId; 
     16        private readonly string _connectionString = ConnString.getConnString().Value; 
    1617 
    1718        public Facturer(int rekId) 
     
    7071                else 
    7172                { 
    72                     Agent agent = new AgentRepository().FindByShortName(row["SYMBOL AKWIZYTORA"].ToString()); 
     73                    Agent agent = new AgentRepository(_connectionString).FindByShortName(row["SYMBOL AKWIZYTORA"].ToString()); 
    7374 
    7475                    IInvoiceProvider invoiceProvider = InvoiceProviderFactory.GetInvoiceProviderById(agent.InvoiceProvider); 
     
    410411                //ustawienie pól formularza na dodanie nowej faktury 
    411412                 
    412                 Agent agent = new AgentRepository().FindByShortName(row["SYMBOL AKWIZYTORA"].ToString()); 
     413                Agent agent = new AgentRepository(_connectionString).FindByShortName(row["SYMBOL AKWIZYTORA"].ToString()); 
    413414                IInvoiceProvider invoiceProvider = InvoiceProviderFactory.GetInvoiceProviderById(agent.InvoiceProvider); 
    414415