| 1 | using System;
|
|---|
| 2 | using System.Collections.Generic;
|
|---|
| 3 | using System.Text;
|
|---|
| 4 | using System.Data.SqlClient;
|
|---|
| 5 | using System.Windows.Forms;
|
|---|
| 6 |
|
|---|
| 7 | namespace BazaZamowien.Classes
|
|---|
| 8 | {
|
|---|
| 9 | class PremieDBBindings
|
|---|
| 10 | {
|
|---|
| 11 |
|
|---|
| 12 | public static void bindujDzialy(ComboBox toolStripComboBox, int IDEGrupy)
|
|---|
| 13 | {
|
|---|
| 14 | SqlCommand command = new SqlCommand();
|
|---|
| 15 | command.Connection = new SqlConnection(ConnString.getConnString().PremieConnStr);
|
|---|
| 16 |
|
|---|
| 17 | command.CommandText = "SELECT Dzialy.IDE, Dzialy.Dzial FROM Dzialy LEFT OUTER JOIN GrupaDzial " +
|
|---|
| 18 | " ON Dzialy.IDE = GrupaDzial.IDEDzial WHERE (GrupaDzial.IDEGrupy = @param) ORDER BY Dzialy.Dzial";
|
|---|
| 19 | command.Parameters.AddWithValue("@param", IDEGrupy);
|
|---|
| 20 | command.Connection.Open();
|
|---|
| 21 |
|
|---|
| 22 | SqlDataReader reader = command.ExecuteReader();
|
|---|
| 23 |
|
|---|
| 24 | if (reader.HasRows)
|
|---|
| 25 | {
|
|---|
| 26 | while (reader.Read())
|
|---|
| 27 | {
|
|---|
| 28 | toolStripComboBox.Items.Add(new BoundItem((int)reader.GetValue(0), reader.GetValue(1).ToString()));
|
|---|
| 29 | }
|
|---|
| 30 | }
|
|---|
| 31 | command.Connection.Close();
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | public static void bindujPracownikow(ComboBox toolStripComboBox, int IDEGrupy)
|
|---|
| 37 | {
|
|---|
| 38 | SqlCommand command = new SqlCommand();
|
|---|
| 39 | command.Connection = new SqlConnection(ConnString.getConnString().PremieConnStr);
|
|---|
| 40 |
|
|---|
| 41 | command.CommandText = "select distinct IdePracownik,Pracownik from dbo.PODWLADNOSC where ideDzial in " +
|
|---|
| 42 | "(select IDEDzial from dbo.GrupaDzial where IDEGrupy = " + IDEGrupy + ")";
|
|---|
| 43 |
|
|---|
| 44 | if (User.getUser().IDEDzialuCT == 8){
|
|---|
| 45 | command.CommandText += " AND IDEoddzial IN (select IDEOddzial from dbo.Kierownicy WHERE IDEPracownik=" + User.getUser().IDE_CT + ")";
|
|---|
| 46 | }
|
|---|
| 47 |
|
|---|
| 48 | command.CommandText += " order by Pracownik";
|
|---|
| 49 | command.Connection.Open();
|
|---|
| 50 |
|
|---|
| 51 | SqlDataReader reader = command.ExecuteReader();
|
|---|
| 52 |
|
|---|
| 53 | if (reader.HasRows)
|
|---|
| 54 | {
|
|---|
| 55 | while (reader.Read())
|
|---|
| 56 | {
|
|---|
| 57 | toolStripComboBox.Items.Add(new BoundItem((int)reader.GetValue(0), reader.GetValue(1).ToString()));
|
|---|
| 58 | }
|
|---|
| 59 | }
|
|---|
| 60 | command.Connection.Close();
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | } |
|---|