Zbiór zmian 705 dla branches

Pokaż
Ignoruj:
Data:
2009-06-16 17:51:04 (17 years ago)
Autor:
marek
Opis:

re #184 - abonamenty - mozna fakturowac - z bledami ale mozna...

Lokalizacja:
branches/Abonament/BazaReklam
Pliki:
4 dodane
12 zmodyfikowane

Legenda:

Bez zmian
Dodane
Usunięte
  • branches/Abonament/BazaReklam/Baza Reklam.csproj

    r704 r705  
    142142    <Compile Include="Classes\Interfaces\IForm.cs" /> 
    143143    <Compile Include="Classes\Interfaces\IProduct.cs" /> 
     144    <Compile Include="Classes\Interfaces\IProductDetail.cs" /> 
     145    <Compile Include="Classes\Model\Enums\InvoicingType.cs" /> 
    144146    <Compile Include="Classes\Model\Enums\ProductType.cs" /> 
    145147    <Compile Include="Classes\Model\Product.cs" /> 
     
    153155    <Compile Include="Classes\Global.cs" /> 
    154156    <Compile Include="Classes\Logger.cs" /> 
     157    <Compile Include="Classes\Model\ProductDetail.cs" /> 
    155158    <Compile Include="Classes\Model\State.cs" /> 
    156159    <Compile Include="Classes\Model\Subscription.cs" /> 
     
    165168    <Compile Include="Classes\Repositories\CustomerRepository.cs" /> 
    166169    <Compile Include="Classes\Repositories\IRepository.cs" /> 
     170    <Compile Include="Classes\Repositories\ProductRepository.cs" /> 
    167171    <Compile Include="Classes\Repositories\Repository.cs" /> 
    168172    <Compile Include="Classes\Repositories\StateRepository.cs" /> 
  • branches/Abonament/BazaReklam/Classes/Interfaces/IProduct.cs

    r704 r705  
    11using System; 
     2using System.Collections.Generic; 
    23using Baza_Reklam.Classes.Model.Enums; 
    34 
     
    1011        string Type { get; set; } 
    1112        string ShortName { get; set; } 
    12         DateTime StartDate { get; set; } 
     13        DateTime? StartDate { get; set; } 
    1314        decimal Price { get; set; } 
    1415        decimal TotalPrice { get; set; } 
     
    1819        int? OrderId { get; set; } 
    1920        bool HasInvoice { get; set; } 
     21        List<IProductDetail> ProductDetails { get; } 
     22        void AddProductDetail(IProductDetail productDetail); 
    2023    } 
    2124} 
  • branches/Abonament/BazaReklam/Classes/Model/Agent.cs

    r621 r705  
    66        private string _loginName; 
    77        private string _shortName; 
     8        private string _firstName; 
     9        private string _lastName; 
    810 
    911        public Agent(string loginName) 
     
    3638            set { _invoiceProvider = value; } 
    3739        } 
     40 
     41        public string FirstName 
     42        { 
     43            get { return _firstName; } 
     44            set { _firstName = value; } 
     45        } 
     46 
     47        public string LastName 
     48        { 
     49            get { return _lastName; } 
     50            set { _lastName = value; } 
     51        } 
     52 
     53        public override string ToString() 
     54        { 
     55            return _firstName + " " + _lastName; 
     56        } 
    3857    } 
    3958} 
  • branches/Abonament/BazaReklam/Classes/Model/Enums/ProductType.cs

    r704 r705  
    33    public enum ProductType 
    44    { 
    5         Advertisment = 1, 
    6         Subscription = 2 
     5        Subscription = 1, 
     6        Advertisment = 2, 
    77    } 
    88} 
  • branches/Abonament/BazaReklam/Classes/Model/Product.cs

    r704 r705  
    11using System; 
     2using System.Collections.Generic; 
    23using Baza_Reklam.Classes.Interfaces; 
    34using Baza_Reklam.Classes.Model.Enums; 
     
    1112        private string _type; 
    1213        private string _shortName; 
    13         private DateTime _startDate; 
     14        private DateTime? _startDate; 
    1415        private decimal _price; 
    1516        private decimal _totalPrice; 
     
    1920        private int? _orderId; 
    2021        private bool _hasInvoice; 
     22        private List<IProductDetail> _productDetails = new List<IProductDetail>(); 
    2123 
    2224        public int Id 
     
    4446        } 
    4547 
    46         public DateTime StartDate 
     48        public DateTime? StartDate 
    4749        { 
    4850            get { return _startDate; } 
     
    9193            set { _hasInvoice = value; } 
    9294        } 
     95 
     96        public List<IProductDetail> ProductDetails 
     97        { 
     98            get { return _productDetails; } 
     99        } 
     100 
     101        public void AddProductDetail(IProductDetail productDetail) 
     102        { 
     103            productDetail.ProductId = _id; 
     104            _productDetails.Add(productDetail); 
     105        } 
    93106    } 
    94107} 
  • branches/Abonament/BazaReklam/Classes/Repositories/AgentRepository.cs

    r702 r705  
    5454        public Agent FindByShortName(string shortName) 
    5555        { 
    56             const string query = "SELECT Symbol, F_ROZ, InvoiceProviderId FROM dbo.Agenci WHERE F_ROZ=@shortName"; 
     56            const string query = "SELECT Symbol, F_ROZ, InvoiceProviderId, [Imiê], Nazwisko FROM dbo.Agenci WHERE F_ROZ=@shortName"; 
    5757            SqlConnection conn = null; 
    5858            SqlCommand cmd = null; 
     
    6464                conn.Open(); 
    6565                cmd = new SqlCommand(query, conn); 
     66                cmd.Parameters.AddWithValue("@shortName", shortName); 
    6667                reader = cmd.ExecuteReader(); 
    6768                if (reader != null && reader.Read()) 
    68                     return new Agent(reader.GetString(0).Trim().ToLower(), 
    69                                      reader.GetString(1).Trim().ToUpper(), 
    70                                      reader.GetInt32(2)); 
     69                { 
     70                    Agent agent = new Agent(reader.GetString(0).Trim().ToLower()); 
     71                    agent.ShortName = reader.GetString(1).Trim().ToUpper(); 
     72                    agent.InvoiceProvider = reader.GetInt32(2); 
     73                    agent.FirstName = reader.GetString(3); 
     74                    agent.LastName = reader.GetString(4); 
     75                    return agent; 
     76                } 
    7177            } 
    7278            finally 
  • branches/Abonament/BazaReklam/Classes/Repositories/CustomerRepository.cs

    r704 r705  
    33using System.Data; 
    44using System.Data.SqlClient; 
     5using System.Diagnostics; 
    56using Baza_Reklam.Classes.Interfaces; 
    67using Baza_Reklam.Classes.Model; 
     
    180181                        product.ProductType = (ProductType)_reader.GetInt32(2); 
    181182                        product.ShortName = _reader.GetString(3); 
    182                         product.StartDate = _reader.GetDateTime(4); 
     183                        if (_reader[4] != DBNull.Value) 
     184                            product.StartDate = _reader.GetDateTime(4); 
     185                        else 
     186                            Debug.WriteLine(product.ShortName); 
    183187                        product.Price = _reader.GetDecimal(5); 
    184188                        product.TotalPrice = _reader.GetDecimal(6); 
  • branches/Abonament/BazaReklam/ClientsForm.cs

    r703 r705  
    23072307        private void toolStripButton1_Click(object sender, EventArgs e) 
    23082308        { 
    2309             if (kLIENCIBindingSource.Current != null) 
    2310             { 
     2309            if (kLIENCIBindingSource.Current == null) return; 
     2310             
     2311            try 
     2312            { 
     2313                Cursor = Cursors.WaitCursor; 
    23112314                DataRowView row = (DataRowView)kLIENCIBindingSource.Current; 
    23122315                REKLAMADataSet.KLIENCIRow klient = (REKLAMADataSet.KLIENCIRow)row.Row; 
    23132316 
    23142317                ZamowieniaForm zam = new ZamowieniaForm(klient); 
    2315                 zam.ShowDialog(); 
    2316             } 
     2318                zam.ShowDialog();                 
     2319            } 
     2320            finally 
     2321            { 
     2322                Cursor = Cursors.Default; 
     2323            } 
     2324 
    23172325        } 
    23182326 
  • branches/Abonament/BazaReklam/FacturesFormNew.cs

    r676 r705  
    332332        private void zamowieniaToolStripButton_Click(object sender, EventArgs e) 
    333333        { 
    334             if (VIEW_ZESTAWIENIE_FAKTUR_NOWEBindingSource.Current != null) 
    335             { 
     334            if (VIEW_ZESTAWIENIE_FAKTUR_NOWEBindingSource.Current == null) return; 
     335             
     336             
     337            try 
     338            { 
     339                Cursor = Cursors.WaitCursor; 
    336340                DataRowView row = (DataRowView)VIEW_ZESTAWIENIE_FAKTUR_NOWEBindingSource.Current; 
    337341                REKLAMADataSet.VIEW_ZESTAWIENIE_FAKTUR_NOWERow f = (REKLAMADataSet.VIEW_ZESTAWIENIE_FAKTUR_NOWERow)row.Row; 
    338342 
    339343                ZamowieniaForm zf = new ZamowieniaForm(f.ID_NABYWCY, f.idZamowienia); 
    340                 zf.ShowDialog(); 
    341             } 
     344                zf.ShowDialog();                 
     345            } 
     346            finally 
     347            { 
     348                Cursor = Cursors.Default;  
     349            } 
     350 
     351 
    342352        } 
    343353 
  • branches/Abonament/BazaReklam/ZamowieniaForm.Designer.cs

    r704 r705  
    3030        { 
    3131            this.components = new System.ComponentModel.Container(); 
    32             System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); 
    33             System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); 
    34             System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); 
    35             System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); 
    36             System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); 
     32            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle(); 
     33            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle(); 
     34            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle(); 
     35            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle(); 
     36            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle(); 
     37            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle(); 
     38            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle16 = new System.Windows.Forms.DataGridViewCellStyle(); 
     39            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle17 = new System.Windows.Forms.DataGridViewCellStyle(); 
    3740            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ZamowieniaForm)); 
    38             System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle(); 
    39             System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); 
    40             System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); 
    41             System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); 
     41            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle18 = new System.Windows.Forms.DataGridViewCellStyle(); 
    4242            this.zamowieniaDataGridView = new System.Windows.Forms.DataGridView(); 
    4343            this.dataGridViewCheckBoxColumn1 = new System.Windows.Forms.DataGridViewCheckBoxColumn(); 
     
    4949            this.rEKLAMADataSet = new Baza_Reklam.REKLAMADataSet(); 
    5050            this.rEKLAMADataGridView = new System.Windows.Forms.DataGridView(); 
    51             this.rEKLAMABindingSource = new System.Windows.Forms.BindingSource(this.components); 
     51            this.TYP = new System.Windows.Forms.DataGridViewTextBoxColumn(); 
     52            this.ShortName = new System.Windows.Forms.DataGridViewTextBoxColumn(); 
     53            this.VAT = new System.Windows.Forms.DataGridViewTextBoxColumn(); 
     54            this.Brutto_Euro_Miano = new System.Windows.Forms.DataGridViewTextBoxColumn(); 
     55            this.ZATWIERDZONO_DO_DRUKU = new System.Windows.Forms.DataGridViewCheckBoxColumn(); 
    5256            this.rEKLAMADataGridView1 = new System.Windows.Forms.DataGridView(); 
    53             this.rEKLAMABindingSource1 = new System.Windows.Forms.BindingSource(this.components); 
     57            this.Data1Emisji = new System.Windows.Forms.DataGridViewTextBoxColumn(); 
     58            this.ShortName1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); 
     59            this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); 
     60            this.dataGridViewTextBoxColumn43 = new System.Windows.Forms.DataGridViewTextBoxColumn(); 
     61            this.dataGridViewTextBoxColumn44 = new System.Windows.Forms.DataGridViewTextBoxColumn(); 
     62            this.ZATWIERDZONO_DO_DRUKU2 = new System.Windows.Forms.DataGridViewCheckBoxColumn(); 
    5463            this.dodajButton = new System.Windows.Forms.Button(); 
    5564            this.dodajDoZamButton = new System.Windows.Forms.Button(); 
     
    8998            this.toolTip = new System.Windows.Forms.ToolTip(this.components); 
    9099            this.KlientLabel = new System.Windows.Forms.Label(); 
    91             this.TYP = new System.Windows.Forms.DataGridViewTextBoxColumn(); 
    92             this.ShortName = new System.Windows.Forms.DataGridViewTextBoxColumn(); 
    93             this.VAT = new System.Windows.Forms.DataGridViewTextBoxColumn(); 
    94             this.Brutto_Euro_Miano = new System.Windows.Forms.DataGridViewTextBoxColumn(); 
    95             this.ZATWIERDZONO_DO_DRUKU = new System.Windows.Forms.DataGridViewCheckBoxColumn(); 
    96             this.Data1Emisji = new System.Windows.Forms.DataGridViewTextBoxColumn(); 
    97             this.ShortName1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); 
    98             this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); 
    99             this.dataGridViewTextBoxColumn43 = new System.Windows.Forms.DataGridViewTextBoxColumn(); 
    100             this.dataGridViewTextBoxColumn44 = new System.Windows.Forms.DataGridViewTextBoxColumn(); 
    101             this.ZATWIERDZONO_DO_DRUKU2 = new System.Windows.Forms.DataGridViewCheckBoxColumn(); 
    102100            ((System.ComponentModel.ISupportInitialize)(this.zamowieniaDataGridView)).BeginInit(); 
    103101            ((System.ComponentModel.ISupportInitialize)(this.zamowieniaBindingSource)).BeginInit(); 
    104102            ((System.ComponentModel.ISupportInitialize)(this.rEKLAMADataSet)).BeginInit(); 
    105103            ((System.ComponentModel.ISupportInitialize)(this.rEKLAMADataGridView)).BeginInit(); 
    106             ((System.ComponentModel.ISupportInitialize)(this.rEKLAMABindingSource)).BeginInit(); 
    107104            ((System.ComponentModel.ISupportInitialize)(this.rEKLAMADataGridView1)).BeginInit(); 
    108             ((System.ComponentModel.ISupportInitialize)(this.rEKLAMABindingSource1)).BeginInit(); 
    109105            ((System.ComponentModel.ISupportInitialize)(this.fAKTURYDataGridView)).BeginInit(); 
    110106            ((System.ComponentModel.ISupportInitialize)(this.fAKTURYBindingSource)).BeginInit(); 
     
    118114            this.zamowieniaDataGridView.AllowUserToAddRows = false; 
    119115            this.zamowieniaDataGridView.AllowUserToDeleteRows = false; 
    120             dataGridViewCellStyle1.BackColor = System.Drawing.Color.MintCream; 
    121             this.zamowieniaDataGridView.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; 
     116            dataGridViewCellStyle10.BackColor = System.Drawing.Color.MintCream; 
     117            this.zamowieniaDataGridView.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle10; 
    122118            this.zamowieniaDataGridView.AutoGenerateColumns = false; 
    123119            this.zamowieniaDataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; 
    124120            this.zamowieniaDataGridView.BackgroundColor = System.Drawing.Color.White; 
    125121            this.zamowieniaDataGridView.CausesValidation = false; 
    126             dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; 
    127             dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Control; 
    128             dataGridViewCellStyle2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); 
    129             dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText; 
    130             dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight; 
    131             dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText; 
    132             dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True; 
    133             this.zamowieniaDataGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2; 
     122            dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; 
     123            dataGridViewCellStyle11.BackColor = System.Drawing.SystemColors.Control; 
     124            dataGridViewCellStyle11.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); 
     125            dataGridViewCellStyle11.ForeColor = System.Drawing.SystemColors.WindowText; 
     126            dataGridViewCellStyle11.SelectionBackColor = System.Drawing.SystemColors.Highlight; 
     127            dataGridViewCellStyle11.SelectionForeColor = System.Drawing.SystemColors.HighlightText; 
     128            dataGridViewCellStyle11.WrapMode = System.Windows.Forms.DataGridViewTriState.True; 
     129            this.zamowieniaDataGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle11; 
    134130            this.zamowieniaDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { 
    135131            this.dataGridViewCheckBoxColumn1, 
     
    206202            this.rEKLAMADataGridView.BackgroundColor = System.Drawing.Color.White; 
    207203            this.rEKLAMADataGridView.CausesValidation = false; 
    208             dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; 
    209             dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control; 
    210             dataGridViewCellStyle3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); 
    211             dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText; 
    212             dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight; 
    213             dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText; 
    214             dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True; 
    215             this.rEKLAMADataGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle3; 
     204            dataGridViewCellStyle12.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; 
     205            dataGridViewCellStyle12.BackColor = System.Drawing.SystemColors.Control; 
     206            dataGridViewCellStyle12.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); 
     207            dataGridViewCellStyle12.ForeColor = System.Drawing.SystemColors.WindowText; 
     208            dataGridViewCellStyle12.SelectionBackColor = System.Drawing.SystemColors.Highlight; 
     209            dataGridViewCellStyle12.SelectionForeColor = System.Drawing.SystemColors.HighlightText; 
     210            dataGridViewCellStyle12.WrapMode = System.Windows.Forms.DataGridViewTriState.True; 
     211            this.rEKLAMADataGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle12; 
    216212            this.rEKLAMADataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { 
    217213            this.TYP, 
     
    229225            this.rEKLAMADataGridView.TabIndex = 1; 
    230226            //  
    231             // rEKLAMABindingSource 
    232             //  
    233             this.rEKLAMABindingSource.DataMember = "REKLAMA"; 
    234             this.rEKLAMABindingSource.DataSource = this.rEKLAMADataSet; 
     227            // TYP 
     228            //  
     229            this.TYP.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; 
     230            this.TYP.DataPropertyName = "Type"; 
     231            this.TYP.HeaderText = "Typ"; 
     232            this.TYP.Name = "TYP"; 
     233            this.TYP.ReadOnly = true; 
     234            this.TYP.Width = 50; 
     235            //  
     236            // ShortName 
     237            //  
     238            this.ShortName.DataPropertyName = "ShortName"; 
     239            this.ShortName.HeaderText = "Symbol"; 
     240            this.ShortName.Name = "ShortName"; 
     241            this.ShortName.ReadOnly = true; 
     242            //  
     243            // VAT 
     244            //  
     245            this.VAT.DataPropertyName = "Vat"; 
     246            dataGridViewCellStyle13.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; 
     247            dataGridViewCellStyle13.Format = "P"; 
     248            this.VAT.DefaultCellStyle = dataGridViewCellStyle13; 
     249            this.VAT.HeaderText = "Vat"; 
     250            this.VAT.Name = "VAT"; 
     251            this.VAT.ReadOnly = true; 
     252            //  
     253            // Brutto_Euro_Miano 
     254            //  
     255            this.Brutto_Euro_Miano.DataPropertyName = "Currency"; 
     256            this.Brutto_Euro_Miano.HeaderText = "Waluta"; 
     257            this.Brutto_Euro_Miano.Name = "Brutto_Euro_Miano"; 
     258            this.Brutto_Euro_Miano.ReadOnly = true; 
     259            //  
     260            // ZATWIERDZONO_DO_DRUKU 
     261            //  
     262            this.ZATWIERDZONO_DO_DRUKU.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; 
     263            this.ZATWIERDZONO_DO_DRUKU.DataPropertyName = "IsActivated"; 
     264            this.ZATWIERDZONO_DO_DRUKU.HeaderText = "ZD"; 
     265            this.ZATWIERDZONO_DO_DRUKU.Name = "ZATWIERDZONO_DO_DRUKU"; 
     266            this.ZATWIERDZONO_DO_DRUKU.ReadOnly = true; 
     267            this.ZATWIERDZONO_DO_DRUKU.Width = 25; 
    235268            //  
    236269            // rEKLAMADataGridView1 
     
    238271            this.rEKLAMADataGridView1.AllowUserToAddRows = false; 
    239272            this.rEKLAMADataGridView1.AllowUserToDeleteRows = false; 
    240             dataGridViewCellStyle5.BackColor = System.Drawing.Color.MintCream; 
    241             this.rEKLAMADataGridView1.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5; 
     273            dataGridViewCellStyle14.BackColor = System.Drawing.Color.MintCream; 
     274            this.rEKLAMADataGridView1.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle14; 
    242275            this.rEKLAMADataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; 
    243276            this.rEKLAMADataGridView1.BackgroundColor = System.Drawing.Color.White; 
    244277            this.rEKLAMADataGridView1.CausesValidation = false; 
    245             dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; 
    246             dataGridViewCellStyle6.BackColor = System.Drawing.SystemColors.Control; 
    247             dataGridViewCellStyle6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); 
    248             dataGridViewCellStyle6.ForeColor = System.Drawing.SystemColors.WindowText; 
    249             dataGridViewCellStyle6.SelectionBackColor = System.Drawing.SystemColors.Highlight; 
    250             dataGridViewCellStyle6.SelectionForeColor = System.Drawing.SystemColors.HighlightText; 
    251             dataGridViewCellStyle6.WrapMode = System.Windows.Forms.DataGridViewTriState.True; 
    252             this.rEKLAMADataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle6; 
     278            dataGridViewCellStyle15.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; 
     279            dataGridViewCellStyle15.BackColor = System.Drawing.SystemColors.Control; 
     280            dataGridViewCellStyle15.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); 
     281            dataGridViewCellStyle15.ForeColor = System.Drawing.SystemColors.WindowText; 
     282            dataGridViewCellStyle15.SelectionBackColor = System.Drawing.SystemColors.Highlight; 
     283            dataGridViewCellStyle15.SelectionForeColor = System.Drawing.SystemColors.HighlightText; 
     284            dataGridViewCellStyle15.WrapMode = System.Windows.Forms.DataGridViewTriState.True; 
     285            this.rEKLAMADataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle15; 
    253286            this.rEKLAMADataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { 
    254287            this.Data1Emisji, 
     
    267300            this.rEKLAMADataGridView1.TabIndex = 2; 
    268301            //  
    269             // rEKLAMABindingSource1 
    270             //  
    271             this.rEKLAMABindingSource1.DataMember = "REKLAMA"; 
    272             this.rEKLAMABindingSource1.DataSource = this.rEKLAMADataSet; 
     302            // Data1Emisji 
     303            //  
     304            this.Data1Emisji.DataPropertyName = "StartDate"; 
     305            dataGridViewCellStyle16.Format = "d"; 
     306            dataGridViewCellStyle16.NullValue = null; 
     307            this.Data1Emisji.DefaultCellStyle = dataGridViewCellStyle16; 
     308            this.Data1Emisji.HeaderText = "1 Emisja"; 
     309            this.Data1Emisji.Name = "Data1Emisji"; 
     310            this.Data1Emisji.ReadOnly = true; 
     311            //  
     312            // ShortName1 
     313            //  
     314            this.ShortName1.DataPropertyName = "ShortName"; 
     315            this.ShortName1.HeaderText = "Symbol"; 
     316            this.ShortName1.Name = "ShortName1"; 
     317            this.ShortName1.ReadOnly = true; 
     318            //  
     319            // dataGridViewTextBoxColumn1 
     320            //  
     321            this.dataGridViewTextBoxColumn1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; 
     322            this.dataGridViewTextBoxColumn1.DataPropertyName = "Type"; 
     323            this.dataGridViewTextBoxColumn1.HeaderText = "Typ"; 
     324            this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1"; 
     325            this.dataGridViewTextBoxColumn1.ReadOnly = true; 
     326            this.dataGridViewTextBoxColumn1.Width = 50; 
     327            //  
     328            // dataGridViewTextBoxColumn43 
     329            //  
     330            this.dataGridViewTextBoxColumn43.DataPropertyName = "Vat"; 
     331            dataGridViewCellStyle17.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; 
     332            dataGridViewCellStyle17.Format = "P"; 
     333            this.dataGridViewTextBoxColumn43.DefaultCellStyle = dataGridViewCellStyle17; 
     334            this.dataGridViewTextBoxColumn43.HeaderText = "Vat"; 
     335            this.dataGridViewTextBoxColumn43.Name = "dataGridViewTextBoxColumn43"; 
     336            this.dataGridViewTextBoxColumn43.ReadOnly = true; 
     337            //  
     338            // dataGridViewTextBoxColumn44 
     339            //  
     340            this.dataGridViewTextBoxColumn44.DataPropertyName = "Currency"; 
     341            this.dataGridViewTextBoxColumn44.HeaderText = "Waluta"; 
     342            this.dataGridViewTextBoxColumn44.Name = "dataGridViewTextBoxColumn44"; 
     343            this.dataGridViewTextBoxColumn44.ReadOnly = true; 
     344            //  
     345            // ZATWIERDZONO_DO_DRUKU2 
     346            //  
     347            this.ZATWIERDZONO_DO_DRUKU2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; 
     348            this.ZATWIERDZONO_DO_DRUKU2.DataPropertyName = "IsActivated"; 
     349            this.ZATWIERDZONO_DO_DRUKU2.HeaderText = "ZD"; 
     350            this.ZATWIERDZONO_DO_DRUKU2.Name = "ZATWIERDZONO_DO_DRUKU2"; 
     351            this.ZATWIERDZONO_DO_DRUKU2.ReadOnly = true; 
     352            this.ZATWIERDZONO_DO_DRUKU2.Width = 25; 
    273353            //  
    274354            // dodajButton 
     
    335415            this.fAKTURYDataGridView.AllowUserToAddRows = false; 
    336416            this.fAKTURYDataGridView.AllowUserToDeleteRows = false; 
    337             dataGridViewCellStyle9.BackColor = System.Drawing.Color.MintCream; 
    338             this.fAKTURYDataGridView.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle9; 
     417            dataGridViewCellStyle18.BackColor = System.Drawing.Color.MintCream; 
     418            this.fAKTURYDataGridView.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle18; 
    339419            this.fAKTURYDataGridView.AutoGenerateColumns = false; 
    340420            this.fAKTURYDataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; 
     
    658738            this.KlientLabel.Text = "----"; 
    659739            //  
    660             // TYP 
    661             //  
    662             this.TYP.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; 
    663             this.TYP.DataPropertyName = "Type"; 
    664             this.TYP.HeaderText = "Typ"; 
    665             this.TYP.Name = "TYP"; 
    666             this.TYP.ReadOnly = true; 
    667             this.TYP.Width = 50; 
    668             //  
    669             // ShortName 
    670             //  
    671             this.ShortName.DataPropertyName = "ShortName"; 
    672             this.ShortName.HeaderText = "Symbol"; 
    673             this.ShortName.Name = "ShortName"; 
    674             this.ShortName.ReadOnly = true; 
    675             //  
    676             // VAT 
    677             //  
    678             this.VAT.DataPropertyName = "Vat"; 
    679             dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; 
    680             dataGridViewCellStyle4.Format = "P"; 
    681             this.VAT.DefaultCellStyle = dataGridViewCellStyle4; 
    682             this.VAT.HeaderText = "Vat"; 
    683             this.VAT.Name = "VAT"; 
    684             this.VAT.ReadOnly = true; 
    685             //  
    686             // Brutto_Euro_Miano 
    687             //  
    688             this.Brutto_Euro_Miano.DataPropertyName = "Currency"; 
    689             this.Brutto_Euro_Miano.HeaderText = "Waluta"; 
    690             this.Brutto_Euro_Miano.Name = "Brutto_Euro_Miano"; 
    691             this.Brutto_Euro_Miano.ReadOnly = true; 
    692             //  
    693             // ZATWIERDZONO_DO_DRUKU 
    694             //  
    695             this.ZATWIERDZONO_DO_DRUKU.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; 
    696             this.ZATWIERDZONO_DO_DRUKU.DataPropertyName = "IsActivated"; 
    697             this.ZATWIERDZONO_DO_DRUKU.HeaderText = "ZD"; 
    698             this.ZATWIERDZONO_DO_DRUKU.Name = "ZATWIERDZONO_DO_DRUKU"; 
    699             this.ZATWIERDZONO_DO_DRUKU.ReadOnly = true; 
    700             this.ZATWIERDZONO_DO_DRUKU.Width = 25; 
    701             //  
    702             // Data1Emisji 
    703             //  
    704             this.Data1Emisji.DataPropertyName = "StartDate"; 
    705             dataGridViewCellStyle7.Format = "d"; 
    706             dataGridViewCellStyle7.NullValue = null; 
    707             this.Data1Emisji.DefaultCellStyle = dataGridViewCellStyle7; 
    708             this.Data1Emisji.HeaderText = "1 Emisja"; 
    709             this.Data1Emisji.Name = "Data1Emisji"; 
    710             this.Data1Emisji.ReadOnly = true; 
    711             //  
    712             // ShortName1 
    713             //  
    714             this.ShortName1.DataPropertyName = "ShortName"; 
    715             this.ShortName1.HeaderText = "Symbol"; 
    716             this.ShortName1.Name = "ShortName1"; 
    717             this.ShortName1.ReadOnly = true; 
    718             //  
    719             // dataGridViewTextBoxColumn1 
    720             //  
    721             this.dataGridViewTextBoxColumn1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; 
    722             this.dataGridViewTextBoxColumn1.DataPropertyName = "Type"; 
    723             this.dataGridViewTextBoxColumn1.HeaderText = "Typ"; 
    724             this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1"; 
    725             this.dataGridViewTextBoxColumn1.ReadOnly = true; 
    726             this.dataGridViewTextBoxColumn1.Width = 50; 
    727             //  
    728             // dataGridViewTextBoxColumn43 
    729             //  
    730             this.dataGridViewTextBoxColumn43.DataPropertyName = "Vat"; 
    731             dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; 
    732             dataGridViewCellStyle8.Format = "P"; 
    733             this.dataGridViewTextBoxColumn43.DefaultCellStyle = dataGridViewCellStyle8; 
    734             this.dataGridViewTextBoxColumn43.HeaderText = "Vat"; 
    735             this.dataGridViewTextBoxColumn43.Name = "dataGridViewTextBoxColumn43"; 
    736             this.dataGridViewTextBoxColumn43.ReadOnly = true; 
    737             //  
    738             // dataGridViewTextBoxColumn44 
    739             //  
    740             this.dataGridViewTextBoxColumn44.DataPropertyName = "Currency"; 
    741             this.dataGridViewTextBoxColumn44.HeaderText = "Waluta"; 
    742             this.dataGridViewTextBoxColumn44.Name = "dataGridViewTextBoxColumn44"; 
    743             this.dataGridViewTextBoxColumn44.ReadOnly = true; 
    744             //  
    745             // ZATWIERDZONO_DO_DRUKU2 
    746             //  
    747             this.ZATWIERDZONO_DO_DRUKU2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; 
    748             this.ZATWIERDZONO_DO_DRUKU2.DataPropertyName = "IsActivated"; 
    749             this.ZATWIERDZONO_DO_DRUKU2.HeaderText = "ZD"; 
    750             this.ZATWIERDZONO_DO_DRUKU2.Name = "ZATWIERDZONO_DO_DRUKU2"; 
    751             this.ZATWIERDZONO_DO_DRUKU2.ReadOnly = true; 
    752             this.ZATWIERDZONO_DO_DRUKU2.Width = 25; 
    753             //  
    754740            // ZamowieniaForm 
    755741            //  
     
    769755            ((System.ComponentModel.ISupportInitialize)(this.rEKLAMADataSet)).EndInit(); 
    770756            ((System.ComponentModel.ISupportInitialize)(this.rEKLAMADataGridView)).EndInit(); 
    771             ((System.ComponentModel.ISupportInitialize)(this.rEKLAMABindingSource)).EndInit(); 
    772757            ((System.ComponentModel.ISupportInitialize)(this.rEKLAMADataGridView1)).EndInit(); 
    773             ((System.ComponentModel.ISupportInitialize)(this.rEKLAMABindingSource1)).EndInit(); 
    774758            ((System.ComponentModel.ISupportInitialize)(this.fAKTURYDataGridView)).EndInit(); 
    775759            ((System.ComponentModel.ISupportInitialize)(this.fAKTURYBindingSource)).EndInit(); 
     
    801785        private System.Windows.Forms.DataGridView fAKTURYDataGridView; 
    802786        private System.Windows.Forms.Button WydrukButton; 
    803         private System.Windows.Forms.BindingSource rEKLAMABindingSource; 
    804         private System.Windows.Forms.BindingSource rEKLAMABindingSource1; 
    805787        private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn3; 
    806788        private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn4; 
  • branches/Abonament/BazaReklam/ZamowieniaForm.cs

    r704 r705  
    88using Baza_Reklam.Classes.Helpers; 
    99using Baza_Reklam.Classes.Interfaces; 
     10using Baza_Reklam.Classes.Model; 
    1011using Baza_Reklam.Classes.Model.Enums; 
    1112using Baza_Reklam.Classes.Repositories; 
     
    1819        private List<IProduct> productsWithOrder = new List<IProduct>(); 
    1920        private List<IProduct> productsWithoutOrder = new List<IProduct>(); 
     21        private AgentRepository agentRepository; 
     22        private Agent agent; 
    2023         
    2124        private REKLAMADataSet.KLIENCIRow klient; 
    22  
    2325        private int idZamowienia; 
    24  
    25         private REKLAMADataSet.REKLAMADataTable reklamyBezZamowienia; 
    2626 
    2727        private REKLAMADataSetTableAdapters.KLIENCITableAdapter klienciTableAdapter = 
     
    4949            new SLOWNIKDataSetTableAdapters.Kursy_WalutTableAdapter(); 
    5050 
    51         #region properties 
    52  
    53         public REKLAMADataSet.REKLAMADataTable ReklamyBezZamowienia 
    54         { 
    55             get { return reklamyBezZamowienia; } 
    56             set { reklamyBezZamowienia = value; } 
    57         } 
    58  
    59         #endregion properties 
    60  
     51         
    6152        public ZamowieniaForm(REKLAMADataSet.KLIENCIRow klient) 
    6253        { 
     
    8273            klient = klienciTableAdapter.GetDataByCustomerId(idKlienta)[0]; 
    8374            this.idZamowienia = idZamowienia; 
    84  
    8575        } 
    8676 
     
    8878        { 
    8979            customerRepository = new CustomerRepository(ConnString.getConnString().Value); 
     80            agentRepository = new AgentRepository(ConnString.getConnString().Value); 
    9081 
    9182            productsWithOrder = customerRepository.FindProductsWithOrders(customerId); 
    9283            productsWithoutOrder = customerRepository.FindProductsWithoutOrders(customerId); 
    9384 
    94             rEKLAMABindingSource1.DataSource = ReklamyBezZamowienia; 
    9585            zamowieniaTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value; 
    9686            rEKLAMATableAdapter.Connection.ConnectionString = ConnString.getConnString().Value; 
     
    131121            zamowieniaBindingSource.CurrentChanged += zamowieniaBindingSource_CurrentChanged; 
    132122 
    133             ReklamyBezZamowienia = rEKLAMATableAdapter.GetDataByCustomerIdandIdZamowienia(klient.CustomerID); 
    134             rEKLAMABindingSource1.DataSource = ReklamyBezZamowienia; 
    135123            zamowieniaTableAdapter.FillByIdKlienta(rEKLAMADataSet.zamowienia, klient.CustomerID); 
    136124 
     
    140128 
    141129                BindProductsWithOrders(idZamowienia); 
    142                  
     130 
    143131                fAKTURYTableAdapter.FillByIdZamowienia(rEKLAMADataSet.FAKTURY, idZamowienia); 
    144132            } 
    145133            else 
    146             { 
    147134                zamowieniaBindingSource.Position = 0; 
    148             } 
    149  
    150             if (klient != null) 
    151             { 
    152                 if (klient.IskodKlientaNull()) 
    153                 { 
    154                     KlientLabel.Text = "BRAK KODU KLIENTA"; 
    155                 } 
    156                 else 
    157                 { 
    158                     KlientLabel.Text = "KOD KLIENTA:  " + klient.kodKlienta; 
    159                 } 
    160             } 
     135 
     136            if (klient == null) return; 
     137             
     138            KlientLabel.Text = klient.IskodKlientaNull() 
     139                                   ? "BRAK KODU KLIENTA" 
     140                                   : "KOD KLIENTA:  " + klient.kodKlienta; 
    161141        } 
    162142 
     
    172152            if (azf.ShowDialog() == DialogResult.OK) 
    173153            { 
    174                 //rEKLAMADataSet.zamowienia.Clear(); 
    175                 //this.zamowieniaTableAdapter.FillByIdKlienta(this.rEKLAMADataSet.zamowienia, klient.CustomerID); 
    176154                rEKLAMADataSet.zamowienia.ImportRow(azf.Zamowienia[0]); 
    177155                int idZam = azf.Zamowienia[0].idZamowienia; 
     
    217195            } 
    218196 
    219             //TODO: move that piece to separate method 
    220             if (product.ProductType == ProductType.Advertisment) 
    221             { 
    222                 if (zamowienie.IsidKontaNull()) 
    223                 { 
    224                     // zmiana domyœlnego konta do faktury dla EUR 
    225                     if (User.Instance().IdAgencji != 4 && product.Currency == "EUR") 
    226                     { 
    227                         if (User.Instance().IdAgencji == 1223940396 || User.Instance().IdAgencji == 1223940398) 
    228                             zamowienie.idKonta = 3; 
    229                         else 
    230                             zamowienie.idKonta = 5; 
    231  
    232                         zamowieniaTableAdapter.Update(rEKLAMADataSet.zamowienia); 
    233                     } 
    234                 } 
    235             } 
     197            UpdateOrderAccount(product, zamowienie); 
    236198 
    237199            product.OrderId = zamowienie.idZamowienia; 
     
    243205            BindProductsWithOrders(zamowienie.idZamowienia); 
    244206            BindProductsWithoutOrders(); 
     207        } 
     208 
     209        private void UpdateOrderAccount(IProduct product, REKLAMADataSet.zamowieniaRow order) 
     210        { 
     211            if (product.ProductType != ProductType.Advertisment || !order.IsidKontaNull()) return; 
     212 
     213            // zmiana domyœlnego konta do faktury dla EUR 
     214            if (User.Instance().IdAgencji != 4 && product.Currency == "EUR") 
     215            { 
     216                if (User.Instance().IdAgencji == 1223940396 || User.Instance().IdAgencji == 1223940398) 
     217                    order.idKonta = 3; 
     218                else 
     219                    order.idKonta = 5; 
     220 
     221                zamowieniaTableAdapter.Update(rEKLAMADataSet.zamowienia); 
     222            } 
    245223        } 
    246224 
     
    315293                REKLAMADataSet.zamowieniaRow zamowienie = (REKLAMADataSet.zamowieniaRow) z.Row; 
    316294 
    317                 REKLAMADataSet.KLIENCIRow klientRow = 
    318                     (REKLAMADataSet.KLIENCIRow) klienciTableAdapter.GetDataByCustomerId(zamowienie.idKlienta).Rows[0]; 
    319  
    320295                InitIssueTables(zamowienie); 
    321296 
    322                 string errorMessage = CzyMoznaZafakturowac(zamowienie, klientRow); 
     297                string errorMessage = CzyMoznaZafakturowac(zamowienie, klient); 
    323298 
    324299                if (errorMessage != string.Empty) 
     
    329304                } 
    330305 
    331                 WystawFakture(zamowienie, klientRow, false); 
     306                List<IProduct> subscriptionsToInvoice = GetSubscriptionsToInvoice(productsWithOrder); 
     307 
     308                WystawFakture(zamowienie, klient, subscriptionsToInvoice, false); 
    332309 
    333310                RestoreConnections(); 
     
    343320        } 
    344321 
    345         private int WystawFakture(REKLAMADataSet.zamowieniaRow zamowienie, REKLAMADataSet.KLIENCIRow klientRow, bool proforma) 
     322        private int WystawFakture(REKLAMADataSet.zamowieniaRow zamowienie, REKLAMADataSet.KLIENCIRow klientRow, List<IProduct> subscriptions, bool proforma) 
    346323        { 
    347324            int idNaglowka; 
    348              
     325 
    349326            try 
    350327            { 
    351                 REKLAMADataSet.FAKTURYRow naglowekFaktury = UtworzNaglowekFaktury(zamowienie, klientRow, proforma); 
    352                 rEKLAMADataSet.FAKTURY.AddFAKTURYRow(naglowekFaktury); 
    353                 PobierzOznaczEmisje(zamowienie, naglowekFaktury); 
    354                 UtworzPozycjeFaktury(naglowekFaktury, klientRow); 
    355                 DodajWplate(naglowekFaktury); 
    356  
    357                 zamowienie.zafakturowano = true; 
    358                 zamowienie.EndEdit(); 
    359  
    360328                SqlConnection conn = new SqlConnection(ConnString.getConnString().Value); 
    361329 
     
    377345                wplatyTableAdapter.AttachTransaction(transaction); 
    378346 
     347 
     348                REKLAMADataSet.FAKTURYRow naglowekFaktury = UtworzNaglowekFaktury(zamowienie, klientRow, proforma); 
    379349                try 
    380350                { 
     351                    rEKLAMADataSet.FAKTURY.AddFAKTURYRow(naglowekFaktury); 
     352                    PobierzOznaczEmisje(zamowienie, naglowekFaktury); 
     353                    UtworzPozycjeFaktury(naglowekFaktury, klientRow, subscriptions); 
     354                    DodajWplate(naglowekFaktury); 
     355 
     356                    zamowienie.zafakturowano = true; 
     357                    zamowienie.EndEdit(); 
     358 
    381359                    fAKTURYTableAdapter.Update(rEKLAMADataSet.FAKTURY); 
    382360                    idNaglowka = naglowekFaktury.ID_FAKTURY; 
     
    385363                    wplatyTableAdapter.Update(rEKLAMADataSet.Wplaty); 
    386364 
    387                     int il = (int)emisjeTableAdapter.iloscNiezafakturowanychEmisjiWZamowieniu( 
    388                         zamowienie.idZamowienia); 
     365                    int il = (int) emisjeTableAdapter.iloscNiezafakturowanychEmisjiWZamowieniu(zamowienie.idZamowienia); 
    389366                    if (il == 0 && !proforma) 
    390367                    { 
     
    427404                fAKTURYDataGridView.Refresh(); 
    428405                zamowieniaBindingSource.ResetBindings(false); 
    429                  
     406 
    430407            } 
    431408 
     
    441418        } 
    442419 
    443         private void UtworzPozycjeFaktury(REKLAMADataSet.FAKTURYRow naglowekFaktury, REKLAMADataSet.KLIENCIRow klientRow) 
     420        private void UtworzPozycjeFaktury(REKLAMADataSet.FAKTURYRow naglowekFaktury, REKLAMADataSet.KLIENCIRow klientRow, List<IProduct> subscriptionsToInvoice) 
    444421        { 
    445422            decimal bruttoWaluta = 0; 
     
    532509            } 
    533510 
     511            foreach (IProduct subscription in subscriptionsToInvoice) 
     512            { 
     513 
     514                foreach (IProductDetail subscriptionDetail in subscription.ProductDetails) 
     515                { 
     516                    REKLAMADataSet.FAKTURA_DETAILSRow fakturaDetailsRow = rEKLAMADataSet.FAKTURA_DETAILS.NewFAKTURA_DETAILSRow(); 
     517 
     518                    fakturaDetailsRow.ROK = subscriptionDetail.Year; 
     519                    fakturaDetailsRow.MIESIAC = (short)subscriptionDetail.Month; 
     520                    //TODO: Add Title to Subscription schema 
     521                    //fakturaDetailsRow.TYTUL = subscriptionDetail; 
     522                    //TODO: Nazwa uslugi dla reklamy i abonamentu 
     523                    fakturaDetailsRow.NAZWA_USLUGI = subscriptionDetail.ProductId + " | " + subscriptionDetail.Id; 
     524                    fakturaDetailsRow.reklamaId = subscription.Id; 
     525                    fakturaDetailsRow.CENA_JEDN = subscription.Price; 
     526                    fakturaDetailsRow.ILOSC = 1; 
     527                    fakturaDetailsRow.JM = "szt."; 
     528 
     529                    fakturaDetailsRow.NETTO = subscriptionDetail.PricePln; 
     530                    fakturaDetailsRow.BRUTTO = Math.Round(subscriptionDetail.PricePln * (1 + subscription.Vat)); 
     531                    fakturaDetailsRow.S_VAT = (double)subscription.Vat; 
     532                    fakturaDetailsRow.VAT = Math.Round(subscriptionDetail.PricePln * subscription.Vat); 
     533 
     534                    //TODO: Get discount from parent 
     535                    //fakturaDetailsRow.UPUST_PR = subscription.Discount; 
     536                    //fakturaDetailsRow.UPUST_NETTO = fakturaDetailsRow.UPUST_PR != 0 ? Math.Round(netto / Convert.ToDecimal(reklama.RABAT) - netto, 2) : 0; 
     537 
     538                    fakturaDetailsRow.TYP = 1; 
     539                    fakturaDetailsRow.PODTYP = 1; 
     540                    fakturaDetailsRow.ID_FAKTURY = naglowekFaktury.ID_FAKTURY; 
     541 
     542                    rEKLAMADataSet.FAKTURA_DETAILS.AddFAKTURA_DETAILSRow(fakturaDetailsRow); 
     543 
     544                    if (subscription.Currency != "PLN") 
     545                        bruttoWaluta += subscriptionDetail.Price; 
     546                } 
     547                 
     548                 
     549            } 
     550 
     551 
    534552            if (bruttoWaluta != 0) 
    535553            { 
     
    546564            rEKLAMADataSet.UKAZE_SIE_W_NR.Clear(); 
    547565            rEKLAMADataSet.DatyWydan.Clear(); 
     566            rEKLAMATableAdapter.FillByIdZamowienia(rEKLAMADataSet.REKLAMA, zamowienie.idZamowienia); 
    548567 
    549568            REKLAMADataSet.DatyWydanDataTable t = datyWydanTableAdapter.GetDataByPierwszaEmisjaWZamowieniu(zamowienie.idZamowienia); 
     
    551570 
    552571            DateTime d = t[0].DATA_W; 
    553             //d = zamowienie.IsdataOstatniejZafakturowanejEmisjiNull() ? d : zamowienie.dataOstatniejZafakturowanejEmisji.AddMonths(1); 
    554  
    555             List<string> adIds = new List<string>(); 
    556  
    557             foreach (DataRow r in rEKLAMADataSet.REKLAMA.Rows) 
    558             { 
    559                 REKLAMADataSet.REKLAMARow reklama = (REKLAMADataSet.REKLAMARow)r; 
    560                 adIds.Add(reklama.ID_REKLAMY); 
     572 
     573            foreach (REKLAMADataSet.REKLAMARow reklama in rEKLAMADataSet.REKLAMA.Rows) 
     574            { 
    561575                switch (zamowienie.rodzajFakturowania) 
    562576                { 
     
    593607        private void PobierzOznaczEmisje(REKLAMADataSet.zamowieniaRow zamowienie, REKLAMADataSet.FAKTURYRow naglowekFaktury) 
    594608        { 
    595             //InitIssueTables(zamowienie); 
    596  
    597609            if (zamowienie.IsdataOstatniejZafakturowanejEmisjiNull()) 
    598610            { 
     
    600612            } 
    601613 
    602             foreach (DataRow r in rEKLAMADataSet.REKLAMA.Rows) 
    603             { 
    604                 REKLAMADataSet.REKLAMARow reklama = (REKLAMADataSet.REKLAMARow)r; 
    605                  
     614            foreach (REKLAMADataSet.REKLAMARow reklama in rEKLAMADataSet.REKLAMA.Rows) 
     615            { 
    606616                foreach (DataRow em in rEKLAMADataSet.UKAZE_SIE_W_NR) 
    607617                { 
     
    648658        private REKLAMADataSet.FAKTURYRow UtworzNaglowekFaktury(REKLAMADataSet.zamowieniaRow zamowienie, REKLAMADataSet.KLIENCIRow klientRow, bool proforma) 
    649659        { 
    650             SLOWNIKDataSet.AGENCIRow agent = (SLOWNIKDataSet.AGENCIRow)agenciTableAdapter.GetDataByKodAgenta(zamowienie.kodAgenta).Rows[0]; 
    651             IInvoiceProvider invoiceProvider = InvoiceProviderFactory.GetInvoiceProviderById(agent.InvoiceProviderId); 
    652  
     660            agent = agentRepository.FindByShortName(zamowienie.kodAgenta); 
     661 
     662            IInvoiceProvider invoiceProvider = InvoiceProviderFactory.GetInvoiceProviderById(agent.InvoiceProvider); 
    653663 
    654664            REKLAMADataSet.FAKTURYRow naglowekFaktury = (REKLAMADataSet.FAKTURYRow)rEKLAMADataSet.FAKTURY.NewRow(); 
     
    661671            naglowekFaktury.DATA_WYSTAWIENIA = DateTime.Today; 
    662672 
    663             if (User.Instance().IsKierownik) 
    664             { 
    665                 if (dtpZmianaDaty.Value != DateTime.Today) 
    666                 { 
    667                     naglowekFaktury.DATA_WYSTAWIENIA = dtpZmianaDaty.Value; 
    668                 } 
    669             } 
     673            //TODO: pass issueDate as parameter 
     674            if (dtpZmianaDaty.Value != DateTime.Today && User.Instance().IsKierownik) 
     675                naglowekFaktury.DATA_WYSTAWIENIA = dtpZmianaDaty.Value; 
    670676 
    671677            SLOWNIKDataSet.AGENCJERow agencja = (SLOWNIKDataSet.AGENCJERow)agencjeTableAdapter.GetDataByKodAgenta(zamowienie.kodAgenta).Rows[0]; 
    672678            naglowekFaktury.ID_SPRZEDAWCY = agencja.Id_agencji; 
    673679             
    674             if (naglowekFaktury.ID_SPRZEDAWCY == 4 || naglowekFaktury.ID_SPRZEDAWCY == 6 || 
    675                 naglowekFaktury.ID_SPRZEDAWCY == 1223940400) 
    676             { 
     680            //Set EKSPORT to true to avoid to export this invoice to SoftLab FK accounting system 
     681            if (naglowekFaktury.ID_SPRZEDAWCY == 4 || naglowekFaktury.ID_SPRZEDAWCY == 6) 
    677682                naglowekFaktury.EKSPORT = true; 
    678             } 
    679683 
    680684            naglowekFaktury.MIEJSCOWOSC_WYSTAWIENIA = agencja.miasto; 
    681             naglowekFaktury.SPRZEDAWCA_ADRES = invoiceProvider.GetAddress(); //agencja.Adres_Fk; 
    682             naglowekFaktury.SPRZEDAWCA_NIP = invoiceProvider.TaxNumber; //agencja.NIP; 
     685            naglowekFaktury.SPRZEDAWCA_ADRES = invoiceProvider.GetAddress(); 
     686            naglowekFaktury.SPRZEDAWCA_NIP = invoiceProvider.TaxNumber; 
    683687            naglowekFaktury.SystemKsiegowyId = Convert.ToByte(invoiceProvider.SystemKsiegowyId); 
    684              
    685  
    686             //SLOWNIKDataSet.AGENCIRow agent = (SLOWNIKDataSet.AGENCIRow)agenciTableAdapter.GetDataByKodAgenta(zamowienie.kodAgenta).Rows[0]; 
    687             naglowekFaktury.PODPIS_WYSTAWIL = agent.Imiê + " " + agent.Nazwisko; 
     688 
     689            naglowekFaktury.PODPIS_WYSTAWIL = agent.ToString(); 
    688690            naglowekFaktury.DATA_SPRZEDAZY = naglowekFaktury.DATA_WYSTAWIENIA; 
    689691 
    690             naglowekFaktury.ID_NABYWCY = zamowienie.idKlienta; 
     692            naglowekFaktury.ID_NABYWCY = klientRow.CustomerID; 
    691693            naglowekFaktury.NABYWCA_ADRES = klientRow.Adres_Fkatura; 
    692694            naglowekFaktury.NABYWCA_NIP = klientRow.Nip; 
    693695            naglowekFaktury.opis = "Faktura za reklamy zgodnie z zamówieniem: "  
    694                 + klientRow.kodKlienta +  
    695                 "/" + zamowienie.nrZamowienia +  
    696                 "/" + zamowienie.kodAgenta +  
    697                 "/" + zamowienie.rokZamowienia; 
    698  
     696                                                + klientRow.kodKlienta +  
     697                                                "/" + zamowienie.nrZamowienia +  
     698                                                "/" + zamowienie.kodAgenta +  
     699                                                "/" + zamowienie.rokZamowienia; 
    699700 
    700701            naglowekFaktury.SPOSOB_ZAPLATY = FakturaHelper.GetPaymentType(zamowienie.sposobZaplaty); 
     
    708709            naglowekFaktury.waluta_kurs = 1d; 
    709710            //WALUTOWE 
    710             if (!rEKLAMADataSet.REKLAMA[0].IsBrutto_Euro_MianoNull() && 
    711                 rEKLAMADataSet.REKLAMA[0].Brutto_Euro_Miano != string.Empty) 
    712             { 
    713                 //naglowekFaktury.SPRZEDAWCA_NIP = agencja.vies; 
     711            if (!rEKLAMADataSet.REKLAMA[0].IsBrutto_Euro_MianoNull() && rEKLAMADataSet.REKLAMA[0].Brutto_Euro_Miano != string.Empty) 
     712            { 
    714713                naglowekFaktury.SPRZEDAWCA_NIP = invoiceProvider.TaxCountryPrefix + " " + invoiceProvider.TaxNumber; //agencja.vies; 
    715714                naglowekFaktury.NABYWCA_NIP = klientRow.nipKraj + " " + klientRow.Nip; 
     
    741740            return naglowekFaktury; 
    742741        } 
    743  
    744          
    745742 
    746743        private string CzyMoznaZafakturowac(REKLAMADataSet.zamowieniaRow zamowienie, REKLAMADataSet.KLIENCIRow klientRow) 
     
    11721169        { 
    11731170            if (zamowieniaBindingSource.Current == null) return; 
    1174              
    1175              
    1176             DataRowView z = (DataRowView)zamowieniaBindingSource.Current; 
    1177             REKLAMADataSet.zamowieniaRow zamowienie = (REKLAMADataSet.zamowieniaRow)z.Row; 
    1178                  
    1179             //rEKLAMATableAdapter.FillByIdZamowienia(rEKLAMADataSet.REKLAMA, zamowienie.idZamowienia); 
     1171 
     1172            DataRowView z = (DataRowView) zamowieniaBindingSource.Current; 
     1173            REKLAMADataSet.zamowieniaRow zamowienie = (REKLAMADataSet.zamowieniaRow) z.Row; 
     1174 
    11801175            BindProductsWithOrders(zamowienie.idZamowienia); 
    11811176 
     
    13941389            REKLAMADataSet.zamowieniaRow zamowienie = (REKLAMADataSet.zamowieniaRow) z.Row; 
    13951390 
    1396             REKLAMADataSet.KLIENCIRow _klient = 
    1397                 (REKLAMADataSet.KLIENCIRow) klienciTableAdapter.GetDataByCustomerId(zamowienie.idKlienta).Rows[0]; 
    1398  
    13991391            InitIssueTables(zamowienie); 
    14001392 
    1401             string errorMessage = CzyMoznaZafakturowac(zamowienie, _klient); 
     1393            string errorMessage = CzyMoznaZafakturowac(zamowienie, klient); 
    14021394 
    14031395            if (errorMessage != string.Empty) 
     
    14111403            try 
    14121404            { 
    1413                 id = WystawFakture(zamowienie, _klient, true); 
    1414                 FactureViewer fv = new FactureViewer(id, true, _klient.kodKlienta); 
     1405                List<IProduct> subscriptionsToInvoice = GetSubscriptionsToInvoice(productsWithOrder); 
     1406 
     1407                id = WystawFakture(zamowienie, klient, subscriptionsToInvoice, true); 
     1408                FactureViewer fv = new FactureViewer(id, true, klient.kodKlienta); 
    14151409                fv.ShowDialog(); 
    14161410            } 
     
    14191413                DataRow[] rows = rEKLAMADataSet.FAKTURY.Select("id_faktury=" + id); 
    14201414                if (rows.Length > 0) 
    1421                     usunFakture((REKLAMADataSet.FAKTURYRow) rows[0]); 
    1422                  
     1415                    usunFakture((REKLAMADataSet.FAKTURYRow)rows[0]); 
     1416 
    14231417                RestoreConnections(); 
    14241418                Cursor = Cursors.Default; 
     
    14351429            wplatyTableAdapter.Connection = new SqlConnection(ConnString.getConnString().Value); 
    14361430        } 
     1431 
     1432        private List<IProduct> GetSubscriptionsToInvoice(List<IProduct> products) 
     1433        { 
     1434            ProductRepository productRepository = new ProductRepository(ConnString.getConnString().Value); 
     1435            List<IProduct> subscriptions = products.FindAll(delegate(IProduct p) { return p.ProductType == ProductType.Subscription; }); 
     1436            DateTime date = productRepository.FindFirstDateForInvoice(subscriptions); 
     1437            List<IProduct> subscriptionsToInvoice = productRepository.FindProductsToInvoice(subscriptions, InvoicingType.ThreeMonths, date); 
     1438            return subscriptionsToInvoice; 
     1439        } 
     1440 
    14371441    } 
    14381442} 
  • branches/Abonament/BazaReklam/ZamowieniaForm.resx

    r704 r705  
    136136    <value>17, 17</value> 
    137137  </metadata> 
     138  <metadata name="rEKLAMADataSet.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 
     139    <value>17, 17</value> 
     140  </metadata> 
    138141  <metadata name="TYP.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 
    139142    <value>True</value> 
     
    151154    <value>True</value> 
    152155  </metadata> 
    153   <metadata name="rEKLAMABindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 
    154     <value>1087, 17</value> 
    155   </metadata> 
    156156  <metadata name="Data1Emisji.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 
    157157    <value>True</value> 
     
    171171  <metadata name="ZATWIERDZONO_DO_DRUKU2.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 
    172172    <value>True</value> 
    173   </metadata> 
    174   <metadata name="rEKLAMABindingSource1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 
    175     <value>17, 54</value> 
    176173  </metadata> 
    177174  <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> 
     
    546543  </data> 
    547544  <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 
    548     <value>87</value> 
     545    <value>52</value> 
    549546  </metadata> 
    550547</root>