| 1 | using System;
|
|---|
| 2 | using System.Collections.Generic;
|
|---|
| 3 | using System.Text;
|
|---|
| 4 | using System.Data;
|
|---|
| 5 | using System.Data.SqlClient;
|
|---|
| 6 |
|
|---|
| 7 | using System.Windows.Forms;
|
|---|
| 8 |
|
|---|
| 9 | namespace Baza_Reklam
|
|---|
| 10 | {
|
|---|
| 11 | class DBBindings
|
|---|
| 12 | {
|
|---|
| 13 | public static void bindujTytuly(ToolStripComboBox toolStripComboBox)
|
|---|
| 14 | {
|
|---|
| 15 | SqlCommand command = new SqlCommand();
|
|---|
| 16 | command.Connection = new SqlConnection(ConnString.getConnString().Value);
|
|---|
| 17 |
|
|---|
| 18 | command.CommandText = "select SYMB from [LISTA TYTU£ÓW] where st_aktywny=-1";
|
|---|
| 19 | command.Connection.Open();
|
|---|
| 20 |
|
|---|
| 21 | SqlDataReader reader = command.ExecuteReader();
|
|---|
| 22 |
|
|---|
| 23 | if (reader.HasRows)
|
|---|
| 24 | {
|
|---|
| 25 | while (reader.Read())
|
|---|
| 26 | {
|
|---|
| 27 | toolStripComboBox.Items.Add(reader.GetValue(0).ToString());
|
|---|
| 28 | }
|
|---|
| 29 | }
|
|---|
| 30 | command.Connection.Close();
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | public static void bindujTytuly2(ToolStripComboBox toolStripComboBox)
|
|---|
| 34 | {
|
|---|
| 35 | SqlCommand command = new SqlCommand();
|
|---|
| 36 | command.Connection = new SqlConnection(ConnString.getConnString().Value);
|
|---|
| 37 |
|
|---|
| 38 | command.CommandText = "select id,SYMB from [LISTA TYTU£ÓW] where st_aktywny=-1";
|
|---|
| 39 | command.Connection.Open();
|
|---|
| 40 |
|
|---|
| 41 | SqlDataReader reader = command.ExecuteReader();
|
|---|
| 42 |
|
|---|
| 43 | if (reader.HasRows)
|
|---|
| 44 | {
|
|---|
| 45 | while (reader.Read())
|
|---|
| 46 | {
|
|---|
| 47 | toolStripComboBox.Items.Add(new BoundItem(Convert.ToInt32(reader.GetValue(0))
|
|---|
| 48 | ,reader.GetValue(1).ToString()));
|
|---|
| 49 | }
|
|---|
| 50 | }
|
|---|
| 51 | command.Connection.Close();
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 | public static void bindujTypyReklam(ToolStripComboBox toolStripComboBox)
|
|---|
| 55 | {
|
|---|
| 56 | /*
|
|---|
| 57 | SLOWNIKDataSetTableAdapters.LISTA_TYPOW_REKLAMYTableAdapter ta =
|
|---|
| 58 | new SLOWNIKDataSetTableAdapters.LISTA_TYPOW_REKLAMYTableAdapter();
|
|---|
| 59 |
|
|---|
| 60 | ta.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 61 |
|
|---|
| 62 | ((ComboBox)toolStripComboBox.Control).DataSource = ta.GetData();
|
|---|
| 63 | ((ComboBox)toolStripComboBox.Control).DisplayMember = "SYMB";
|
|---|
| 64 | ((ComboBox)toolStripComboBox.Control).ValueMember = "SYMB";
|
|---|
| 65 | toolStripComboBox.SelectedIndex = -1;
|
|---|
| 66 | */
|
|---|
| 67 |
|
|---|
| 68 | SqlCommand command = new SqlCommand();
|
|---|
| 69 | command.Connection = new SqlConnection(ConnString.getConnString().Value);
|
|---|
| 70 |
|
|---|
| 71 | command.CommandText = "SELECT SYMB FROM [LISTA TYPÓW REKLAMY]";
|
|---|
| 72 | command.Connection.Open();
|
|---|
| 73 |
|
|---|
| 74 | SqlDataReader reader = command.ExecuteReader();
|
|---|
| 75 |
|
|---|
| 76 | if (reader.HasRows)
|
|---|
| 77 | {
|
|---|
| 78 | while (reader.Read())
|
|---|
| 79 | {
|
|---|
| 80 | toolStripComboBox.Items.Add(reader.GetValue(0).ToString());
|
|---|
| 81 | }
|
|---|
| 82 | }
|
|---|
| 83 | command.Connection.Close();
|
|---|
| 84 | }
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 | public static void bindujGrzbiety(ToolStripComboBox toolStripComboBox)
|
|---|
| 88 | {
|
|---|
| 89 | SLOWNIKDataSetTableAdapters.GRZBIETYTableAdapter ta =
|
|---|
| 90 | new SLOWNIKDataSetTableAdapters.GRZBIETYTableAdapter();
|
|---|
| 91 |
|
|---|
| 92 | ta.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 93 |
|
|---|
| 94 | ((ComboBox)toolStripComboBox.Control).DataSource = ta.GetData();
|
|---|
| 95 | ((ComboBox)toolStripComboBox.Control).DisplayMember = "Nazwa";
|
|---|
| 96 | ((ComboBox)toolStripComboBox.Control).ValueMember = "ID";
|
|---|
| 97 | toolStripComboBox.SelectedIndex = -1;
|
|---|
| 98 | }
|
|---|
| 99 |
|
|---|
| 100 | public static void bindujGrzbiety2(ToolStripComboBox toolStripComboBox)
|
|---|
| 101 | {
|
|---|
| 102 | SqlCommand command = new SqlCommand();
|
|---|
| 103 | command.Connection = new SqlConnection(ConnString.getConnString().Value);
|
|---|
| 104 |
|
|---|
| 105 | command.CommandText = "SELECT id,Nazwa FROM GRZBIETY";
|
|---|
| 106 | command.Connection.Open();
|
|---|
| 107 |
|
|---|
| 108 | SqlDataReader reader = command.ExecuteReader();
|
|---|
| 109 |
|
|---|
| 110 | if (reader.HasRows)
|
|---|
| 111 | {
|
|---|
| 112 | while (reader.Read())
|
|---|
| 113 | {
|
|---|
| 114 | toolStripComboBox.Items.Add(new BoundItem(reader.GetInt32(0),reader.GetString(1)));
|
|---|
| 115 | }
|
|---|
| 116 | }
|
|---|
| 117 | command.Connection.Close();
|
|---|
| 118 | }
|
|---|
| 119 |
|
|---|
| 120 | public static void bindujAgencje(ToolStripComboBox toolStripComboBox)
|
|---|
| 121 | {
|
|---|
| 122 | /*
|
|---|
| 123 | SLOWNIKDataSetTableAdapters.AGENCJETableAdapter ta =
|
|---|
| 124 | new SLOWNIKDataSetTableAdapters.AGENCJETableAdapter();
|
|---|
| 125 |
|
|---|
| 126 | ta.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 127 |
|
|---|
| 128 | ((ComboBox)toolStripComboBox.Control).DataSource = ta.GetData();
|
|---|
| 129 | ((ComboBox)toolStripComboBox.Control).DisplayMember = "Symbol";
|
|---|
| 130 | ((ComboBox)toolStripComboBox.Control).ValueMember = "Id_agencji";
|
|---|
| 131 | toolStripComboBox.SelectedIndex = -1;
|
|---|
| 132 | * */
|
|---|
| 133 |
|
|---|
| 134 | SqlCommand command = new SqlCommand();
|
|---|
| 135 | command.Connection = new SqlConnection(ConnString.getConnString().Value);
|
|---|
| 136 |
|
|---|
| 137 | command.CommandText = "select Symbol from dbo.AGENCJE where aktywna = 1 order by Symbol";
|
|---|
| 138 | command.Connection.Open();
|
|---|
| 139 |
|
|---|
| 140 | SqlDataReader reader = command.ExecuteReader();
|
|---|
| 141 |
|
|---|
| 142 | if (reader.HasRows)
|
|---|
| 143 | {
|
|---|
| 144 | while (reader.Read())
|
|---|
| 145 | {
|
|---|
| 146 | toolStripComboBox.Items.Add(reader.GetValue(0).ToString());
|
|---|
| 147 | }
|
|---|
| 148 | }
|
|---|
| 149 | command.Connection.Close();
|
|---|
| 150 |
|
|---|
| 151 | }
|
|---|
| 152 |
|
|---|
| 153 | //Przez BindingSource by bylo filtrowanie
|
|---|
| 154 | public static void bindujAgentow(ToolStripComboBox toolStripComboBox)
|
|---|
| 155 | {
|
|---|
| 156 | /*
|
|---|
| 157 | SLOWNIKDataSetTableAdapters.AGENCITableAdapter ta =
|
|---|
| 158 | new SLOWNIKDataSetTableAdapters.AGENCITableAdapter();
|
|---|
| 159 |
|
|---|
| 160 | ta.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 161 |
|
|---|
| 162 | BindingSource bs = new BindingSource();
|
|---|
| 163 | bs.DataSource = ta.GetDataByAktywny();
|
|---|
| 164 | ((ComboBox)toolStripComboBox.Control).DataSource = bs;
|
|---|
| 165 | ((ComboBox)toolStripComboBox.Control).DisplayMember = "Symbol";
|
|---|
| 166 | ((ComboBox)toolStripComboBox.Control).ValueMember = "Id_agenta";
|
|---|
| 167 | toolStripComboBox.SelectedIndex = -1;
|
|---|
| 168 | * */
|
|---|
| 169 |
|
|---|
| 170 | SqlCommand command = new SqlCommand();
|
|---|
| 171 | command.Connection = new SqlConnection(ConnString.getConnString().Value);
|
|---|
| 172 |
|
|---|
| 173 | command.CommandText = "select Symbol from dbo.AGENCI where aktywny=1 order by Symbol";
|
|---|
| 174 | command.Connection.Open();
|
|---|
| 175 |
|
|---|
| 176 | SqlDataReader reader = command.ExecuteReader();
|
|---|
| 177 |
|
|---|
| 178 | if (reader.HasRows)
|
|---|
| 179 | {
|
|---|
| 180 | while (reader.Read())
|
|---|
| 181 | {
|
|---|
| 182 | toolStripComboBox.Items.Add(reader.GetValue(0).ToString());
|
|---|
| 183 | }
|
|---|
| 184 | }
|
|---|
| 185 | command.Connection.Close();
|
|---|
| 186 | }
|
|---|
| 187 |
|
|---|
| 188 | //Przez BindingSource by bylo filtrowanie
|
|---|
| 189 | public static void bindujModuly(ToolStripComboBox toolStripComboBox)
|
|---|
| 190 | {
|
|---|
| 191 |
|
|---|
| 192 | SLOWNIKDataSetTableAdapters.NAZWY_MODULOWTableAdapter ta =
|
|---|
| 193 | new SLOWNIKDataSetTableAdapters.NAZWY_MODULOWTableAdapter();
|
|---|
| 194 |
|
|---|
| 195 | ta.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 196 |
|
|---|
| 197 | BindingSource bs2 = new BindingSource();
|
|---|
| 198 | bs2.DataSource = ta.GetData();
|
|---|
| 199 | ((ComboBox)toolStripComboBox.Control).DataSource = bs2;
|
|---|
| 200 | ((ComboBox)toolStripComboBox.Control).DisplayMember = "MOD_TYP";
|
|---|
| 201 | ((ComboBox)toolStripComboBox.Control).ValueMember = "MOD_TYP";
|
|---|
| 202 | toolStripComboBox.SelectedIndex = -1;
|
|---|
| 203 |
|
|---|
| 204 | /*
|
|---|
| 205 | SqlCommand command = new SqlCommand();
|
|---|
| 206 | command.Connection = new SqlConnection(ConnString.getConnString().Value);
|
|---|
| 207 |
|
|---|
| 208 | command.CommandText = "select Symbol from dbo.AGENCI where aktywny=1 order by Symbol";
|
|---|
| 209 | command.Connection.Open();
|
|---|
| 210 |
|
|---|
| 211 | SqlDataReader reader = command.ExecuteReader();
|
|---|
| 212 |
|
|---|
| 213 | if (reader.HasRows)
|
|---|
| 214 | {
|
|---|
| 215 | while (reader.Read())
|
|---|
| 216 | {
|
|---|
| 217 | toolStripComboBox.Items.Add(reader.GetValue(0).ToString());
|
|---|
| 218 | }
|
|---|
| 219 | }
|
|---|
| 220 | command.Connection.Close(); */
|
|---|
| 221 | }
|
|---|
| 222 |
|
|---|
| 223 | ///////////////////////////////////////////////////////////////////////////////////
|
|---|
| 224 |
|
|---|
| 225 | public static void dodajAgencjeDoWezla(TreeNode node)
|
|---|
| 226 | {
|
|---|
| 227 | node.Nodes.Clear();
|
|---|
| 228 | SqlCommand command = new SqlCommand();
|
|---|
| 229 | command.Connection = new SqlConnection(ConnString.getConnString().Value);
|
|---|
| 230 |
|
|---|
| 231 | command.CommandText = "select ID_AGENCJI,Symbol from dbo.AGENCJE where aktywna = 1";
|
|---|
| 232 | command.Connection.Open();
|
|---|
| 233 |
|
|---|
| 234 | SqlDataReader reader = command.ExecuteReader();
|
|---|
| 235 |
|
|---|
| 236 | TreeNode newNode;
|
|---|
| 237 |
|
|---|
| 238 | while (reader.Read())
|
|---|
| 239 | {
|
|---|
| 240 | newNode = new TreeNode(reader.GetValue(1).ToString());
|
|---|
| 241 | newNode.Name = reader.GetValue(0).ToString();
|
|---|
| 242 | newNode.Nodes.Add(new TreeNode());
|
|---|
| 243 | node.Nodes.Add(newNode);
|
|---|
| 244 | }
|
|---|
| 245 |
|
|---|
| 246 | command.Connection.Close();
|
|---|
| 247 | }
|
|---|
| 248 |
|
|---|
| 249 | public static void dodajAgentowDoWezla(TreeNode node, string idAgencji)
|
|---|
| 250 | {
|
|---|
| 251 | node.Nodes.Clear();
|
|---|
| 252 | SqlCommand command = new SqlCommand();
|
|---|
| 253 | command.Connection = new SqlConnection(ConnString.getConnString().Value);
|
|---|
| 254 |
|
|---|
| 255 | command.CommandText = "select Symbol from dbo.AGENCI where aktywny=1 and ID_AGENCJI=@param order by Symbol";
|
|---|
| 256 | command.Parameters.AddWithValue("@param", idAgencji);
|
|---|
| 257 | command.Connection.Open();
|
|---|
| 258 |
|
|---|
| 259 | SqlDataReader reader = command.ExecuteReader();
|
|---|
| 260 | TreeNode newNode;
|
|---|
| 261 |
|
|---|
| 262 | while (reader.Read())
|
|---|
| 263 | {
|
|---|
| 264 | newNode = new TreeNode(reader.GetValue(0).ToString());
|
|---|
| 265 | newNode.Name = reader.GetValue(0).ToString();
|
|---|
| 266 | node.Nodes.Add(newNode);
|
|---|
| 267 | }
|
|---|
| 268 |
|
|---|
| 269 | command.Connection.Close();
|
|---|
| 270 | }
|
|---|
| 271 |
|
|---|
| 272 | public static void dodajTytulyDoWezla(TreeNode node)
|
|---|
| 273 | {
|
|---|
| 274 | node.Nodes.Clear();
|
|---|
| 275 | SqlCommand command = new SqlCommand();
|
|---|
| 276 | command.Connection = new SqlConnection(ConnString.getConnString().Value);
|
|---|
| 277 |
|
|---|
| 278 | command.CommandText = "select id, SYMB from [LISTA TYTU£ÓW] where st_aktywny=-1";
|
|---|
| 279 | command.Connection.Open();
|
|---|
| 280 |
|
|---|
| 281 | SqlDataReader reader = command.ExecuteReader();
|
|---|
| 282 | TreeNode newNode;
|
|---|
| 283 |
|
|---|
| 284 | while (reader.Read())
|
|---|
| 285 | {
|
|---|
| 286 | newNode = new TreeNode(reader.GetValue(1).ToString());
|
|---|
| 287 | newNode.Name = reader.GetValue(1).ToString();
|
|---|
| 288 | newNode.Nodes.Add(new TreeNode());
|
|---|
| 289 | node.Nodes.Add(newNode);
|
|---|
| 290 | }
|
|---|
| 291 |
|
|---|
| 292 | command.Connection.Close();
|
|---|
| 293 | }
|
|---|
| 294 |
|
|---|
| 295 | public static void dodajKlasyfikacjePoziom1(TreeView treeView)
|
|---|
| 296 | {
|
|---|
| 297 | treeView.Nodes.Clear();
|
|---|
| 298 | SqlCommand command = new SqlCommand();
|
|---|
| 299 | command.Connection = new SqlConnection(ConnString.getConnString().Value);
|
|---|
| 300 |
|
|---|
| 301 | command.CommandText = "select KL_1,ID_KL_1 from dbo.KL_1 order by KL_1";
|
|---|
| 302 |
|
|---|
| 303 | TreeNode newNode;
|
|---|
| 304 | command.Connection.Open();
|
|---|
| 305 |
|
|---|
| 306 | SqlDataReader reader = command.ExecuteReader();
|
|---|
| 307 |
|
|---|
| 308 | while (reader.Read())
|
|---|
| 309 | {
|
|---|
| 310 | newNode = new TreeNode(reader.GetValue(0).ToString());
|
|---|
| 311 | newNode.Name = reader.GetValue(1).ToString();
|
|---|
| 312 | newNode.Nodes.Add(new TreeNode());
|
|---|
| 313 | treeView.Nodes.Add(newNode);
|
|---|
| 314 | }
|
|---|
| 315 |
|
|---|
| 316 | command.Connection.Close();
|
|---|
| 317 | }
|
|---|
| 318 |
|
|---|
| 319 | public static void bindujDatyWydan(TreeNode node)
|
|---|
| 320 | {
|
|---|
| 321 | node.Nodes.Clear();
|
|---|
| 322 | SqlCommand command = new SqlCommand();
|
|---|
| 323 | command.Connection = new SqlConnection(ConnString.getConnString().Value);
|
|---|
| 324 |
|
|---|
| 325 | command.CommandText = "select distinct datepart(year,DATA_W) as rok from dbo.NR where datepart(year,DATA_W) is not null order by rok desc";
|
|---|
| 326 |
|
|---|
| 327 | TreeNode newNode;
|
|---|
| 328 | command.Connection.Open();
|
|---|
| 329 |
|
|---|
| 330 | SqlDataReader reader = command.ExecuteReader();
|
|---|
| 331 |
|
|---|
| 332 | while (reader.Read())
|
|---|
| 333 | {
|
|---|
| 334 | newNode = new TreeNode(reader.GetValue(0).ToString());
|
|---|
| 335 | newNode.Name = reader.GetValue(0).ToString();
|
|---|
| 336 |
|
|---|
| 337 | for (int i = 12; i >= 1; i--)
|
|---|
| 338 | {
|
|---|
| 339 | TreeNode node2 = new TreeNode(i.ToString());
|
|---|
| 340 | node2.Name = i.ToString();
|
|---|
| 341 | //node2.Nodes.Add(new TreeNode());
|
|---|
| 342 | newNode.Nodes.Add(node2);
|
|---|
| 343 | }
|
|---|
| 344 | node.Nodes.Add(node);
|
|---|
| 345 | }
|
|---|
| 346 |
|
|---|
| 347 | command.Connection.Close();
|
|---|
| 348 | }
|
|---|
| 349 |
|
|---|
| 350 | public static void dodajKlasyfikacjePoziom1(TreeNode node)
|
|---|
| 351 | {
|
|---|
| 352 | node.Nodes.Clear();
|
|---|
| 353 | SqlCommand command = new SqlCommand();
|
|---|
| 354 | command.Connection = new SqlConnection(ConnString.getConnString().Value);
|
|---|
| 355 |
|
|---|
| 356 | command.CommandText = "select KL_1,ID_KL_1 from dbo.KL_1 order by KL_1";
|
|---|
| 357 |
|
|---|
| 358 | TreeNode newNode;
|
|---|
| 359 | command.Connection.Open();
|
|---|
| 360 |
|
|---|
| 361 | SqlDataReader reader = command.ExecuteReader();
|
|---|
| 362 |
|
|---|
| 363 | while (reader.Read())
|
|---|
| 364 | {
|
|---|
| 365 | newNode = new TreeNode(reader.GetValue(0).ToString());
|
|---|
| 366 | newNode.Name = reader.GetValue(1).ToString();
|
|---|
| 367 | newNode.Nodes.Add(new TreeNode());
|
|---|
| 368 | node.Nodes.Add(newNode);
|
|---|
| 369 | }
|
|---|
| 370 |
|
|---|
| 371 | command.Connection.Close();
|
|---|
| 372 | }
|
|---|
| 373 |
|
|---|
| 374 | public static void dodajKlasyfikacjePoziom2(TreeNode node)
|
|---|
| 375 | {
|
|---|
| 376 | node.Nodes.Clear();
|
|---|
| 377 | SqlCommand command = new SqlCommand();
|
|---|
| 378 | command.Connection = new SqlConnection(ConnString.getConnString().Value);
|
|---|
| 379 |
|
|---|
| 380 | command.CommandText = "select KL_2,ID_KL_2 from dbo.KL_2 where ID_KL_1=@param order by KL_2";
|
|---|
| 381 | command.Parameters.Clear();
|
|---|
| 382 | command.Parameters.AddWithValue("@param", node.Name);
|
|---|
| 383 |
|
|---|
| 384 | TreeNode newNode;
|
|---|
| 385 | command.Connection.Open();
|
|---|
| 386 |
|
|---|
| 387 | SqlDataReader reader = command.ExecuteReader();
|
|---|
| 388 |
|
|---|
| 389 | while (reader.Read())
|
|---|
| 390 | {
|
|---|
| 391 | newNode = new TreeNode(reader.GetValue(0).ToString());
|
|---|
| 392 | newNode.Name = reader.GetValue(1).ToString();
|
|---|
| 393 | newNode.Nodes.Add(new TreeNode());
|
|---|
| 394 | node.Nodes.Add(newNode);
|
|---|
| 395 | }
|
|---|
| 396 |
|
|---|
| 397 | command.Connection.Close();
|
|---|
| 398 | }
|
|---|
| 399 |
|
|---|
| 400 | public static void dodajKlasyfikacjePoziom3(TreeNode node)
|
|---|
| 401 | {
|
|---|
| 402 | node.Nodes.Clear();
|
|---|
| 403 | SqlCommand command = new SqlCommand();
|
|---|
| 404 | command.Connection = new SqlConnection(ConnString.getConnString().Value);
|
|---|
| 405 |
|
|---|
| 406 | command.CommandText = "select KL_3,ID_KL_3 from dbo.KL_3 where ID_KL_1=@param1 and ID_KL_2=@param2 order by KL_3";
|
|---|
| 407 | command.Parameters.Clear();
|
|---|
| 408 | command.Parameters.AddWithValue("@param1", node.Parent.Name);
|
|---|
| 409 | command.Parameters.AddWithValue("@param2", node.Name);
|
|---|
| 410 |
|
|---|
| 411 | TreeNode newNode;
|
|---|
| 412 | command.Connection.Open();
|
|---|
| 413 |
|
|---|
| 414 | SqlDataReader reader = command.ExecuteReader();
|
|---|
| 415 |
|
|---|
| 416 | while (reader.Read())
|
|---|
| 417 | {
|
|---|
| 418 | newNode = new TreeNode(reader.GetValue(0).ToString());
|
|---|
| 419 | newNode.Name = reader.GetValue(1).ToString();
|
|---|
| 420 | node.Nodes.Add(newNode);
|
|---|
| 421 | }
|
|---|
| 422 |
|
|---|
| 423 | command.Connection.Close();
|
|---|
| 424 | }
|
|---|
| 425 |
|
|---|
| 426 | }
|
|---|
| 427 | }
|
|---|