| 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 ZamowieniaDBBindings
|
|---|
| 10 | {
|
|---|
| 11 |
|
|---|
| 12 | public static void bindujDzialy(ToolStripComboBox toolStripComboBox, int userIDE)
|
|---|
| 13 | {
|
|---|
| 14 | SqlCommand command = new SqlCommand();
|
|---|
| 15 | command.Connection = new SqlConnection(ConnString.getConnString().ZamowieniaConnStr);
|
|---|
| 16 |
|
|---|
| 17 | command.CommandText = "SELECT Dzialy.IDE, Dzialy.Symbol, Dzialy.Roz, Dzialy.Opis FROM Dzialy LEFT OUTER JOIN ";
|
|---|
| 18 | command.CommandText += "UsersDzialy ON Dzialy.IDE = UsersDzialy.IDEDzial WHERE (UsersDzialy.IDEUser = @param) ";
|
|---|
| 19 | command.CommandText += "ORDER BY Dzialy.Symbol";
|
|---|
| 20 | command.Parameters.AddWithValue("@param", userIDE);
|
|---|
| 21 | command.Connection.Open();
|
|---|
| 22 |
|
|---|
| 23 | SqlDataReader reader = command.ExecuteReader();
|
|---|
| 24 |
|
|---|
| 25 | if (reader.HasRows)
|
|---|
| 26 | {
|
|---|
| 27 | while (reader.Read())
|
|---|
| 28 | {
|
|---|
| 29 | toolStripComboBox.Items.Add(new BoundItem((int)reader.GetValue(0), reader.GetValue(1).ToString()));
|
|---|
| 30 | }
|
|---|
| 31 | }
|
|---|
| 32 | command.Connection.Close();
|
|---|
| 33 | }
|
|---|
| 34 |
|
|---|
| 35 | public static void bindujDzialyAll(ToolStripComboBox toolStripComboBox)
|
|---|
| 36 | {
|
|---|
| 37 | SqlCommand command = new SqlCommand();
|
|---|
| 38 | command.Connection = new SqlConnection(ConnString.getConnString().ZamowieniaConnStr);
|
|---|
| 39 |
|
|---|
| 40 | command.CommandText = "SELECT Dzialy.IDE, Dzialy.Symbol, Dzialy.Roz, Dzialy.Opis FROM Dzialy ";
|
|---|
| 41 | command.CommandText += "ORDER BY Dzialy.Symbol";
|
|---|
| 42 | command.Connection.Open();
|
|---|
| 43 |
|
|---|
| 44 | SqlDataReader reader = command.ExecuteReader();
|
|---|
| 45 |
|
|---|
| 46 | if (reader.HasRows)
|
|---|
| 47 | {
|
|---|
| 48 | while (reader.Read())
|
|---|
| 49 | {
|
|---|
| 50 | toolStripComboBox.Items.Add(new BoundItem((int)reader.GetValue(0), reader.GetValue(1).ToString()));
|
|---|
| 51 | }
|
|---|
| 52 | }
|
|---|
| 53 | command.Connection.Close();
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|
| 56 | }
|
|---|
| 57 | }
|
|---|