| 1 | using System;
|
|---|
| 2 | using System.Collections.Generic;
|
|---|
| 3 | using System.ComponentModel;
|
|---|
| 4 | using System.Data;
|
|---|
| 5 | using System.Drawing;
|
|---|
| 6 | using System.Text;
|
|---|
| 7 | using System.Windows.Forms;
|
|---|
| 8 |
|
|---|
| 9 | namespace Baza_Reklam
|
|---|
| 10 | {
|
|---|
| 11 | public partial class KalendarzEmisji : Form
|
|---|
| 12 | {
|
|---|
| 13 | //emisja, która ukazala sie w gazecie
|
|---|
| 14 | public readonly string WYDANA = "wydana";
|
|---|
| 15 | //emisja, ktora sie dopiero ukaze
|
|---|
| 16 | public readonly string NIEWYDANA = "niewydana";
|
|---|
| 17 | //emisja zafakturowana
|
|---|
| 18 | public readonly string ZAFAKTUROWANA = "zafakturowana";
|
|---|
| 19 | //emisja zafakturowana i wydana
|
|---|
| 20 | public readonly string ZAFAKTUROWANA_WYDANA = "zafakturowana_wydana";
|
|---|
| 21 | //emisja siê nie ukazala, ale jest w miesiacu, ktory jest juz zafakturowany
|
|---|
| 22 | public readonly string MS_ZAFAKTUROWANY_NIEWYDANA = "zafakturowana_wydana";
|
|---|
| 23 | //emisja do zmiany
|
|---|
| 24 | public readonly string DO_ZMIANY = "do_zmiany";
|
|---|
| 25 | //emisja do zmiany
|
|---|
| 26 | public readonly string NOWA = "nowa";
|
|---|
| 27 |
|
|---|
| 28 | string tytul;
|
|---|
| 29 |
|
|---|
| 30 | REKLAMADataSet.REKLAMARow reklama;
|
|---|
| 31 |
|
|---|
| 32 | REKLAMADataSet.UKAZE_SIE_W_NRDataTable emisje;
|
|---|
| 33 |
|
|---|
| 34 | public REKLAMADataSet.UKAZE_SIE_W_NRDataTable Emisje
|
|---|
| 35 | {
|
|---|
| 36 | get { return emisje; }
|
|---|
| 37 | set { emisje = value; }
|
|---|
| 38 | }
|
|---|
| 39 |
|
|---|
| 40 | short emisjaDoZmiany;
|
|---|
| 41 | short nowaEmisja;
|
|---|
| 42 |
|
|---|
| 43 | public short NowaEmisja
|
|---|
| 44 | {
|
|---|
| 45 | get { return nowaEmisja; }
|
|---|
| 46 | set { nowaEmisja = value; }
|
|---|
| 47 | }
|
|---|
| 48 | int iloscEmisji;
|
|---|
| 49 | int index = -1;
|
|---|
| 50 |
|
|---|
| 51 | #region properties
|
|---|
| 52 |
|
|---|
| 53 | public string Tytul
|
|---|
| 54 | {
|
|---|
| 55 | get { return tytul; }
|
|---|
| 56 | set { tytul = value; }
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| 59 | #endregion properties
|
|---|
| 60 |
|
|---|
| 61 | public KalendarzEmisji(string tytul, REKLAMADataSet.REKLAMARow reklama, REKLAMADataSet.UKAZE_SIE_W_NRDataTable emisje)
|
|---|
| 62 | {
|
|---|
| 63 | InitializeComponent();
|
|---|
| 64 | Tytul = tytul;
|
|---|
| 65 | label1.Text = tytul;
|
|---|
| 66 | this.reklama = reklama;
|
|---|
| 67 | this.emisje = emisje;
|
|---|
| 68 |
|
|---|
| 69 | foreach (DataRow r in emisje.Rows)
|
|---|
| 70 | {
|
|---|
| 71 | if (r.RowState != DataRowState.Deleted)
|
|---|
| 72 | {
|
|---|
| 73 | iloscEmisji++;
|
|---|
| 74 | }
|
|---|
| 75 | }
|
|---|
| 76 |
|
|---|
| 77 | label2.Text = iloscEmisji.ToString();
|
|---|
| 78 |
|
|---|
| 79 | dodajButton.Click += dodajButton_Click;
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 | public KalendarzEmisji(string tytul, REKLAMADataSet.REKLAMARow reklama, REKLAMADataSet.UKAZE_SIE_W_NRDataTable emisje, short emisjaDoZmiany)
|
|---|
| 84 | {
|
|---|
| 85 | InitializeComponent();
|
|---|
| 86 | Tytul = tytul;
|
|---|
| 87 | label1.Text = tytul;
|
|---|
| 88 | dodajButton.Text = "Zmieñ";
|
|---|
| 89 |
|
|---|
| 90 | this.reklama = reklama;
|
|---|
| 91 | this.emisje = emisje;
|
|---|
| 92 |
|
|---|
| 93 | this.emisjaDoZmiany = emisjaDoZmiany;
|
|---|
| 94 |
|
|---|
| 95 | dodajButton.Click += zmienButton_Click;
|
|---|
| 96 | }
|
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 | private void KalendarzEmisji_Load(object sender, EventArgs e)
|
|---|
| 100 | {
|
|---|
| 101 | nRTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 102 | DateTime startDay = DateTime.Today;
|
|---|
| 103 |
|
|---|
| 104 | this.nRTableAdapter.FillByTytulData(this.sLOWNIKDataSet.NR, Tytul, startDay);
|
|---|
| 105 |
|
|---|
| 106 | foreach (DataGridViewRow row in nRDataGridView.Rows)
|
|---|
| 107 | {
|
|---|
| 108 | row.Cells[2].Value = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.DayNames
|
|---|
| 109 | [(int)Convert.ToDateTime(row.Cells[1].Value).DayOfWeek];
|
|---|
| 110 | }
|
|---|
| 111 |
|
|---|
| 112 | nRDataGridView.CellValueChanged += nRDataGridView_CellValueChanged;
|
|---|
| 113 | nRDataGridView.CellContentClick += nRDataGridView_CellContentClicked;
|
|---|
| 114 | }
|
|---|
| 115 |
|
|---|
| 116 | private void dodajButton_Click(object sender, EventArgs e)
|
|---|
| 117 | {
|
|---|
| 118 | foreach (DataGridViewRow row in nRDataGridView.Rows)
|
|---|
| 119 | {
|
|---|
| 120 | if (row.Cells[3].Value != null && ((bool)row.Cells[3].Value) == true)
|
|---|
| 121 | {
|
|---|
| 122 | if (row.DefaultCellStyle.BackColor == Color.LightYellow)
|
|---|
| 123 | {
|
|---|
| 124 | REKLAMADataSet.UKAZE_SIE_W_NRRow em =
|
|---|
| 125 | emisje.NewUKAZE_SIE_W_NRRow();
|
|---|
| 126 |
|
|---|
| 127 | em.ReklamaId = reklama.ReklamaID;
|
|---|
| 128 | em.dataDodania = DateTime.Today;
|
|---|
| 129 | em.Nr_Wydania = Convert.ToInt16(row.Cells[0].Value);
|
|---|
| 130 |
|
|---|
| 131 | emisje.AddUKAZE_SIE_W_NRRow(em);
|
|---|
| 132 | }
|
|---|
| 133 | }
|
|---|
| 134 | }
|
|---|
| 135 | }
|
|---|
| 136 |
|
|---|
| 137 | private void zmienButton_Click(object sender, EventArgs e)
|
|---|
| 138 | {
|
|---|
| 139 | foreach (REKLAMADataSet.UKAZE_SIE_W_NRRow r in emisje)
|
|---|
| 140 | {
|
|---|
| 141 | if (r.RowState != DataRowState.Deleted)
|
|---|
| 142 | {
|
|---|
| 143 | if (r.Nr_Wydania == emisjaDoZmiany)
|
|---|
| 144 | {
|
|---|
| 145 | r.Nr_Wydania = nowaEmisja;
|
|---|
| 146 | r.EndEdit();
|
|---|
| 147 | break;
|
|---|
| 148 | }
|
|---|
| 149 | }
|
|---|
| 150 | }
|
|---|
| 151 | }
|
|---|
| 152 |
|
|---|
| 153 | private void nRDataGridView_CellContentClicked(object sender, DataGridViewCellEventArgs e)
|
|---|
| 154 | {
|
|---|
| 155 | if (e.RowIndex >= 0)
|
|---|
| 156 | {
|
|---|
| 157 | if (!nRDataGridView.Rows[e.RowIndex].ReadOnly)
|
|---|
| 158 | {
|
|---|
| 159 | if (e.ColumnIndex == 3)
|
|---|
| 160 | {
|
|---|
| 161 | if (nRDataGridView.Rows[e.RowIndex].DefaultCellStyle.BackColor == Color.White)
|
|---|
| 162 | {
|
|---|
| 163 | if (emisjaDoZmiany != 0 && index != -1)
|
|---|
| 164 | {
|
|---|
| 165 | nRDataGridView.Rows[index].Cells[3].Value = false;
|
|---|
| 166 | nRDataGridView.Rows[index].DefaultCellStyle.BackColor = Color.White;
|
|---|
| 167 | }
|
|---|
| 168 |
|
|---|
| 169 | nowaEmisja = (short)nRDataGridView.Rows[e.RowIndex].Cells[0].Value;
|
|---|
| 170 | index = e.RowIndex;
|
|---|
| 171 |
|
|---|
| 172 | nRDataGridView.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.LightYellow;
|
|---|
| 173 | }
|
|---|
| 174 | else
|
|---|
| 175 | {
|
|---|
| 176 | nowaEmisja = (short)nRDataGridView.Rows[e.RowIndex].Cells[0].Value;
|
|---|
| 177 | index = e.RowIndex;
|
|---|
| 178 |
|
|---|
| 179 | nRDataGridView.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.White;
|
|---|
| 180 | }
|
|---|
| 181 |
|
|---|
| 182 | }
|
|---|
| 183 | }
|
|---|
| 184 | }
|
|---|
| 185 | nRDataGridView.EndEdit();
|
|---|
| 186 | }
|
|---|
| 187 |
|
|---|
| 188 | private void nRDataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e)
|
|---|
| 189 | {
|
|---|
| 190 | if (e.ColumnIndex == 3)
|
|---|
| 191 | {
|
|---|
| 192 | if (((bool)nRDataGridView[e.ColumnIndex, e.RowIndex].Value) == true)
|
|---|
| 193 | {
|
|---|
| 194 | iloscEmisji++;
|
|---|
| 195 | }
|
|---|
| 196 | else
|
|---|
| 197 | {
|
|---|
| 198 | iloscEmisji--;
|
|---|
| 199 | }
|
|---|
| 200 |
|
|---|
| 201 | label2.Text = iloscEmisji.ToString();
|
|---|
| 202 | }
|
|---|
| 203 | }
|
|---|
| 204 |
|
|---|
| 205 | private void nRDataGridView_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
|
|---|
| 206 | {
|
|---|
| 207 | if (e.ListChangedType == ListChangedType.Reset)
|
|---|
| 208 | {
|
|---|
| 209 | foreach (DataGridViewRow row in nRDataGridView.Rows)
|
|---|
| 210 | {
|
|---|
| 211 |
|
|---|
| 212 | row.DefaultCellStyle.BackColor = Color.White;
|
|---|
| 213 |
|
|---|
| 214 | DataRow[] table = emisje.Select("[Nr Wydania]=" + row.Cells[0].Value);
|
|---|
| 215 |
|
|---|
| 216 | if (table != null && table.Length > 0)
|
|---|
| 217 | {
|
|---|
| 218 | row.ReadOnly = true;
|
|---|
| 219 | row.Cells[3].Value = true;
|
|---|
| 220 | row.DefaultCellStyle.BackColor = Color.WhiteSmoke;
|
|---|
| 221 |
|
|---|
| 222 | REKLAMADataSet.UKAZE_SIE_W_NRRow em =
|
|---|
| 223 | (REKLAMADataSet.UKAZE_SIE_W_NRRow)table[0];
|
|---|
| 224 |
|
|---|
| 225 |
|
|---|
| 226 | if (Convert.ToDateTime(row.Cells[1].Value) < DateTime.Today)
|
|---|
| 227 | {
|
|---|
| 228 | row.DefaultCellStyle.BackColor = Color.MintCream;
|
|---|
| 229 | }
|
|---|
| 230 |
|
|---|
| 231 | if (em.zafakturowana)
|
|---|
| 232 | {
|
|---|
| 233 | row.DefaultCellStyle.BackColor = Color.LightGray;
|
|---|
| 234 | }
|
|---|
| 235 |
|
|---|
| 236 | //anulowana
|
|---|
| 237 | if (em.status == 2)
|
|---|
| 238 | {
|
|---|
| 239 | row.DefaultCellStyle.ForeColor = Color.Red;
|
|---|
| 240 | }
|
|---|
| 241 |
|
|---|
| 242 | if (emisjaDoZmiany == (short)row.Cells[0].Value)
|
|---|
| 243 | {
|
|---|
| 244 | row.DefaultCellStyle.BackColor = Color.MistyRose;
|
|---|
| 245 | }
|
|---|
| 246 | }
|
|---|
| 247 | }
|
|---|
| 248 | }
|
|---|
| 249 | }
|
|---|
| 250 |
|
|---|
| 251 | }
|
|---|
| 252 | } |
|---|