public static Dictionary <string, string> PolaczZBazaLinkZamowienieKlient()
        {
            //set the connection string
            string connString = conn_string;

            //variables to store the query results

            try
            {
                //sql connection object
                using (SqlConnection conn = new SqlConnection(connString))
                {
                    //define the SqlCommand object
                    SqlCommand cmd = new SqlCommand(query_get_orders, conn);

                    //open connection
                    conn.Open();

                    //execute the SQLCommand
                    SqlDataReader dr = cmd.ExecuteReader();

                    // Console.WriteLine(Environment.NewLine + "Retrieving data from database...LinkZamowienieKlient" + Environment.NewLine);
                    // Console.WriteLine("Retrieved records:");

                    string ZamowienieIdHashKey, KlientIdHashKey, mail, RecordSource;
                    int    ETL_RunId, ServerId, Id, id_klienta;

                    Dictionary <string, string> temp = new Dictionary <string, string>();


                    //check if there are records
                    if (dr.HasRows)
                    {
                        while (dr.Read())
                        {
                            ZamowienieIdHashKey = dr.GetString(1);
                            KlientIdHashKey     = dr.GetString(2);
                            ETL_RunId           = dr.GetInt32(3);
                            RecordSource        = dr.GetString(4);
                            ServerId            = dr.GetInt32(5);
                            Id         = dr.GetInt32(6);
                            id_klienta = dr.GetInt32(7);
                            mail       = dr.GetString(8);

                            Dictionary <string, string> tempin = new Dictionary <string, string>();

                            tempin["ZamowienieKlientHashKey"] = ZamowienieIdHashKey;
                            tempin["KlientIdHashKey"]         = KlientIdHashKey;
                            tempin["ETL_RunId"]       = ETL_RunId.ToString();
                            tempin["RecordSource"]    = RecordSource;
                            tempin["ServerId"]        = ServerId.ToString();
                            tempin["Id"]              = Id.ToString();
                            tempin["id_klienta"]      = id_klienta.ToString();
                            tempin["mail"]            = mail;
                            temp[ZamowienieIdHashKey] = KlientIdHashKey;
                        }
                    }
                    else
                    {
                        Console.WriteLine("No data found.");
                    }

                    //close data reader
                    dr.Close();

                    //close connection
                    conn.Close();

                    return(temp);
                }
            }
            catch (Exception ex)
            {
                //display error message
                Console.WriteLine("Exception: " + ex.Message);
            }
            return(new Dictionary <string, string>());
        }
        public static Dictionary <string, Dictionary <string, string> > PolaczZBazaSatZamowienieKlientDaneFirmy()
        {
            //set the connection string
            string connString = conn_string;

            try
            {
                //sql connection object
                using (SqlConnection conn = new SqlConnection(connString))
                {
                    //define the SqlCommand object
                    SqlCommand cmd = new SqlCommand(query_zamowienie_klient_dane_firmy, conn);

                    //open connection
                    conn.Open();

                    //execute the SQLCommand
                    SqlDataReader dr = cmd.ExecuteReader();

                    // Console.WriteLine(Environment.NewLine + "Retrieving data from database...SatZamowienieKlientDaneFirmy" + Environment.NewLine);
                    // Console.WriteLine("Retrieved records:");

                    string ZamowienieIdHashKey, RecordSource, nip, firma_nazwa, firma_imie, firma_nazwisko, firma_adres, firma_adres2, firma_kod, firma_miasto, firma_kraj, firma_telefon, firma_email, ZamowienieKlientDaneFirmyHashDiff;
                    int    ETL_RunId;

                    Dictionary <string, Dictionary <string, string> > temp = new Dictionary <string, Dictionary <string, string> >();

                    //check if there are records
                    if (dr.HasRows)
                    {
                        while (dr.Read())
                        {
                            ZamowienieIdHashKey = dr[0] as string ?? default(string);;
                            ETL_RunId           = dr.GetInt32(1);
                            RecordSource        = dr[4] as string ?? default(string);
                            nip            = dr[5] as string ?? default(string);
                            firma_nazwa    = dr[6] as string ?? default(string);
                            firma_imie     = dr[7] as string ?? default(string);
                            firma_nazwisko = dr[8] as string ?? default(string);
                            firma_adres    = dr[9] as string ?? default(string);
                            firma_adres2   = dr[10] as string ?? default(string);
                            firma_kod      = dr[11] as string ?? default(string);
                            firma_miasto   = dr[12] as string ?? default(string);
                            firma_kraj     = dr[13] as string ?? default(string);
                            firma_telefon  = dr[14] as string ?? default(string);
                            firma_email    = dr[15] as string ?? default(string);
                            ZamowienieKlientDaneFirmyHashDiff = dr[16] as string ?? default(string);
                            Dictionary <string, string> tempin = new Dictionary <string, string>();
                            tempin["ETL_RunId"]      = ETL_RunId.ToString();
                            tempin["RecordSource"]   = RecordSource;
                            tempin["NIP"]            = nip;
                            tempin["firma_nazwa"]    = firma_nazwa;
                            tempin["firma_imie"]     = firma_imie;
                            tempin["firma_nazwisko"] = firma_nazwisko;
                            tempin["firma_adres"]    = firma_adres;
                            tempin["firma_adres2"]   = firma_adres2;
                            tempin["firma_kod"]      = firma_kod;
                            tempin["firma_miasto"]   = firma_miasto;
                            tempin["firma_kraj"]     = firma_kraj;
                            tempin["firma_telefon"]  = firma_telefon;
                            tempin["firma_email"]    = firma_email;
                            tempin["ZamowienieKlientDaneFirmyHashDiff"] = ZamowienieKlientDaneFirmyHashDiff;
                            temp[ZamowienieIdHashKey] = tempin;
                        }
                    }
                    else
                    {
                        Console.WriteLine("No data found.");
                    }

                    //close data reader
                    dr.Close();

                    //close connection
                    conn.Close();
                    return(temp);
                }
            }
            catch (Exception ex)
            {
                //display error message
                Console.WriteLine("Exception: " + ex.Message);
            }
            return(new Dictionary <string, Dictionary <string, string> >());
        }
        public static Dictionary <string, Dictionary <string, string> > PolaczZBazaSatZamowienieKlientAdres()
        {
            //set the connection string
            string connString = conn_string;


            try
            {
                //sql connection object
                using (SqlConnection conn = new SqlConnection(connString))
                {
                    //define the SqlCommand object
                    SqlCommand cmd = new SqlCommand(query_adresy, conn);

                    //open connection
                    conn.Open();

                    //execute the SQLCommand
                    SqlDataReader dr = cmd.ExecuteReader();

                    // Console.WriteLine(Environment.NewLine + "Retrieving data from database...ZamowienieKlientAdres" + Environment.NewLine);
                    // Console.WriteLine("Retrieved records:");

                    string ZamowienieIdHashKey, RecordSource, adres, adres2, kod, miasto, kraj, imie, nazwisko, firma, ZamowienieKlientAdresHashDiff;
                    int    ETL_RunId;
                    Dictionary <string, Dictionary <string, string> > temp = new Dictionary <string, Dictionary <string, string> >();
                    //check if there are records
                    if (dr.HasRows)
                    {
                        while (dr.Read())
                        {
                            ZamowienieIdHashKey = dr[0] as string ?? default(string);
                            ETL_RunId           = dr.GetInt32(1);
                            RecordSource        = dr[4] as string ?? default(string);
                            adres    = dr[5] as string ?? default(string);
                            adres2   = dr[6] as string ?? default(string);
                            kod      = dr[7] as string ?? default(string);
                            miasto   = dr[8] as string ?? default(string);
                            kraj     = dr[9] as string ?? default(string);
                            imie     = dr[10] as string ?? default(string);
                            nazwisko = dr[11] as string ?? default(string);
                            firma    = dr[12] as string ?? default(string);
                            ZamowienieKlientAdresHashDiff = dr.GetString(13);

                            Dictionary <string, string> tempin = new Dictionary <string, string>
                            {
                                ["ETL_RunId"]    = ETL_RunId.ToString(),
                                ["RecordSource"] = RecordSource,
                                ["adres"]        = adres,
                                ["adres2"]       = adres2,
                                ["kod"]          = kod,
                                ["miasto"]       = miasto,
                                ["kraj"]         = kraj,
                                ["imie"]         = imie,
                                ["nazwisko"]     = nazwisko,
                                ["firma"]        = firma,
                                ["ZamowienieKlientAdresHashDiff"] = ZamowienieKlientAdresHashDiff
                            };

                            temp[ZamowienieIdHashKey] = tempin;
                        }
                    }
                    else
                    {
                        Console.WriteLine("No data found.");
                    }

                    //close data reader
                    dr.Close();

                    //close connection
                    conn.Close();
                    return(temp);
                }
            }
            catch (Exception ex)
            {
                //display error message
                Console.WriteLine("Exception: " + ex.Message);
            }

            return(new Dictionary <string, Dictionary <string, string> >());
        }
        public static Dictionary <string, Dictionary <string, string> > PolaczZBazaSatPozycja()
        {
            //set the connection string
            string connString = conn_string;

            try
            {
                //sql connection object
                using (SqlConnection conn = new SqlConnection(connString))
                {
                    //define the SqlCommand object
                    SqlCommand cmd = new SqlCommand(query_pozycja, conn);

                    //open connection
                    conn.Open();

                    //execute the SQLCommand
                    SqlDataReader dr = cmd.ExecuteReader();

                    // Console.WriteLine(Environment.NewLine + "Retrieving data from database...SatPozycja" + Environment.NewLine);
                    // Console.WriteLine("Retrieved records:");

                    string  PozycjaIdHashKey, tytul, RecordSource, cena, vat, cena_netto, PozycjaHashDiff;
                    int     liczba, ETL_RunId;
                    decimal wartosc_vat;
                    Dictionary <string, Dictionary <string, string> > temp = new Dictionary <string, Dictionary <string, string> >();

                    //check if there are records

                    if (dr.HasRows)
                    {
                        while (dr.Read())
                        {
                            PozycjaIdHashKey = dr[0] as string ?? default(string);
                            ETL_RunId        = dr.GetInt32(1) as int? ?? default(int);
                            RecordSource     = dr[4] as string ?? default(string);
                            liczba           = dr.GetInt32(5) as int? ?? default(int);
                            tytul            = dr[6] as string ?? default(string);
                            cena             = dr[7] as string ?? default(string);
                            vat             = dr[8] as string ?? default(string);
                            cena_netto      = dr[9] as string ?? default(string);
                            PozycjaHashDiff = dr[10] as string ?? default(string);
                            wartosc_vat     = dr.GetDecimal(11) as decimal? ?? default(decimal);
                            Dictionary <string, string> tempin = new Dictionary <string, string>();
                            tempin["ETL_RunId"]       = ETL_RunId.ToString();
                            tempin["RecordSource"]    = RecordSource;
                            tempin["Liczba"]          = liczba.ToString();
                            tempin["Tytul"]           = tytul;
                            tempin["Cena"]            = cena;
                            tempin["VAT"]             = vat;
                            tempin["Cena_Netto"]      = cena_netto;
                            tempin["PozycjaHashDiff"] = PozycjaHashDiff;
                            tempin["Wartosc_vat"]     = wartosc_vat.ToString();

                            temp[PozycjaIdHashKey] = tempin;
                        }
                    }
                    else
                    {
                        Console.WriteLine("No data found.");
                    }

                    //close data reader
                    dr.Close();

                    //close connection
                    conn.Close();
                    return(temp);
                }
            }
            catch (Exception ex)
            {
                //display error message
                Console.WriteLine("Exception: " + ex.Message);
            }
            return(null);
        }