| 1 | using System;
|
|---|
| 2 | using System.Collections.Generic;
|
|---|
| 3 | using System.ComponentModel;
|
|---|
| 4 | using System.Data;
|
|---|
| 5 | using System.Data.SqlClient;
|
|---|
| 6 | using System.Drawing;
|
|---|
| 7 | using System.Windows.Forms;
|
|---|
| 8 | using System.IO;
|
|---|
| 9 | using System.Text;
|
|---|
| 10 | using Baza_Reklam.Classes;
|
|---|
| 11 |
|
|---|
| 12 | namespace Baza_Reklam
|
|---|
| 13 | {
|
|---|
| 14 | public partial class ProductionForm : Form
|
|---|
| 15 | {
|
|---|
| 16 | //Nr wydañ wg których generowane s¹ listy do klientów
|
|---|
| 17 | private static ProductionForm productionForm;
|
|---|
| 18 | private SqlCommand command;
|
|---|
| 19 | private short nrAMT;
|
|---|
| 20 | private short nrGS1;
|
|---|
| 21 | private short nrGS2;
|
|---|
| 22 | private short nrWyd;
|
|---|
| 23 |
|
|---|
| 24 | private string query = "select * from dbo.PRODUKCJA where 1=1 ";
|
|---|
| 25 |
|
|---|
| 26 | //zapytanie wybieraj¹ce projekty bêd¹ce w stanie produkcji
|
|---|
| 27 | private string queryDzisiaj;
|
|---|
| 28 |
|
|---|
| 29 | private SqlDataAdapter sqlDataAdapter;
|
|---|
| 30 | private string tyt;
|
|---|
| 31 |
|
|---|
| 32 | private ProductionForm(MDIBazaReklam parent)
|
|---|
| 33 | {
|
|---|
| 34 | InitializeComponent();
|
|---|
| 35 |
|
|---|
| 36 | MdiParent = parent;
|
|---|
| 37 |
|
|---|
| 38 | gRZBIETYTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 39 | aGENCJETableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 40 | aGENCITableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 41 | lISTA_TYTULOWTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 42 | reklamaTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 43 | pRODUKCJATableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 44 | listaReklamDoWydaniaNrTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 45 | aGENCJETableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 46 | aGENCITableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 47 | listyTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 48 | listyPodsumowanieTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 49 | klienciTableAdapter1.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 50 |
|
|---|
| 51 | zwrotToolStripButton.Enabled = false;
|
|---|
| 52 | doDTPToolStripButton.Enabled = false;
|
|---|
| 53 | proToolStripButton.Enabled = false;
|
|---|
| 54 | doKorektyToolStripButton.Enabled = false;
|
|---|
| 55 | doDTP2ToolStripButton.Enabled = false;
|
|---|
| 56 | doKorekty2ToolStripButton.Enabled = false;
|
|---|
| 57 | doAgentaToolStripButton.Enabled = false;
|
|---|
| 58 |
|
|---|
| 59 | produkcjaDataGridView.Sort(zAMAWIAMNADataGridViewTextBoxColumn, ListSortDirection.Descending);
|
|---|
| 60 |
|
|---|
| 61 | queryDzisiaj = buildQuery();
|
|---|
| 62 |
|
|---|
| 63 | uprawnienia();
|
|---|
| 64 |
|
|---|
| 65 | nrAMTToolStripTextBox.Text = Global.getGlobal().NrAMT.ToString();
|
|---|
| 66 | nrGS1ToolStripTextBox.Text = Global.getGlobal().NrGS1.ToString();
|
|---|
| 67 | nrGS2ToolStripTextBox.Text = Global.getGlobal().NrGS2.ToString();
|
|---|
| 68 |
|
|---|
| 69 | dateTimePicker1.Value = DateTime.Today;
|
|---|
| 70 |
|
|---|
| 71 | if (!ConnString.getConnString().Value.Contains("truck"))
|
|---|
| 72 | {
|
|---|
| 73 | //w Sampressie w tej kolumnie jest zapisana wersja jêzykowa projektu/ w bazie CT niewykorzystywane
|
|---|
| 74 | szkic.Visible = false;
|
|---|
| 75 | }
|
|---|
| 76 | }
|
|---|
| 77 |
|
|---|
| 78 | public static ProductionForm getProductionForm(MDIBazaReklam parent)
|
|---|
| 79 | {
|
|---|
| 80 | if (productionForm == null)
|
|---|
| 81 | {
|
|---|
| 82 | productionForm = new ProductionForm(parent);
|
|---|
| 83 | }
|
|---|
| 84 | return productionForm;
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | private void ProductionForm_Load(object sender, EventArgs e)
|
|---|
| 88 | {
|
|---|
| 89 | aGENCJETableAdapter.Fill(sLOWNIKDataSet.AGENCJE);
|
|---|
| 90 | aGENCITableAdapter.Fill(sLOWNIKDataSet.AGENCI);
|
|---|
| 91 | gRZBIETYTableAdapter.Fill(sLOWNIKDataSet.GRZBIETY);
|
|---|
| 92 | lISTA_TYTULOWTableAdapter.Fill(sLOWNIKDataSet.LISTA_TYTULOW);
|
|---|
| 93 |
|
|---|
| 94 | tytulComboBox.SelectedIndex = 1;
|
|---|
| 95 | tytulComboBox.SelectedIndex = 0;
|
|---|
| 96 |
|
|---|
| 97 | SqlConnection conn = new SqlConnection(ConnString.getConnString().Value);
|
|---|
| 98 | sqlDataAdapter = new SqlDataAdapter();
|
|---|
| 99 | command = new SqlCommand();
|
|---|
| 100 | command.CommandText = queryDzisiaj;
|
|---|
| 101 | command.CommandType = CommandType.Text;
|
|---|
| 102 | command.Connection = conn;
|
|---|
| 103 |
|
|---|
| 104 | sqlDataAdapter.SelectCommand = command;
|
|---|
| 105 | sqlDataAdapter.Fill(rEKLAMADataSet.PRODUKCJA);
|
|---|
| 106 | }
|
|---|
| 107 |
|
|---|
| 108 | private void dataGridView1_SelectionChanged(object sender, EventArgs e)
|
|---|
| 109 | {
|
|---|
| 110 | if (pRODUKCJABindingSource.Current != null)
|
|---|
| 111 | {
|
|---|
| 112 | DataRowView row = (DataRowView) pRODUKCJABindingSource.Current;
|
|---|
| 113 | plikToolStripTextBox.Text = Convert.ToString(row["PLIK"]);
|
|---|
| 114 | }
|
|---|
| 115 |
|
|---|
| 116 | zablokujButtony();
|
|---|
| 117 | }
|
|---|
| 118 |
|
|---|
| 119 | private void zwrotToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 120 | {
|
|---|
| 121 | if (pRODUKCJABindingSource.Current != null)
|
|---|
| 122 | {
|
|---|
| 123 | wylaczSortowanieGrida();
|
|---|
| 124 |
|
|---|
| 125 | DataRowView row = (DataRowView) pRODUKCJABindingSource.Current;
|
|---|
| 126 | row["PRODUKCJA"] = User.getUser().Login;
|
|---|
| 127 | row["DATA_PRODUKCJA"] = DateTime.Now;
|
|---|
| 128 | // na koncu,bo moze byc sortowanie po stanie
|
|---|
| 129 | row["stan"] = "ZWROT Z PRODUKCJI";
|
|---|
| 130 | pRODUKCJABindingSource.EndEdit();
|
|---|
| 131 | pRODUKCJATableAdapter.Update(rEKLAMADataSet.PRODUKCJA);
|
|---|
| 132 |
|
|---|
| 133 | zablokujButtony();
|
|---|
| 134 | wlaczSortowanieGrida();
|
|---|
| 135 | }
|
|---|
| 136 | }
|
|---|
| 137 |
|
|---|
| 138 | private void doDTPToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 139 | {
|
|---|
| 140 | if (pRODUKCJABindingSource.Current != null)
|
|---|
| 141 | {
|
|---|
| 142 | wylaczSortowanieGrida();
|
|---|
| 143 |
|
|---|
| 144 | DataRowView row = (DataRowView) pRODUKCJABindingSource.Current;
|
|---|
| 145 | row["PRODUKCJA"] = User.getUser().Login;
|
|---|
| 146 | row["DATA_PRODUKCJA"] = DateTime.Now;
|
|---|
| 147 | // na koncu,bo moze byc sortowanie po stanie
|
|---|
| 148 | row["stan"] = "DO DTP";
|
|---|
| 149 | pRODUKCJABindingSource.EndEdit();
|
|---|
| 150 | pRODUKCJATableAdapter.Update(rEKLAMADataSet.PRODUKCJA);
|
|---|
| 151 | zablokujButtony();
|
|---|
| 152 |
|
|---|
| 153 | wlaczSortowanieGrida();
|
|---|
| 154 | }
|
|---|
| 155 | }
|
|---|
| 156 |
|
|---|
| 157 | private void proToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 158 | {
|
|---|
| 159 | if (pRODUKCJABindingSource.Current != null)
|
|---|
| 160 | {
|
|---|
| 161 | wylaczSortowanieGrida();
|
|---|
| 162 |
|
|---|
| 163 | DataRowView row = (DataRowView) pRODUKCJABindingSource.Current;
|
|---|
| 164 |
|
|---|
| 165 | REKLAMADataSet.PRODUKCJADataTable t = pRODUKCJATableAdapter.GetDataById(Convert.ToInt32(row["ID"]));
|
|---|
| 166 |
|
|---|
| 167 | if (!t[0].IsDTPNull())
|
|---|
| 168 | {
|
|---|
| 169 | if (
|
|---|
| 170 | MessageBox.Show("Zlecenie jest ju¿ w DTP. Czy chcesz je przej¹æ ?", "", MessageBoxButtons.YesNo) ==
|
|---|
| 171 | DialogResult.No)
|
|---|
| 172 | {
|
|---|
| 173 | return;
|
|---|
| 174 | }
|
|---|
| 175 | }
|
|---|
| 176 |
|
|---|
| 177 | row["DTP"] = User.getUser().Login;
|
|---|
| 178 | row["DATA_DTP"] = DateTime.Now;
|
|---|
| 179 | // na koncu,bo moze byc sortowanie po stanie
|
|---|
| 180 | row["stan"] = "W DTP";
|
|---|
| 181 |
|
|---|
| 182 | pRODUKCJABindingSource.EndEdit();
|
|---|
| 183 | pRODUKCJATableAdapter.Update(rEKLAMADataSet.PRODUKCJA);
|
|---|
| 184 | zablokujButtony();
|
|---|
| 185 |
|
|---|
| 186 | wlaczSortowanieGrida();
|
|---|
| 187 | }
|
|---|
| 188 | }
|
|---|
| 189 |
|
|---|
| 190 | private void doKorektyToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 191 | {
|
|---|
| 192 | if (pRODUKCJABindingSource.Current != null)
|
|---|
| 193 | {
|
|---|
| 194 | wylaczSortowanieGrida();
|
|---|
| 195 |
|
|---|
| 196 | DataRowView row = (DataRowView) pRODUKCJABindingSource.Current;
|
|---|
| 197 | row["stan"] = "DO KOREKTY";
|
|---|
| 198 |
|
|---|
| 199 | pRODUKCJABindingSource.EndEdit();
|
|---|
| 200 | pRODUKCJATableAdapter.Update(rEKLAMADataSet.PRODUKCJA);
|
|---|
| 201 | zablokujButtony();
|
|---|
| 202 |
|
|---|
| 203 | wlaczSortowanieGrida();
|
|---|
| 204 | }
|
|---|
| 205 | }
|
|---|
| 206 |
|
|---|
| 207 | private void doDTP2ToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 208 | {
|
|---|
| 209 | if (pRODUKCJABindingSource.Current != null)
|
|---|
| 210 | {
|
|---|
| 211 | wylaczSortowanieGrida();
|
|---|
| 212 |
|
|---|
| 213 | DataRowView row = (DataRowView) pRODUKCJABindingSource.Current;
|
|---|
| 214 |
|
|---|
| 215 | row["KOREKTA"] = User.getUser().Login;
|
|---|
| 216 | row["DATA_KOREKTA"] = DateTime.Now;
|
|---|
| 217 | // na koncu,bo moze byc sortowanie po stanie
|
|---|
| 218 | row["stan"] = "PO KOREKCIE";
|
|---|
| 219 |
|
|---|
| 220 | pRODUKCJABindingSource.EndEdit();
|
|---|
| 221 | pRODUKCJATableAdapter.Update(rEKLAMADataSet.PRODUKCJA);
|
|---|
| 222 | zablokujButtony();
|
|---|
| 223 |
|
|---|
| 224 | wlaczSortowanieGrida();
|
|---|
| 225 | }
|
|---|
| 226 | }
|
|---|
| 227 |
|
|---|
| 228 | private void doKorekty2ToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 229 | {
|
|---|
| 230 | if (pRODUKCJABindingSource.Current != null)
|
|---|
| 231 | {
|
|---|
| 232 | wylaczSortowanieGrida();
|
|---|
| 233 |
|
|---|
| 234 | DataRowView row = (DataRowView) pRODUKCJABindingSource.Current;
|
|---|
| 235 |
|
|---|
| 236 | row["DTP_PO_KOR"] = User.getUser().Login;
|
|---|
| 237 | row["DATA_DTP_PO_KOR"] = DateTime.Now;
|
|---|
| 238 | // na koncu,bo moze byc sortowanie po stanie
|
|---|
| 239 | row["stan"] = "W 2 KOREKCIE";
|
|---|
| 240 |
|
|---|
| 241 | pRODUKCJABindingSource.EndEdit();
|
|---|
| 242 | pRODUKCJATableAdapter.Update(rEKLAMADataSet.PRODUKCJA);
|
|---|
| 243 | zablokujButtony();
|
|---|
| 244 |
|
|---|
| 245 | wlaczSortowanieGrida();
|
|---|
| 246 | }
|
|---|
| 247 | }
|
|---|
| 248 |
|
|---|
| 249 | private void doAgentaToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 250 | {
|
|---|
| 251 | if (pRODUKCJABindingSource.Current != null)
|
|---|
| 252 | {
|
|---|
| 253 | wylaczSortowanieGrida();
|
|---|
| 254 |
|
|---|
| 255 | DataRowView row = (DataRowView) pRODUKCJABindingSource.Current;
|
|---|
| 256 |
|
|---|
| 257 | row["DTP_PO_KOR"] = User.getUser().Login;
|
|---|
| 258 | row["DATA_DTP_PO_KOR"] = DateTime.Now;
|
|---|
| 259 |
|
|---|
| 260 | //row["DATA_AKCEPTACJI"] = DateTime.Now;
|
|---|
| 261 |
|
|---|
| 262 | row["stan"] = "DO AKCEPTACJI";
|
|---|
| 263 | pRODUKCJABindingSource.EndEdit();
|
|---|
| 264 | pRODUKCJATableAdapter.Update(rEKLAMADataSet.PRODUKCJA);
|
|---|
| 265 | zablokujButtony();
|
|---|
| 266 |
|
|---|
| 267 | wlaczSortowanieGrida();
|
|---|
| 268 | }
|
|---|
| 269 | }
|
|---|
| 270 |
|
|---|
| 271 | private void akceptToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 272 | {
|
|---|
| 273 | if (ocenaToolStripComboBox.SelectedIndex == -1)
|
|---|
| 274 | {
|
|---|
| 275 | MessageBox.Show("Oceñ projekt");
|
|---|
| 276 | }
|
|---|
| 277 | else
|
|---|
| 278 | {
|
|---|
| 279 | if (pRODUKCJABindingSource.Current != null)
|
|---|
| 280 | {
|
|---|
| 281 | wylaczSortowanieGrida();
|
|---|
| 282 | DataRowView row = (DataRowView) pRODUKCJABindingSource.Current;
|
|---|
| 283 | row["DATA_AKCEPTACJI"] = DateTime.Now;
|
|---|
| 284 | row["ocena"] = ocenaToolStripComboBox.Items[ocenaToolStripComboBox.SelectedIndex];
|
|---|
| 285 | // na koncu,bo moze byc sortowanie po stanie
|
|---|
| 286 | row["stan"] = "ZAAKCEPTOWANE";
|
|---|
| 287 |
|
|---|
| 288 | pRODUKCJABindingSource.EndEdit();
|
|---|
| 289 | pRODUKCJATableAdapter.Update(rEKLAMADataSet.PRODUKCJA);
|
|---|
| 290 | zablokujButtony();
|
|---|
| 291 |
|
|---|
| 292 | wlaczSortowanieGrida();
|
|---|
| 293 | }
|
|---|
| 294 | }
|
|---|
| 295 | }
|
|---|
| 296 |
|
|---|
| 297 | private void nieakceptToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 298 | {
|
|---|
| 299 | if (pRODUKCJABindingSource.Current != null)
|
|---|
| 300 | {
|
|---|
| 301 | wylaczSortowanieGrida();
|
|---|
| 302 | DataRowView row = (DataRowView) pRODUKCJABindingSource.Current;
|
|---|
| 303 |
|
|---|
| 304 | row["DATA_AKCEPTACJI"] = DateTime.Now;
|
|---|
| 305 | row["ocena"] = -1;
|
|---|
| 306 | // na koncu,bo moze byc sortowanie po stanie
|
|---|
| 307 | row["stan"] = "NIEZAAKCEPTOWANE";
|
|---|
| 308 |
|
|---|
| 309 | pRODUKCJABindingSource.EndEdit();
|
|---|
| 310 | pRODUKCJATableAdapter.Update(rEKLAMADataSet.PRODUKCJA);
|
|---|
| 311 | zablokujButtony();
|
|---|
| 312 |
|
|---|
| 313 | wlaczSortowanieGrida();
|
|---|
| 314 | }
|
|---|
| 315 | }
|
|---|
| 316 |
|
|---|
| 317 | private void produkcjaDataGridView_CellLeave(object sender, DataGridViewCellEventArgs e)
|
|---|
| 318 | {
|
|---|
| 319 | pRODUKCJABindingSource.CancelEdit();
|
|---|
| 320 | }
|
|---|
| 321 |
|
|---|
| 322 | private void szukajToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 323 | {
|
|---|
| 324 | if (stanToolStripComboBox.SelectedIndex != -1)
|
|---|
| 325 | {
|
|---|
| 326 | Cursor = Cursors.WaitCursor;
|
|---|
| 327 |
|
|---|
| 328 | command.CommandText = query;
|
|---|
| 329 | command.Parameters.Clear();
|
|---|
| 330 |
|
|---|
| 331 | string status = stanToolStripComboBox.SelectedItem.ToString();
|
|---|
| 332 |
|
|---|
| 333 | if (status == "*W PRODUKCJI*")
|
|---|
| 334 | {
|
|---|
| 335 | command.CommandText +=
|
|---|
| 336 | " AND STAN!='ZAAKCEPTOWANE' AND STAN!='NIEZAAKCEPTOWANE' AND STAN!='DO AKCEPTACJI' AND STAN!='ZWROT Z PRODUKCJI'";
|
|---|
| 337 | }
|
|---|
| 338 | else
|
|---|
| 339 | {
|
|---|
| 340 | command.CommandText += " AND STAN=@stan ";
|
|---|
| 341 | command.Parameters.AddWithValue("@stan", status);
|
|---|
| 342 |
|
|---|
| 343 | //wybieramy z ostatnich 3 miesiecy
|
|---|
| 344 | if (status == "NIEZAAKCEPTOWANE" || status == "ZAAKCEPTOWANE" || status == "ZWROT Z PRODUKCJI")
|
|---|
| 345 | {
|
|---|
| 346 | command.CommandText += "AND datediff(month,DATA_AGENT,getdate()) <= 3 ";
|
|---|
| 347 | }
|
|---|
| 348 | }
|
|---|
| 349 |
|
|---|
| 350 | command.CommandText += "order by DATA_AGENT desc";
|
|---|
| 351 |
|
|---|
| 352 | rEKLAMADataSet.PRODUKCJA.Clear();
|
|---|
| 353 | sqlDataAdapter.Fill(rEKLAMADataSet.PRODUKCJA);
|
|---|
| 354 |
|
|---|
| 355 | Cursor = Cursors.Default;
|
|---|
| 356 | }
|
|---|
| 357 | }
|
|---|
| 358 |
|
|---|
| 359 | private void dzisiajToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 360 | {
|
|---|
| 361 | Cursor = Cursors.WaitCursor;
|
|---|
| 362 |
|
|---|
| 363 | command.CommandText = queryDzisiaj;
|
|---|
| 364 |
|
|---|
| 365 | sqlDataAdapter.SelectCommand = command;
|
|---|
| 366 |
|
|---|
| 367 | rEKLAMADataSet.PRODUKCJA.Clear();
|
|---|
| 368 | sqlDataAdapter.Fill(rEKLAMADataSet.PRODUKCJA);
|
|---|
| 369 |
|
|---|
| 370 | Cursor = Cursors.Default;
|
|---|
| 371 | }
|
|---|
| 372 |
|
|---|
| 373 | /// <summary>
|
|---|
| 374 | /// Wczytuje listê reklam na wskazane wydanie i sprawdza czy istniej¹ pliki do reklam
|
|---|
| 375 | /// </summary>
|
|---|
| 376 | private void button1_Click(object sender, EventArgs e)
|
|---|
| 377 | {
|
|---|
| 378 | Cursor = Cursors.WaitCursor;
|
|---|
| 379 |
|
|---|
| 380 | listaReklamDoWydaniaNrBindingSource.Filter = "";
|
|---|
| 381 | grzbietyComboBox.SelectedIndex = -1;
|
|---|
| 382 |
|
|---|
| 383 | if ((tytulComboBox.Text.Trim() != "") && (nrWydaniaTextBox.Text.Trim() != ""))
|
|---|
| 384 | {
|
|---|
| 385 | short nr = Convert.ToInt16(nrWydaniaTextBox.Text);
|
|---|
| 386 | nrWyd = nr;
|
|---|
| 387 | tyt = tytulComboBox.Text;
|
|---|
| 388 | listaReklamDoWydaniaNrTableAdapter.Fill2Produkcja(rEKLAMADataSet.ListaReklamDoWydaniaNr,
|
|---|
| 389 | tytulComboBox.Text, nr);
|
|---|
| 390 | sprawdzPlikiDlaWszystkichReklam();
|
|---|
| 391 | }
|
|---|
| 392 |
|
|---|
| 393 | spisPlikowDataGridView.Refresh();
|
|---|
| 394 |
|
|---|
| 395 | Cursor = Cursors.Default;
|
|---|
| 396 | }
|
|---|
| 397 |
|
|---|
| 398 | /// <summary>
|
|---|
| 399 | /// Otwiera plik xtg. Zczytuje z niego reklamy do listy obiektów Reklama.
|
|---|
| 400 | /// Wpisuje znalezione strony do tabeli.
|
|---|
| 401 | /// </summary>
|
|---|
| 402 | private void XTGbutton_Click(object sender, EventArgs e)
|
|---|
| 403 | {
|
|---|
| 404 | openFileDialog.InitialDirectory = "R:\\MAKIETY\\QUARK\\" + tyt + nrWyd;
|
|---|
| 405 | openFileDialog.DefaultExt = "xtg";
|
|---|
| 406 |
|
|---|
| 407 | if (openFileDialog.ShowDialog() == DialogResult.OK)
|
|---|
| 408 | {
|
|---|
| 409 | xtgTextBox.Text = openFileDialog.FileName;
|
|---|
| 410 |
|
|---|
| 411 | XTGFile xtgfile = new XTGFile();
|
|---|
| 412 |
|
|---|
| 413 | List<Reklama> lista = xtgfile.zczytajStronyZplikuXTG(openFileDialog.FileName);
|
|---|
| 414 |
|
|---|
| 415 | wpiszStronyDoTabeli(lista);
|
|---|
| 416 |
|
|---|
| 417 | spisPlikowDataGridView.Sort(IdReklamyColumn, ListSortDirection.Ascending);
|
|---|
| 418 |
|
|---|
| 419 | StringBuilder message = new StringBuilder();
|
|---|
| 420 | message.AppendLine("Wczytywanie stron z pliku " + openFileDialog.FileName + " zakoñczone. ");
|
|---|
| 421 | message.AppendLine("Niewczytane reklamy: ");
|
|---|
| 422 |
|
|---|
| 423 | foreach (Reklama r in lista)
|
|---|
| 424 | {
|
|---|
| 425 | if (!r.wpisana)
|
|---|
| 426 | {
|
|---|
| 427 | message.AppendLine(r.nrRek);
|
|---|
| 428 | }
|
|---|
| 429 | }
|
|---|
| 430 |
|
|---|
| 431 | MessageBox.Show(message.ToString());
|
|---|
| 432 | }
|
|---|
| 433 | }
|
|---|
| 434 |
|
|---|
| 435 | public void wpiszStronyDoTabeli(List<Reklama> lista)
|
|---|
| 436 | {
|
|---|
| 437 | Cursor = Cursors.WaitCursor;
|
|---|
| 438 |
|
|---|
| 439 | foreach (DataRowView r in listaReklamDoWydaniaNrBindingSource.List)
|
|---|
| 440 | {
|
|---|
| 441 | foreach (Reklama reklama in lista)
|
|---|
| 442 | {
|
|---|
| 443 | if (r["id reklamy"].ToString().ToLower().Contains(reklama.nrRek.ToLower()))
|
|---|
| 444 | {
|
|---|
| 445 | short test;
|
|---|
| 446 | bool result = Int16.TryParse(reklama.costam[1], out test);
|
|---|
| 447 |
|
|---|
| 448 | // r["strona"] = Convert.ToInt16();
|
|---|
| 449 |
|
|---|
| 450 | if (result)
|
|---|
| 451 | {
|
|---|
| 452 | r["strona"] = test;
|
|---|
| 453 | reklama.wpisana = true;
|
|---|
| 454 | }
|
|---|
| 455 | }
|
|---|
| 456 | }
|
|---|
| 457 | }
|
|---|
| 458 |
|
|---|
| 459 | rEKLAMADataSet.ListaReklamDoWydaniaNr.AcceptChanges();
|
|---|
| 460 |
|
|---|
| 461 | Cursor = Cursors.Default;
|
|---|
| 462 | }
|
|---|
| 463 |
|
|---|
| 464 | /// <summary>
|
|---|
| 465 | /// Usuwa poprzednie informacje o stronach i zapisuje nowe strony. W tabeli strona nie ma
|
|---|
| 466 | /// kolumny wyznaczaj¹cej tytu³, wiêc sprawdza grzbiet.
|
|---|
| 467 | /// </summary>
|
|---|
| 468 | private void zapiszStronyButton_Click(object sender, EventArgs e)
|
|---|
| 469 | {
|
|---|
| 470 | Cursor = Cursors.WaitCursor;
|
|---|
| 471 |
|
|---|
| 472 | SqlCommand command = new SqlCommand();
|
|---|
| 473 | command.Connection = new SqlConnection(ConnString.getConnString().Value);
|
|---|
| 474 |
|
|---|
| 475 | if (listaReklamDoWydaniaNrBindingSource.Filter == "")
|
|---|
| 476 | {
|
|---|
| 477 | command.CommandText = "delete from dbo.REKLAMA_STRONA where nr_wydania=@nrWyd" +
|
|---|
| 478 | " and ID_GRZBIETU in (select ID from dbo.GRZBIETY where Nazwa like '%'+ @tytul + '%')";
|
|---|
| 479 | command.Parameters.Clear();
|
|---|
| 480 | command.Parameters.AddWithValue("@nrWyd", nrWyd);
|
|---|
| 481 | command.Parameters.AddWithValue("@tytul", tyt);
|
|---|
| 482 | }
|
|---|
| 483 | else
|
|---|
| 484 | {
|
|---|
| 485 | command.CommandText = "delete from dbo.REKLAMA_STRONA where nr_wydania=@nrWyd" +
|
|---|
| 486 | " and ID_GRZBIETU = @idGrzbietu";
|
|---|
| 487 | command.Parameters.Clear();
|
|---|
| 488 | command.Parameters.AddWithValue("@nrWyd", nrWyd);
|
|---|
| 489 | command.Parameters.AddWithValue("@tytul", tyt);
|
|---|
| 490 | command.Parameters.AddWithValue("@idGrzbietu", grzbietyComboBox.SelectedValue);
|
|---|
| 491 | }
|
|---|
| 492 |
|
|---|
| 493 | command.Connection.Open();
|
|---|
| 494 | command.ExecuteNonQuery();
|
|---|
| 495 | command.Connection.Close();
|
|---|
| 496 |
|
|---|
| 497 | command.CommandText = "insert into reklama_strona values(@idRek,@nrWyd,@idGrzbiet,@nrStrony);";
|
|---|
| 498 | command.Connection.Open();
|
|---|
| 499 | foreach (DataGridViewRow row in spisPlikowDataGridView.Rows)
|
|---|
| 500 | {
|
|---|
| 501 | //reklam bez stron i dla autosalonu nie zapisuje w bazie
|
|---|
| 502 | if ((row.Cells["strona"].Value != null) & (Convert.ToInt32(row.Cells["grzbiet"].Value) != 9))
|
|---|
| 503 | {
|
|---|
| 504 | command.Parameters.Clear();
|
|---|
| 505 |
|
|---|
| 506 | command.Parameters.AddWithValue("@idRek", row.Cells["reklamaId"].Value);
|
|---|
| 507 | command.Parameters.AddWithValue("@nrWyd", row.Cells["NR"].Value);
|
|---|
| 508 | command.Parameters.AddWithValue("@idGrzbiet", row.Cells["Grzbiet"].Value);
|
|---|
| 509 | command.Parameters.AddWithValue("@nrStrony", row.Cells["strona"].Value);
|
|---|
| 510 |
|
|---|
| 511 | try
|
|---|
| 512 | {
|
|---|
| 513 | command.ExecuteNonQuery();
|
|---|
| 514 | }
|
|---|
| 515 | catch (Exception e1)
|
|---|
| 516 | {
|
|---|
| 517 | MessageBox.Show(e1.Message);
|
|---|
| 518 | }
|
|---|
| 519 | }
|
|---|
| 520 | }
|
|---|
| 521 | command.Connection.Close();
|
|---|
| 522 |
|
|---|
| 523 | Cursor = Cursors.Default;
|
|---|
| 524 |
|
|---|
| 525 | MessageBox.Show("Zapisano strony");
|
|---|
| 526 | }
|
|---|
| 527 |
|
|---|
| 528 | private void spisPlikowDataGridView_SelectionChanged(object sender, EventArgs e)
|
|---|
| 529 | {
|
|---|
| 530 | if (listaReklamDoWydaniaNrBindingSource.Current != null)
|
|---|
| 531 | {
|
|---|
| 532 | DataRowView row = (DataRowView) listaReklamDoWydaniaNrBindingSource.Current;
|
|---|
| 533 | pobierzSciezki(row);
|
|---|
| 534 | }
|
|---|
| 535 | }
|
|---|
| 536 |
|
|---|
| 537 | /// <summary>
|
|---|
| 538 | /// Sprawdza cie¿ki do plików JPG (PDF), CDR, EPS dla danego projektu.
|
|---|
| 539 | /// Je¿eli pliki istniej¹ uzupe³nia informacjê o datach.
|
|---|
| 540 | /// </summary>
|
|---|
| 541 | private void pobierzSciezki(DataRowView row)
|
|---|
| 542 | {
|
|---|
| 543 | string idReklamy = row["id reklamy"].ToString();
|
|---|
| 544 | string tytul = row["TYTU£"].ToString();
|
|---|
| 545 | int idGrzbietu = Convert.ToInt32(row["GRZBIET"]);
|
|---|
| 546 | string miasto = row["miasto"].ToString();
|
|---|
| 547 | byte staryNowyArchiwum = 0;
|
|---|
| 548 |
|
|---|
| 549 | string plikJPG = Produkcja.GetReklamaFileName(idReklamy, tytul, idGrzbietu, miasto, staryNowyArchiwum, "jpg");
|
|---|
| 550 | string plikPDF = Produkcja.GetReklamaFileName(idReklamy, tytul, idGrzbietu, miasto, staryNowyArchiwum, "pdf");
|
|---|
| 551 | string plikEPS = Produkcja.GetReklamaFileName(idReklamy, tytul, idGrzbietu, miasto, staryNowyArchiwum, "eps");
|
|---|
| 552 | string plikCDR = Produkcja.GetReklamaFileName(idReklamy, tytul, idGrzbietu, miasto, staryNowyArchiwum, "cdr");
|
|---|
| 553 |
|
|---|
| 554 |
|
|---|
| 555 | if (File.Exists(plikCDR))
|
|---|
| 556 | {
|
|---|
| 557 | DateTime data = File.GetLastWriteTime(plikCDR);
|
|---|
| 558 | CDRTextBox.Text = plikCDR;
|
|---|
| 559 | CDRdataTextBox.Text = data.ToString();
|
|---|
| 560 | CDRbutton.Enabled = true;
|
|---|
| 561 | }
|
|---|
| 562 | else
|
|---|
| 563 | {
|
|---|
| 564 | CDRTextBox.Text = "";
|
|---|
| 565 | CDRdataTextBox.Text = "";
|
|---|
| 566 | CDRbutton.Enabled = false;
|
|---|
| 567 | }
|
|---|
| 568 |
|
|---|
| 569 | if (File.Exists(plikEPS))
|
|---|
| 570 | {
|
|---|
| 571 | DateTime data = File.GetLastWriteTime(plikEPS);
|
|---|
| 572 | EPSTextBox.Text = plikEPS;
|
|---|
| 573 | EPSdataTextBox.Text = data.ToString();
|
|---|
| 574 | EPSbutton.Enabled = true;
|
|---|
| 575 | }
|
|---|
| 576 | else
|
|---|
| 577 | {
|
|---|
| 578 | EPSTextBox.Text = "";
|
|---|
| 579 | EPSdataTextBox.Text = "";
|
|---|
| 580 | EPSbutton.Enabled = false;
|
|---|
| 581 | }
|
|---|
| 582 |
|
|---|
| 583 |
|
|---|
| 584 | if (File.Exists(plikJPG))
|
|---|
| 585 | {
|
|---|
| 586 | DateTime data = File.GetLastWriteTime(plikJPG);
|
|---|
| 587 | JPGTextBox.Text = plikJPG;
|
|---|
| 588 | JPGdataTextBox.Text = data.ToString();
|
|---|
| 589 | JPGbutton.Enabled = true;
|
|---|
| 590 | }
|
|---|
| 591 | else if (File.Exists(plikPDF))
|
|---|
| 592 | {
|
|---|
| 593 | DateTime data = File.GetLastWriteTime(plikPDF);
|
|---|
| 594 | JPGTextBox.Text = plikPDF;
|
|---|
| 595 | JPGdataTextBox.Text = data.ToString();
|
|---|
| 596 | JPGbutton.Enabled = true;
|
|---|
| 597 | }
|
|---|
| 598 | else
|
|---|
| 599 | {
|
|---|
| 600 | JPGTextBox.Text = "";
|
|---|
| 601 | JPGdataTextBox.Text = "";
|
|---|
| 602 | JPGbutton.Enabled = false;
|
|---|
| 603 | }
|
|---|
| 604 | }
|
|---|
| 605 |
|
|---|
| 606 | /// <summary>
|
|---|
| 607 | /// Sprawdza dla wszytskich reklam czy istniej¹ pliki JPG,CDR, EPS.
|
|---|
| 608 | /// </summary>
|
|---|
| 609 | private void sprawdzPlikiDlaWszystkichReklam()
|
|---|
| 610 | {
|
|---|
| 611 | CDRColumn.SortMode = DataGridViewColumnSortMode.NotSortable;
|
|---|
| 612 | EPSColumn.SortMode = DataGridViewColumnSortMode.NotSortable;
|
|---|
| 613 | JPGColumn.SortMode = DataGridViewColumnSortMode.NotSortable;
|
|---|
| 614 |
|
|---|
| 615 | foreach (DataRowView row in listaReklamDoWydaniaNrBindingSource.List)
|
|---|
| 616 | {
|
|---|
| 617 | if (row["id reklamy"] != DBNull.Value)
|
|---|
| 618 | {
|
|---|
| 619 | string idReklamy = row["Id Reklamy"].ToString();
|
|---|
| 620 | string tytul = row["TYTU£"].ToString();
|
|---|
| 621 |
|
|---|
| 622 | int idGrzbietu = 0;
|
|---|
| 623 | if (row["GRZBIET"] != DBNull.Value)
|
|---|
| 624 | {
|
|---|
| 625 | idGrzbietu = Convert.ToInt32(row["GRZBIET"]);
|
|---|
| 626 | }
|
|---|
| 627 |
|
|---|
| 628 | string miasto = row["miasto"].ToString();
|
|---|
| 629 |
|
|---|
| 630 | byte staryNowyArchiwum = 0;
|
|---|
| 631 |
|
|---|
| 632 | string plikJPG = Produkcja.GetReklamaFileName(idReklamy, tytul, idGrzbietu, miasto,
|
|---|
| 633 | staryNowyArchiwum, "jpg");
|
|---|
| 634 | string plikPDF = Produkcja.GetReklamaFileName(idReklamy, tytul, idGrzbietu, miasto,
|
|---|
| 635 | staryNowyArchiwum, "pdf");
|
|---|
| 636 | string plikEPS = Produkcja.GetReklamaFileName(idReklamy, tytul, idGrzbietu, miasto,
|
|---|
| 637 | staryNowyArchiwum, "eps");
|
|---|
| 638 | string plikCDR = Produkcja.GetReklamaFileName(idReklamy, tytul, idGrzbietu, miasto,
|
|---|
| 639 | staryNowyArchiwum, "cdr");
|
|---|
| 640 |
|
|---|
| 641 | if (File.Exists(plikCDR))
|
|---|
| 642 | {
|
|---|
| 643 | row["jestCDR"] = true;
|
|---|
| 644 | }
|
|---|
| 645 |
|
|---|
| 646 | if (File.Exists(plikEPS))
|
|---|
| 647 | {
|
|---|
| 648 | row["jestEPS"] = true;
|
|---|
| 649 | }
|
|---|
| 650 |
|
|---|
| 651 | if (File.Exists(plikJPG) || File.Exists(plikPDF))
|
|---|
| 652 | {
|
|---|
| 653 | row["jestJPG"] = true;
|
|---|
| 654 | }
|
|---|
| 655 | }
|
|---|
| 656 | }
|
|---|
| 657 |
|
|---|
| 658 | CDRColumn.SortMode = DataGridViewColumnSortMode.Automatic;
|
|---|
| 659 | EPSColumn.SortMode = DataGridViewColumnSortMode.Automatic;
|
|---|
| 660 | JPGColumn.SortMode = DataGridViewColumnSortMode.Automatic;
|
|---|
| 661 | }
|
|---|
| 662 |
|
|---|
| 663 | private void uprawnienia()
|
|---|
| 664 | {
|
|---|
| 665 | usunToolStripButton.Enabled = User.getUser().St_kierownik | User.getUser().St_produkcja;
|
|---|
| 666 |
|
|---|
| 667 | zamowienieToolStripButton.Visible = User.getUser().St_produkcja | User.getUser().St_handlowiec |
|
|---|
| 668 | User.getUser().St_subhandlowiec | User.getUser().St_kierownik;
|
|---|
| 669 | klientToolStripButton.Visible = User.getUser().St_produkcja | User.getUser().St_handlowiec |
|
|---|
| 670 | User.getUser().St_subhandlowiec | User.getUser().St_kierownik;
|
|---|
| 671 |
|
|---|
| 672 | zwrotToolStripButton.Enabled = User.getUser().St_produkcja | User.getUser().St_korekta |
|
|---|
| 673 | User.getUser().St_dtp;
|
|---|
| 674 | doDTPToolStripButton.Enabled = User.getUser().St_produkcja;
|
|---|
| 675 | proToolStripButton.Enabled = User.getUser().St_dtp;
|
|---|
| 676 | doKorektyToolStripButton.Enabled = User.getUser().St_dtp;
|
|---|
| 677 | doDTP2ToolStripButton.Enabled = User.getUser().St_korekta;
|
|---|
| 678 | doKorekty2ToolStripButton.Enabled = User.getUser().St_dtp;
|
|---|
| 679 | doAgentaToolStripButton.Enabled = User.getUser().St_korekta | User.getUser().St_dtp;
|
|---|
| 680 | akceptToolStripButton.Enabled = User.getUser().St_handlowiec | User.getUser().St_subhandlowiec |
|
|---|
| 681 | User.getUser().St_kierownik;
|
|---|
| 682 | nieakceptToolStripButton.Enabled = User.getUser().St_handlowiec | User.getUser().St_subhandlowiec |
|
|---|
| 683 | User.getUser().St_kierownik;
|
|---|
| 684 |
|
|---|
| 685 | if (!(User.getUser().St_produkcja | User.getUser().St_kierownik | User.getUser().St_dtp))
|
|---|
| 686 | {
|
|---|
| 687 | tabControl1.TabPages.Remove(spisTabPage);
|
|---|
| 688 | tabControl1.TabPages.Remove(listyDoKlientowTabPage);
|
|---|
| 689 | }
|
|---|
| 690 |
|
|---|
| 691 | zapiszStronyButton.Enabled = User.getUser().St_produkcja | User.getUser().St_kierownik;
|
|---|
| 692 | }
|
|---|
| 693 |
|
|---|
| 694 | /// <summary>
|
|---|
| 695 | /// Blokuje buttony w zale¿noci od uprawnieñ i stanu projektu.
|
|---|
| 696 | /// </summary>
|
|---|
| 697 | private void zablokujButtony()
|
|---|
| 698 | {
|
|---|
| 699 | if (pRODUKCJABindingSource.Current != null)
|
|---|
| 700 | {
|
|---|
| 701 | DataRowView row = (DataRowView) pRODUKCJABindingSource.Current;
|
|---|
| 702 |
|
|---|
| 703 | uprawnienia();
|
|---|
| 704 |
|
|---|
| 705 | string agent = row["agent"].ToString();
|
|---|
| 706 |
|
|---|
| 707 | switch (row["stan"].ToString())
|
|---|
| 708 | {
|
|---|
| 709 | case "ZAMAWIAM":
|
|---|
| 710 | zwrotToolStripButton.Enabled = zwrotToolStripButton.Enabled & true;
|
|---|
| 711 | doDTPToolStripButton.Enabled = doDTPToolStripButton.Enabled & true;
|
|---|
| 712 | proToolStripButton.Enabled = proToolStripButton.Enabled & false;
|
|---|
| 713 | doKorektyToolStripButton.Enabled = doKorektyToolStripButton.Enabled & false;
|
|---|
| 714 | doDTP2ToolStripButton.Enabled = doDTP2ToolStripButton.Enabled & false;
|
|---|
| 715 | doKorekty2ToolStripButton.Enabled = doKorekty2ToolStripButton.Enabled & false;
|
|---|
| 716 | doAgentaToolStripButton.Enabled = doAgentaToolStripButton.Enabled & false;
|
|---|
| 717 | akceptToolStripButton.Enabled = false;
|
|---|
| 718 | nieakceptToolStripButton.Enabled = false;
|
|---|
| 719 | break;
|
|---|
| 720 | case "DO DTP":
|
|---|
| 721 | zwrotToolStripButton.Enabled = zwrotToolStripButton.Enabled & true;
|
|---|
| 722 | doDTPToolStripButton.Enabled = false;
|
|---|
| 723 | proToolStripButton.Enabled = proToolStripButton.Enabled & true;
|
|---|
| 724 | doKorektyToolStripButton.Enabled = doKorektyToolStripButton.Enabled & false;
|
|---|
| 725 | doDTP2ToolStripButton.Enabled = doDTP2ToolStripButton.Enabled & false;
|
|---|
| 726 | doKorekty2ToolStripButton.Enabled = doKorekty2ToolStripButton.Enabled & false;
|
|---|
| 727 | doAgentaToolStripButton.Enabled = doAgentaToolStripButton.Enabled & false;
|
|---|
| 728 | akceptToolStripButton.Enabled = false;
|
|---|
| 729 | nieakceptToolStripButton.Enabled = false;
|
|---|
| 730 | break;
|
|---|
| 731 | case "W DTP":
|
|---|
| 732 | zwrotToolStripButton.Enabled = zwrotToolStripButton.Enabled & true;
|
|---|
| 733 | doDTPToolStripButton.Enabled = false;
|
|---|
| 734 | proToolStripButton.Enabled = proToolStripButton.Enabled & true;
|
|---|
| 735 | doKorektyToolStripButton.Enabled = doKorektyToolStripButton.Enabled & true;
|
|---|
| 736 | doDTP2ToolStripButton.Enabled = doDTP2ToolStripButton.Enabled & false;
|
|---|
| 737 | doKorekty2ToolStripButton.Enabled = doKorekty2ToolStripButton.Enabled & false;
|
|---|
| 738 | doAgentaToolStripButton.Enabled = doAgentaToolStripButton.Enabled & false;
|
|---|
| 739 | akceptToolStripButton.Enabled = false;
|
|---|
| 740 | nieakceptToolStripButton.Enabled = false;
|
|---|
| 741 | break;
|
|---|
| 742 | case "DO KOREKTY":
|
|---|
| 743 | zwrotToolStripButton.Enabled = zwrotToolStripButton.Enabled & true;
|
|---|
| 744 | doDTPToolStripButton.Enabled = false;
|
|---|
| 745 | proToolStripButton.Enabled = false;
|
|---|
| 746 | doKorektyToolStripButton.Enabled = false;
|
|---|
| 747 | doDTP2ToolStripButton.Enabled = doDTP2ToolStripButton.Enabled & true;
|
|---|
| 748 | doKorekty2ToolStripButton.Enabled = false;
|
|---|
| 749 | doAgentaToolStripButton.Enabled = doAgentaToolStripButton.Enabled & false;
|
|---|
| 750 | akceptToolStripButton.Enabled = false;
|
|---|
| 751 | nieakceptToolStripButton.Enabled = false;
|
|---|
| 752 | break;
|
|---|
| 753 | case "PO KOREKCIE":
|
|---|
| 754 | zwrotToolStripButton.Enabled = zwrotToolStripButton.Enabled & true;
|
|---|
| 755 | doDTPToolStripButton.Enabled = false;
|
|---|
| 756 | proToolStripButton.Enabled = false;
|
|---|
| 757 | doKorektyToolStripButton.Enabled = false;
|
|---|
| 758 | doDTP2ToolStripButton.Enabled = false;
|
|---|
| 759 | doKorekty2ToolStripButton.Enabled = doKorekty2ToolStripButton.Enabled & true;
|
|---|
| 760 | doAgentaToolStripButton.Enabled = doAgentaToolStripButton.Enabled & true;
|
|---|
| 761 | akceptToolStripButton.Enabled = false;
|
|---|
| 762 | nieakceptToolStripButton.Enabled = false;
|
|---|
| 763 | break;
|
|---|
| 764 | case "W 2 KOREKCIE":
|
|---|
| 765 | zwrotToolStripButton.Enabled = zwrotToolStripButton.Enabled & true;
|
|---|
| 766 | doDTPToolStripButton.Enabled = false;
|
|---|
| 767 | proToolStripButton.Enabled = false;
|
|---|
| 768 | doKorektyToolStripButton.Enabled = false;
|
|---|
| 769 | doDTP2ToolStripButton.Enabled = doDTP2ToolStripButton.Enabled & true;
|
|---|
| 770 | doKorekty2ToolStripButton.Enabled = false;
|
|---|
| 771 | doAgentaToolStripButton.Enabled = false;
|
|---|
| 772 | akceptToolStripButton.Enabled = false;
|
|---|
| 773 | nieakceptToolStripButton.Enabled = false;
|
|---|
| 774 | break;
|
|---|
| 775 | case "NIEZAAKCEPTOWANE":
|
|---|
| 776 | zwrotToolStripButton.Enabled = false;
|
|---|
| 777 | doDTPToolStripButton.Enabled = false;
|
|---|
| 778 | proToolStripButton.Enabled = false;
|
|---|
| 779 | doKorektyToolStripButton.Enabled = false;
|
|---|
| 780 | doDTP2ToolStripButton.Enabled = false;
|
|---|
| 781 | doKorekty2ToolStripButton.Enabled = false;
|
|---|
| 782 | doAgentaToolStripButton.Enabled = false;
|
|---|
| 783 |
|
|---|
| 784 | if ((User.getUser().St_handlowiec) && (!User.getUser().St_kierownik))
|
|---|
| 785 | {
|
|---|
| 786 | //handlowiec moze akceptowac tylko swoje projekty
|
|---|
| 787 | bool ok = agent.ToLower() == User.getUser().Symbol_agenta.ToLower() ? true : false;
|
|---|
| 788 | akceptToolStripButton.Enabled = akceptToolStripButton.Enabled & true & ok;
|
|---|
| 789 | nieakceptToolStripButton.Enabled = nieakceptToolStripButton.Enabled & true & ok;
|
|---|
| 790 | }
|
|---|
| 791 | else
|
|---|
| 792 | {
|
|---|
| 793 | akceptToolStripButton.Enabled = akceptToolStripButton.Enabled & true;
|
|---|
| 794 | nieakceptToolStripButton.Enabled = nieakceptToolStripButton.Enabled & true;
|
|---|
| 795 | }
|
|---|
| 796 | break;
|
|---|
| 797 | case "DO AKCEPTACJI":
|
|---|
| 798 | zwrotToolStripButton.Enabled = false;
|
|---|
| 799 | doDTPToolStripButton.Enabled = false;
|
|---|
| 800 | proToolStripButton.Enabled = false;
|
|---|
| 801 | doKorektyToolStripButton.Enabled = false;
|
|---|
| 802 | doDTP2ToolStripButton.Enabled = false;
|
|---|
| 803 | doKorekty2ToolStripButton.Enabled = false;
|
|---|
| 804 | doAgentaToolStripButton.Enabled = false;
|
|---|
| 805 |
|
|---|
| 806 | if ((User.getUser().St_handlowiec) && (!User.getUser().St_kierownik))
|
|---|
| 807 | {
|
|---|
| 808 | //handlowiec moze akceptowac tylko swoje projekty
|
|---|
| 809 | bool ok = agent.ToLower() == User.getUser().Symbol_agenta.ToLower() ? true : false;
|
|---|
| 810 | akceptToolStripButton.Enabled = akceptToolStripButton.Enabled & true & ok;
|
|---|
| 811 | nieakceptToolStripButton.Enabled = nieakceptToolStripButton.Enabled & true & ok;
|
|---|
| 812 | }
|
|---|
| 813 | else
|
|---|
| 814 | {
|
|---|
| 815 | akceptToolStripButton.Enabled = akceptToolStripButton.Enabled & true;
|
|---|
| 816 | nieakceptToolStripButton.Enabled = nieakceptToolStripButton.Enabled & true;
|
|---|
| 817 | }
|
|---|
| 818 | break;
|
|---|
| 819 | case "ZAAKCEPTOWANE":
|
|---|
| 820 | zwrotToolStripButton.Enabled = false;
|
|---|
| 821 | doDTPToolStripButton.Enabled = false;
|
|---|
| 822 | proToolStripButton.Enabled = false;
|
|---|
| 823 | doKorektyToolStripButton.Enabled = false;
|
|---|
| 824 | doDTP2ToolStripButton.Enabled = false;
|
|---|
| 825 | doKorekty2ToolStripButton.Enabled = false;
|
|---|
| 826 | doAgentaToolStripButton.Enabled = false;
|
|---|
| 827 |
|
|---|
| 828 | if ((User.getUser().St_handlowiec) && (!User.getUser().St_kierownik))
|
|---|
| 829 | {
|
|---|
| 830 | //handlowiec moze akceptowac tylko swoje projekty
|
|---|
| 831 | bool ok = agent.ToLower() == User.getUser().Symbol_agenta.ToLower() ? true : false;
|
|---|
| 832 | akceptToolStripButton.Enabled = akceptToolStripButton.Enabled & true & ok;
|
|---|
| 833 | nieakceptToolStripButton.Enabled = nieakceptToolStripButton.Enabled & true & ok;
|
|---|
| 834 | }
|
|---|
| 835 | else
|
|---|
| 836 | {
|
|---|
| 837 | akceptToolStripButton.Enabled = akceptToolStripButton.Enabled & true;
|
|---|
| 838 | nieakceptToolStripButton.Enabled = nieakceptToolStripButton.Enabled & true;
|
|---|
| 839 | }
|
|---|
| 840 |
|
|---|
| 841 | break;
|
|---|
| 842 | case "ZWROT Z PRODUKCJI":
|
|---|
| 843 | zwrotToolStripButton.Enabled = false;
|
|---|
| 844 | doDTPToolStripButton.Enabled = false;
|
|---|
| 845 | proToolStripButton.Enabled = false;
|
|---|
| 846 | doKorektyToolStripButton.Enabled = false;
|
|---|
| 847 | doDTP2ToolStripButton.Enabled = false;
|
|---|
| 848 | doKorekty2ToolStripButton.Enabled = false;
|
|---|
| 849 | doAgentaToolStripButton.Enabled = false;
|
|---|
| 850 | akceptToolStripButton.Enabled = false;
|
|---|
| 851 | nieakceptToolStripButton.Enabled = false;
|
|---|
| 852 | break;
|
|---|
| 853 | default:
|
|---|
| 854 | zwrotToolStripButton.Enabled = false;
|
|---|
| 855 | doDTPToolStripButton.Enabled = false;
|
|---|
| 856 | proToolStripButton.Enabled = false;
|
|---|
| 857 | doKorektyToolStripButton.Enabled = false;
|
|---|
| 858 | doDTP2ToolStripButton.Enabled = false;
|
|---|
| 859 | doKorekty2ToolStripButton.Enabled = false;
|
|---|
| 860 | doAgentaToolStripButton.Enabled = false;
|
|---|
| 861 | akceptToolStripButton.Enabled = false;
|
|---|
| 862 | nieakceptToolStripButton.Enabled = false;
|
|---|
| 863 | break;
|
|---|
| 864 | }
|
|---|
| 865 | }
|
|---|
| 866 | }
|
|---|
| 867 |
|
|---|
| 868 | private void EPSbutton_Click(object sender, EventArgs e)
|
|---|
| 869 | {
|
|---|
| 870 | System.Diagnostics.Process.Start(EPSTextBox.Text);
|
|---|
| 871 | }
|
|---|
| 872 |
|
|---|
| 873 | private void JPGbutton_Click(object sender, EventArgs e)
|
|---|
| 874 | {
|
|---|
| 875 | System.Diagnostics.Process.Start(JPGTextBox.Text);
|
|---|
| 876 | }
|
|---|
| 877 |
|
|---|
| 878 | private void CDRbutton_Click(object sender, EventArgs e)
|
|---|
| 879 | {
|
|---|
| 880 | System.Diagnostics.Process.Start(CDRTextBox.Text);
|
|---|
| 881 | }
|
|---|
| 882 |
|
|---|
| 883 | private void spisPlikowDataGridView_CellLeave(object sender, DataGridViewCellEventArgs e)
|
|---|
| 884 | {
|
|---|
| 885 | if (e.ColumnIndex == 0)
|
|---|
| 886 | {
|
|---|
| 887 | listaReklamDoWydaniaNrBindingSource.CancelEdit();
|
|---|
| 888 | }
|
|---|
| 889 | }
|
|---|
| 890 |
|
|---|
| 891 | private void podgladToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 892 | {
|
|---|
| 893 | if (pRODUKCJABindingSource.Current != null)
|
|---|
| 894 | {
|
|---|
| 895 | Cursor = Cursors.WaitCursor;
|
|---|
| 896 |
|
|---|
| 897 | DataRowView row = (DataRowView) pRODUKCJABindingSource.Current;
|
|---|
| 898 |
|
|---|
| 899 | int reklamaId = Convert.ToInt32(row["reklamaId"]);
|
|---|
| 900 | string idReklamy = row["NAZWA_ZAMOWIENIA"].ToString();
|
|---|
| 901 |
|
|---|
| 902 | string tytul;
|
|---|
| 903 | int grzbiet;
|
|---|
| 904 | string miasto;
|
|---|
| 905 | byte staryNowyArchiwum;
|
|---|
| 906 |
|
|---|
| 907 | Produkcja.argumentyDoSciezki(reklamaId, idReklamy, out tytul, out grzbiet, out miasto,
|
|---|
| 908 | out staryNowyArchiwum);
|
|---|
| 909 |
|
|---|
| 910 | string sciezka = Produkcja.GetReklamaFileName(idReklamy, tytul, grzbiet, miasto, staryNowyArchiwum,
|
|---|
| 911 | "pdf");
|
|---|
| 912 |
|
|---|
| 913 | if (File.Exists(sciezka))
|
|---|
| 914 | {
|
|---|
| 915 | System.Diagnostics.Process.Start(sciezka);
|
|---|
| 916 | }
|
|---|
| 917 | else
|
|---|
| 918 | {
|
|---|
| 919 | MessageBox.Show("Nie znaleziono pliku: " + sciezka);
|
|---|
| 920 | }
|
|---|
| 921 |
|
|---|
| 922 | Cursor = Cursors.Default;
|
|---|
| 923 | }
|
|---|
| 924 | }
|
|---|
| 925 |
|
|---|
| 926 | private void podgladJPGToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 927 | {
|
|---|
| 928 | if (pRODUKCJABindingSource.Current != null)
|
|---|
| 929 | {
|
|---|
| 930 | Cursor = Cursors.WaitCursor;
|
|---|
| 931 |
|
|---|
| 932 | DataRowView row = (DataRowView) pRODUKCJABindingSource.Current;
|
|---|
| 933 |
|
|---|
| 934 | int reklamaId = Convert.ToInt32(row["reklamaId"]);
|
|---|
| 935 | string idReklamy = row["NAZWA_ZAMOWIENIA"].ToString();
|
|---|
| 936 |
|
|---|
| 937 | string tytul;
|
|---|
| 938 | int grzbiet;
|
|---|
| 939 | string miasto;
|
|---|
| 940 | byte staryNowyArchiwum;
|
|---|
| 941 |
|
|---|
| 942 | Produkcja.argumentyDoSciezki(reklamaId, idReklamy, out tytul, out grzbiet, out miasto,
|
|---|
| 943 | out staryNowyArchiwum);
|
|---|
| 944 |
|
|---|
| 945 | string sciezka = Produkcja.GetReklamaFileName(idReklamy, tytul, grzbiet, miasto, staryNowyArchiwum,
|
|---|
| 946 | "jpg");
|
|---|
| 947 |
|
|---|
| 948 | if (File.Exists(sciezka))
|
|---|
| 949 | {
|
|---|
| 950 | System.Diagnostics.Process.Start(sciezka);
|
|---|
| 951 | }
|
|---|
| 952 | else
|
|---|
| 953 | {
|
|---|
| 954 | MessageBox.Show("Nie znaleziono pliku: " + sciezka);
|
|---|
| 955 | }
|
|---|
| 956 |
|
|---|
| 957 | Cursor = Cursors.Default;
|
|---|
| 958 | }
|
|---|
| 959 | }
|
|---|
| 960 |
|
|---|
| 961 | private void produkcjaDataGridView_Leave(object sender, EventArgs e)
|
|---|
| 962 | {
|
|---|
| 963 | ukrytyLabel.Select();
|
|---|
| 964 | }
|
|---|
| 965 |
|
|---|
| 966 | private void zamowienieToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 967 | {
|
|---|
| 968 | if (pRODUKCJABindingSource.Current != null)
|
|---|
| 969 | {
|
|---|
| 970 | DataRowView row = (DataRowView) pRODUKCJABindingSource.Current;
|
|---|
| 971 | int idRek = Convert.ToInt32(row["ReklamaId"]);
|
|---|
| 972 | reklamaTableAdapter.FillByReklamaId(rEKLAMADataSet.REKLAMA, idRek);
|
|---|
| 973 |
|
|---|
| 974 | OrderDetails.getOrderDetails().pokazSzczegolyZamowienia(idRek);
|
|---|
| 975 | OrderDetails.getOrderDetails().ShowDialog();
|
|---|
| 976 | }
|
|---|
| 977 | }
|
|---|
| 978 |
|
|---|
| 979 | private void projektToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 980 | {
|
|---|
| 981 | if (pRODUKCJABindingSource.Current != null)
|
|---|
| 982 | {
|
|---|
| 983 | DataRowView row = (DataRowView) pRODUKCJABindingSource.Current;
|
|---|
| 984 | int idRek = Convert.ToInt32(row["ReklamaId"]);
|
|---|
| 985 | int idPro = Convert.ToInt32(row["ID"]);
|
|---|
| 986 | ProjectForm pf = new ProjectForm(idRek, idPro);
|
|---|
| 987 |
|
|---|
| 988 | if (pf.ShowDialog() == DialogResult.OK)
|
|---|
| 989 | {
|
|---|
| 990 | rEKLAMADataSet.PRODUKCJA.Clear();
|
|---|
| 991 | sqlDataAdapter.Fill(rEKLAMADataSet.PRODUKCJA);
|
|---|
| 992 | }
|
|---|
| 993 | }
|
|---|
| 994 | }
|
|---|
| 995 |
|
|---|
| 996 | private void wczytajPlikButton_Click(object sender, EventArgs e)
|
|---|
| 997 | {
|
|---|
| 998 | if (projektOpenFileDialog.ShowDialog() == DialogResult.OK)
|
|---|
| 999 | {
|
|---|
| 1000 | if (pRODUKCJABindingSource.Current != null)
|
|---|
| 1001 | {
|
|---|
| 1002 | DataRowView row = (DataRowView) pRODUKCJABindingSource.Current;
|
|---|
| 1003 | row["PLIK"] = projektOpenFileDialog.FileName;
|
|---|
| 1004 | pRODUKCJABindingSource.EndEdit();
|
|---|
| 1005 | pRODUKCJATableAdapter.Update(rEKLAMADataSet.PRODUKCJA);
|
|---|
| 1006 | }
|
|---|
| 1007 | }
|
|---|
| 1008 | }
|
|---|
| 1009 |
|
|---|
| 1010 | private void drukujToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 1011 | {
|
|---|
| 1012 | PrintDGV.Print_DataGridView(produkcjaDataGridView, 50);
|
|---|
| 1013 | }
|
|---|
| 1014 |
|
|---|
| 1015 | private void wyczyscPolaToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 1016 | {
|
|---|
| 1017 | stanToolStripComboBox.SelectedIndex = -1;
|
|---|
| 1018 | symbolToolStripTextBox.Clear();
|
|---|
| 1019 | }
|
|---|
| 1020 |
|
|---|
| 1021 | private void tytulComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
|---|
| 1022 | {
|
|---|
| 1023 | switch (tytulComboBox.Text)
|
|---|
| 1024 | {
|
|---|
| 1025 | case "AMT":
|
|---|
| 1026 | gRZBIETYBindingSource.Filter = "Nazwa like '%AMT%'";
|
|---|
| 1027 | grzbietyComboBox.SelectedIndex = -1;
|
|---|
| 1028 | break;
|
|---|
| 1029 | case "GS":
|
|---|
| 1030 | gRZBIETYBindingSource.Filter = "Nazwa like '%GS%'";
|
|---|
| 1031 | grzbietyComboBox.SelectedIndex = -1;
|
|---|
| 1032 | break;
|
|---|
| 1033 | case "adMot":
|
|---|
| 1034 | gRZBIETYBindingSource.Filter = "Nazwa like '%adM%'";
|
|---|
| 1035 | grzbietyComboBox.SelectedIndex = -1;
|
|---|
| 1036 | break;
|
|---|
| 1037 | default:
|
|---|
| 1038 | gRZBIETYBindingSource.Filter = "";
|
|---|
| 1039 | grzbietyComboBox.SelectedIndex = -1;
|
|---|
| 1040 | break;
|
|---|
| 1041 | }
|
|---|
| 1042 | }
|
|---|
| 1043 |
|
|---|
| 1044 | private void szukajToolStripButton2_Click(object sender, EventArgs e)
|
|---|
| 1045 | {
|
|---|
| 1046 | if (symbolToolStripTextBox.Text.Trim() != "")
|
|---|
| 1047 | {
|
|---|
| 1048 | Cursor = Cursors.WaitCursor;
|
|---|
| 1049 |
|
|---|
| 1050 | command.Parameters.Clear();
|
|---|
| 1051 |
|
|---|
| 1052 | command.CommandText =
|
|---|
| 1053 | " select top 100 * from dbo.PRODUKCJA where NAZWA_ZAMOWIENIA like '%' + @symbol + '%' order by DATA_AGENT desc ";
|
|---|
| 1054 | command.Parameters.AddWithValue("@symbol", symbolToolStripTextBox.Text);
|
|---|
| 1055 |
|
|---|
| 1056 | rEKLAMADataSet.PRODUKCJA.Clear();
|
|---|
| 1057 | sqlDataAdapter.Fill(rEKLAMADataSet.PRODUKCJA);
|
|---|
| 1058 |
|
|---|
| 1059 | Cursor = Cursors.Default;
|
|---|
| 1060 | }
|
|---|
| 1061 | }
|
|---|
| 1062 |
|
|---|
| 1063 | /// <summary>
|
|---|
| 1064 | /// Buduje zapytanie filtrujace projekty wg uprawnien
|
|---|
| 1065 | /// </summary>
|
|---|
| 1066 | private string buildQuery()
|
|---|
| 1067 | {
|
|---|
| 1068 | string str =
|
|---|
| 1069 | "select * from dbo.PRODUKCJA where STAN!='ZAAKCEPTOWANE' AND STAN!='NIEZAAKCEPTOWANE' AND STAN!='ZWROT Z PRODUKCJI'";
|
|---|
| 1070 |
|
|---|
| 1071 | if (User.getUser().St_produkcja)
|
|---|
| 1072 | {
|
|---|
| 1073 | str =
|
|---|
| 1074 | "select * from dbo.PRODUKCJA where STAN!='ZAAKCEPTOWANE' AND STAN!='NIEZAAKCEPTOWANE' AND STAN!='ZWROT Z PRODUKCJI'";
|
|---|
| 1075 | return str;
|
|---|
| 1076 | }
|
|---|
| 1077 |
|
|---|
| 1078 | if (User.getUser().St_kierownik)
|
|---|
| 1079 | {
|
|---|
| 1080 | str = "select dbo.PRODUKCJA.* from dbo.PRODUKCJA left join dbo.AGENCI " +
|
|---|
| 1081 | " on dbo.PRODUKCJA.AGENT = dbo.AGENCI.Symbol left join dbo.AGENCJE " +
|
|---|
| 1082 | " on dbo.AGENCJE.Id_agencji = dbo.AGENCI.ID_AGENCJI where STAN!='ZAAKCEPTOWANE' " +
|
|---|
| 1083 | " AND STAN!='NIEZAAKCEPTOWANE' AND STAN!='ZWROT Z PRODUKCJI' AND dbo.AGENCJE.Id_agencji=" +
|
|---|
| 1084 | User.getUser().IdAgencji;
|
|---|
| 1085 | return str;
|
|---|
| 1086 | }
|
|---|
| 1087 |
|
|---|
| 1088 | if (User.getUser().St_handlowiec | User.getUser().St_subhandlowiec)
|
|---|
| 1089 | {
|
|---|
| 1090 | str =
|
|---|
| 1091 | "select * from dbo.PRODUKCJA where STAN!='ZAAKCEPTOWANE' AND STAN!='NIEZAAKCEPTOWANE' AND datediff(day,DATA_AGENT,getdate()) <= 30 ";
|
|---|
| 1092 | str += " AND AGENT='" + User.getUser().Symbol_agenta + "'";
|
|---|
| 1093 | return str;
|
|---|
| 1094 | }
|
|---|
| 1095 |
|
|---|
| 1096 | if (User.getUser().St_dtp)
|
|---|
| 1097 | {
|
|---|
| 1098 | str = "select * from dbo.PRODUKCJA where STAN='DO DTP' OR STAN='W DTP' OR STAN='PO KOREKCIE' ";
|
|---|
| 1099 | return str;
|
|---|
| 1100 | }
|
|---|
| 1101 |
|
|---|
| 1102 | if (User.getUser().St_korekta)
|
|---|
| 1103 | {
|
|---|
| 1104 | str = "select * from dbo.PRODUKCJA where STAN='DO KOREKTY' OR STAN='W 2 KOREKCIE' ";
|
|---|
| 1105 | return str;
|
|---|
| 1106 | }
|
|---|
| 1107 |
|
|---|
| 1108 | return str;
|
|---|
| 1109 | }
|
|---|
| 1110 |
|
|---|
| 1111 | private void wczytajPlikToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 1112 | {
|
|---|
| 1113 | if (projektOpenFileDialog.ShowDialog() == DialogResult.OK)
|
|---|
| 1114 | {
|
|---|
| 1115 | if (pRODUKCJABindingSource.Current != null)
|
|---|
| 1116 | {
|
|---|
| 1117 | DataRowView row = (DataRowView) pRODUKCJABindingSource.Current;
|
|---|
| 1118 | row["PLIK"] = projektOpenFileDialog.FileName;
|
|---|
| 1119 | pRODUKCJABindingSource.EndEdit();
|
|---|
| 1120 | pRODUKCJATableAdapter.Update(rEKLAMADataSet.PRODUKCJA);
|
|---|
| 1121 | plikToolStripTextBox.Text = Convert.ToString(row["PLIK"]);
|
|---|
| 1122 | }
|
|---|
| 1123 | }
|
|---|
| 1124 | }
|
|---|
| 1125 |
|
|---|
| 1126 | private void otworzPlikToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 1127 | {
|
|---|
| 1128 | if (pRODUKCJABindingSource.Current != null)
|
|---|
| 1129 | {
|
|---|
| 1130 | DataRowView row = (DataRowView) pRODUKCJABindingSource.Current;
|
|---|
| 1131 | if (row["PLIK"] != DBNull.Value)
|
|---|
| 1132 | {
|
|---|
| 1133 | string plik = Convert.ToString(row["PLIK"]);
|
|---|
| 1134 |
|
|---|
| 1135 | if (File.Exists(plik))
|
|---|
| 1136 | {
|
|---|
| 1137 | System.Diagnostics.Process.Start(plik);
|
|---|
| 1138 | }
|
|---|
| 1139 | else
|
|---|
| 1140 | {
|
|---|
| 1141 | MessageBox.Show("Nie mo¿na odnale¿æ pliku");
|
|---|
| 1142 | }
|
|---|
| 1143 | }
|
|---|
| 1144 | else
|
|---|
| 1145 | {
|
|---|
| 1146 | MessageBox.Show("Podaj cie¿kê do pliku.");
|
|---|
| 1147 | }
|
|---|
| 1148 | }
|
|---|
| 1149 | }
|
|---|
| 1150 |
|
|---|
| 1151 | private void spisPlikowDataGridView_DataError(object sender, DataGridViewDataErrorEventArgs e)
|
|---|
| 1152 | {
|
|---|
| 1153 | spisPlikowDataGridView.CancelEdit();
|
|---|
| 1154 | }
|
|---|
| 1155 |
|
|---|
| 1156 |
|
|---|
| 1157 | private void grzbietyComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
|---|
| 1158 | {
|
|---|
| 1159 | if (grzbietyComboBox.SelectedIndex != -1)
|
|---|
| 1160 | {
|
|---|
| 1161 | listaReklamDoWydaniaNrBindingSource.Filter = "GRZBIET=" + grzbietyComboBox.SelectedValue;
|
|---|
| 1162 | }
|
|---|
| 1163 | }
|
|---|
| 1164 |
|
|---|
| 1165 | private void znajdzKlientowToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 1166 | {
|
|---|
| 1167 | Cursor = Cursors.WaitCursor;
|
|---|
| 1168 |
|
|---|
| 1169 | Int16.TryParse(nrAMTToolStripTextBox.Text.Trim(), out nrAMT);
|
|---|
| 1170 | Int16.TryParse(nrGS1ToolStripTextBox.Text.Trim(), out nrGS1);
|
|---|
| 1171 | Int16.TryParse(nrGS2ToolStripTextBox.Text.Trim(), out nrGS2);
|
|---|
| 1172 |
|
|---|
| 1173 | listyTableAdapter.Fill(rEKLAMADataSet.Listy, nrAMT, nrGS1, nrGS2);
|
|---|
| 1174 | listyPodsumowanieTableAdapter.Fill(rEKLAMADataSet.ListyPodsumowanie, nrAMT, nrGS1, nrGS2);
|
|---|
| 1175 |
|
|---|
| 1176 | Cursor = Cursors.Default;
|
|---|
| 1177 | }
|
|---|
| 1178 |
|
|---|
| 1179 | private void podgladListuToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 1180 | {
|
|---|
| 1181 | listyDataGridView.EndEdit();
|
|---|
| 1182 |
|
|---|
| 1183 | if (listyBindingSource.Current != null)
|
|---|
| 1184 | {
|
|---|
| 1185 | Cursor = Cursors.WaitCursor;
|
|---|
| 1186 |
|
|---|
| 1187 | DataRowView row = (DataRowView) listyBindingSource.Current;
|
|---|
| 1188 | int custId = Convert.ToInt32(row["custId"]);
|
|---|
| 1189 | LetterViewer lv = new LetterViewer(custId, nrAMT, nrGS1, nrGS2, dateTimePicker1.Value);
|
|---|
| 1190 | lv.ShowDialog();
|
|---|
| 1191 |
|
|---|
| 1192 | Cursor = Cursors.Default;
|
|---|
| 1193 | }
|
|---|
| 1194 | }
|
|---|
| 1195 |
|
|---|
| 1196 | private void toolStripButton1_Click(object sender, EventArgs e)
|
|---|
| 1197 | {
|
|---|
| 1198 | listyDataGridView.EndEdit();
|
|---|
| 1199 |
|
|---|
| 1200 | foreach (DataRowView r in listyBindingSource.List)
|
|---|
| 1201 | {
|
|---|
| 1202 | r["drukuj"] = !Convert.ToBoolean(r["drukuj"]);
|
|---|
| 1203 | }
|
|---|
| 1204 |
|
|---|
| 1205 | listyBindingSource.ResetBindings(false);
|
|---|
| 1206 | }
|
|---|
| 1207 |
|
|---|
| 1208 | /// <summary>
|
|---|
| 1209 | /// Ustawia kolejnoæ do druku.
|
|---|
| 1210 | /// </summary>
|
|---|
| 1211 | private void ustawKolejnoscToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 1212 | {
|
|---|
| 1213 | if (listyDataGridView.SortedColumn != null)
|
|---|
| 1214 | {
|
|---|
| 1215 | DataGridViewColumn c = listyDataGridView.SortedColumn;
|
|---|
| 1216 | listyDataGridView.SortedColumn.SortMode = DataGridViewColumnSortMode.NotSortable;
|
|---|
| 1217 | listyBindingSource.Sort = "suma DESC, ilosc DESC";
|
|---|
| 1218 | c.SortMode = DataGridViewColumnSortMode.Automatic;
|
|---|
| 1219 | }
|
|---|
| 1220 | }
|
|---|
| 1221 |
|
|---|
| 1222 | private void toolStripButton2_Click(object sender, EventArgs e)
|
|---|
| 1223 | {
|
|---|
| 1224 | listyDataGridView.EndEdit();
|
|---|
| 1225 |
|
|---|
| 1226 | if (listyBindingSource.List.Count != 0)
|
|---|
| 1227 | {
|
|---|
| 1228 | List<int> klienci = new List<int>();
|
|---|
| 1229 | int custId;
|
|---|
| 1230 |
|
|---|
| 1231 | foreach (DataRowView r in listyBindingSource.List)
|
|---|
| 1232 | {
|
|---|
| 1233 | if (Convert.ToBoolean(r["drukuj"]))
|
|---|
| 1234 | {
|
|---|
| 1235 | custId = Convert.ToInt32(r["custId"]);
|
|---|
| 1236 | klienci.Add(custId);
|
|---|
| 1237 | }
|
|---|
| 1238 | }
|
|---|
| 1239 |
|
|---|
| 1240 | Cursor = Cursors.WaitCursor;
|
|---|
| 1241 |
|
|---|
| 1242 | LetterViewer lv = new LetterViewer(klienci, nrAMT, nrGS1, nrGS2, dateTimePicker1.Value);
|
|---|
| 1243 | lv.ShowDialog();
|
|---|
| 1244 | }
|
|---|
| 1245 |
|
|---|
| 1246 | Cursor = Cursors.Default;
|
|---|
| 1247 | }
|
|---|
| 1248 |
|
|---|
| 1249 | private void klientToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 1250 | {
|
|---|
| 1251 | if (pRODUKCJABindingSource.Current != null)
|
|---|
| 1252 | {
|
|---|
| 1253 | DataRowView row = (DataRowView) pRODUKCJABindingSource.Current;
|
|---|
| 1254 | int idRek = Convert.ToInt32(row["ReklamaId"]);
|
|---|
| 1255 |
|
|---|
| 1256 | int custId = Utils.customerId(idRek);
|
|---|
| 1257 |
|
|---|
| 1258 | ClientsForm.getClientsForm((MDIBazaReklam) MdiParent).pokazKlienta(custId);
|
|---|
| 1259 |
|
|---|
| 1260 | Hide();
|
|---|
| 1261 |
|
|---|
| 1262 | ClientsForm.getClientsForm((MDIBazaReklam) MdiParent).Show();
|
|---|
| 1263 | }
|
|---|
| 1264 | }
|
|---|
| 1265 |
|
|---|
| 1266 | private void wyslijProMailemToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 1267 | {
|
|---|
| 1268 | if (pRODUKCJABindingSource.Current != null)
|
|---|
| 1269 | {
|
|---|
| 1270 | Cursor = Cursors.WaitCursor;
|
|---|
| 1271 |
|
|---|
| 1272 | DataRowView row = (DataRowView) pRODUKCJABindingSource.Current;
|
|---|
| 1273 |
|
|---|
| 1274 | string idReklamy = row["NAZWA_ZAMOWIENIA"].ToString();
|
|---|
| 1275 | int reklamaId = Convert.ToInt32(row["reklamaId"]);
|
|---|
| 1276 |
|
|---|
| 1277 | string tytul;
|
|---|
| 1278 | int grzbiet;
|
|---|
| 1279 | string miasto;
|
|---|
| 1280 | byte staryNowyArchiwum;
|
|---|
| 1281 |
|
|---|
| 1282 | Produkcja.argumentyDoSciezki(reklamaId, idReklamy, out tytul, out grzbiet, out miasto,
|
|---|
| 1283 | out staryNowyArchiwum);
|
|---|
| 1284 |
|
|---|
| 1285 | string sciezka = Produkcja.GetReklamaFileName(idReklamy, tytul, grzbiet, miasto, staryNowyArchiwum,
|
|---|
| 1286 | "jpg");
|
|---|
| 1287 |
|
|---|
| 1288 | if (File.Exists(sciezka))
|
|---|
| 1289 | {
|
|---|
| 1290 | int custId = Utils.customerId(Convert.ToInt32(row["reklamaId"]));
|
|---|
| 1291 | string temat = "Projekt do zamówienia: " + idReklamy;
|
|---|
| 1292 | MailForm mf = new MailForm(custId, temat, sciezka);
|
|---|
| 1293 | mf.ShowDialog();
|
|---|
| 1294 | }
|
|---|
| 1295 | else
|
|---|
| 1296 | {
|
|---|
| 1297 | MessageBox.Show("Nie znaleziono pliku: " + sciezka);
|
|---|
| 1298 | }
|
|---|
| 1299 |
|
|---|
| 1300 | Cursor = Cursors.Default;
|
|---|
| 1301 | }
|
|---|
| 1302 | }
|
|---|
| 1303 |
|
|---|
| 1304 | private void usunToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 1305 | {
|
|---|
| 1306 | if (pRODUKCJABindingSource.Current != null)
|
|---|
| 1307 | {
|
|---|
| 1308 | if (MessageBox.Show("Czy na pewno chcesz usun¹æ rekord?", "", MessageBoxButtons.YesNo) ==
|
|---|
| 1309 | DialogResult.Yes)
|
|---|
| 1310 | {
|
|---|
| 1311 | pRODUKCJABindingSource.RemoveCurrent();
|
|---|
| 1312 | pRODUKCJABindingSource.EndEdit();
|
|---|
| 1313 | pRODUKCJATableAdapter.Update(rEKLAMADataSet.PRODUKCJA);
|
|---|
| 1314 | }
|
|---|
| 1315 | }
|
|---|
| 1316 | }
|
|---|
| 1317 |
|
|---|
| 1318 |
|
|---|
| 1319 | private void wylaczSortowanieGrida()
|
|---|
| 1320 | {
|
|---|
| 1321 | foreach (DataGridViewColumn c in produkcjaDataGridView.Columns)
|
|---|
| 1322 | {
|
|---|
| 1323 | c.SortMode = DataGridViewColumnSortMode.Programmatic;
|
|---|
| 1324 | }
|
|---|
| 1325 | }
|
|---|
| 1326 |
|
|---|
| 1327 | private void wlaczSortowanieGrida()
|
|---|
| 1328 | {
|
|---|
| 1329 | foreach (DataGridViewColumn c in produkcjaDataGridView.Columns)
|
|---|
| 1330 | {
|
|---|
| 1331 | c.SortMode = DataGridViewColumnSortMode.Automatic;
|
|---|
| 1332 | }
|
|---|
| 1333 | }
|
|---|
| 1334 |
|
|---|
| 1335 | private void fullInfoToolStripButton_Click(object sender, EventArgs e)
|
|---|
| 1336 | {
|
|---|
| 1337 | if (pRODUKCJABindingSource.Current != null)
|
|---|
| 1338 | {
|
|---|
| 1339 | DataRowView row = (DataRowView) pRODUKCJABindingSource.Current;
|
|---|
| 1340 | int id = Convert.ToInt32(row["id"]);
|
|---|
| 1341 | FullInfoProjectForm fipf = new FullInfoProjectForm(id);
|
|---|
| 1342 | fipf.ShowDialog();
|
|---|
| 1343 | }
|
|---|
| 1344 | }
|
|---|
| 1345 |
|
|---|
| 1346 | private void produkcjaDataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
|
|---|
| 1347 | {
|
|---|
| 1348 | if (produkcjaDataGridView["PRIORYTET", e.RowIndex].Value.ToString() == "PILNY")
|
|---|
| 1349 | {
|
|---|
| 1350 | e.CellStyle.ForeColor = Color.Red;
|
|---|
| 1351 | }
|
|---|
| 1352 | else
|
|---|
| 1353 | {
|
|---|
| 1354 | e.CellStyle.ForeColor = Color.Black;
|
|---|
| 1355 | }
|
|---|
| 1356 | }
|
|---|
| 1357 |
|
|---|
| 1358 |
|
|---|
| 1359 |
|
|---|
| 1360 | }
|
|---|
| 1361 | } |
|---|