﻿using System;
using System.Data;
using System.Data.SqlClient;

namespace Baza_Reklam.REKLAMADataSetTableAdapters
{
    partial class REKLAMATableAdapter
    {
        public void AttachTransaction(SqlTransaction transaction)
        {
            this.Adapter.InsertCommand.Transaction = transaction;
            this.Adapter.UpdateCommand.Transaction = transaction;
            this.Adapter.DeleteCommand.Transaction = transaction;
        }
    }

    partial class FAKTURA_DETAILSTableAdapter
    {
        public void AttachTransaction(SqlTransaction transaction)
        {
            this.Adapter.InsertCommand.Transaction = transaction;
            this.Adapter.UpdateCommand.Transaction = transaction;
            this.Adapter.DeleteCommand.Transaction = transaction;
        }
    }

    partial class UKAZE_SIE_W_NRTableAdapter
    {
        public void AttachTransaction(SqlTransaction transaction)
        {
            this.Adapter.InsertCommand.Transaction = transaction;
            this.Adapter.UpdateCommand.Transaction = transaction;
            this.Adapter.DeleteCommand.Transaction = transaction;

            foreach (SqlCommand c in this.CommandCollection)
            {
                c.Transaction = transaction;
            }
        }
    }

    partial class zamowieniaTableAdapter
    {
        public void AttachTransaction(SqlTransaction transaction)
        {
            this.Adapter.InsertCommand.Transaction = transaction;
            this.Adapter.UpdateCommand.Transaction = transaction;
            this.Adapter.DeleteCommand.Transaction = transaction;
        }
    }

    partial class FAKTURYTableAdapter
    {
        public void AttachTransaction(SqlTransaction transaction)
        {
            this.Adapter.InsertCommand.Transaction = transaction;
            this.Adapter.UpdateCommand.Transaction = transaction;
            this.Adapter.DeleteCommand.Transaction = transaction;
        }
    }
}

namespace Baza_Reklam {


    partial class REKLAMADataSet
    {
        partial class WplatyDataTable
        {
        }
    
        partial class VIEW_ZESTAWIENIE_FAKTUR_NOWEDataTable
        {
        }

        partial class REKLAMADataTable
        {
            public double sumaNetto()
            {
                double suma = 0;
             
                if (Rows.Count > 0)
                {
                    suma = (double)this.Compute("Sum(netto)", "netto is not null");
                }
                
                return suma;
            }
        }

        partial class zamowieniaDataTable
        {
            /// <summary>
            /// Do wywołania jeżeli z tablicy są wszystkie zamówienia klienta 
            /// </summary>
            public int nrKolejnegoZamowienia(int rok)
            {
                int nowyNr = 1;
                
                if (Rows.Count > 0)
                {
                    nowyNr = (int)this.Compute("Count(idZamowienia)", "rokZamowienia=" + rok);
                }

                return nowyNr;
            }
        }

        partial class UKAZE_SIE_W_NRDataTable
        {

            public int Count2
            {
                get
                {
                    return (int)this.Compute("count(id)", "status <> 2");
                }
            }

            public int PoliczAktywne(int reklamaId)
            {
                return (int)this.Compute("count(id)", " reklamaID=" + reklamaId + " and status <> 2");
            }

            public short MaxZafakturowanyNrWydania()
            {
                if ((int)this.Compute("count(id)", "zafakturowana=1") > 0)
                {
                    return (short)this.Compute("max([Nr Wydania])", "zafakturowana=1");
                }
                return 0;
            }

            /*
            public double sumaNetto(string tytul,  )
            {
                double suma = 0;

                if (Rows.Count > 0)
                {
                    suma = (double)this.Compute("Sum(netto)", "netto is not null");
                }

                return suma;
            }*/
        }
           

        partial class REKLAMA_STRONADataTable
        {
        }
    
        partial class KONTAKTYDataTable
        {
           
        }

      

    }
}
