| 11 | | //emisja, która ukazala sie w gazecie |
| 12 | | public readonly string WYDANA = "wydana"; |
| 13 | | //emisja, ktora sie dopiero ukaze |
| 14 | | public readonly string NIEWYDANA = "niewydana"; |
| 15 | | //emisja zafakturowana |
| 16 | | public readonly string ZAFAKTUROWANA = "zafakturowana"; |
| 17 | | //emisja zafakturowana i wydana |
| 18 | | public readonly string ZAFAKTUROWANA_WYDANA = "zafakturowana_wydana"; |
| 19 | | //emisja siê nie ukazala, ale jest w miesiacu, ktory jest juz zafakturowany |
| 20 | | public readonly string MS_ZAFAKTUROWANY_NIEWYDANA = "zafakturowana_wydana"; |
| 21 | | //emisja do zmiany |
| 22 | | public readonly string DO_ZMIANY = "do_zmiany"; |
| 23 | | //emisja do zmiany |
| 24 | | public readonly string NOWA = "nowa"; |
| 25 | | |
| 157 | | foreach (REKLAMADataSet.UKAZE_SIE_W_NRRow r in emisje) |
| 158 | | { |
| 159 | | if (r.RowState != DataRowState.Deleted) |
| 160 | | { |
| 161 | | if (r.Nr_Wydania == emisjaDoZmiany) |
| 162 | | { |
| 163 | | r.Nr_Wydania = nowaEmisja; |
| 164 | | r.EndEdit(); |
| 165 | | break; |
| 166 | | } |
| 167 | | } |
| 168 | | } |
| | 140 | //foreach (REKLAMADataSet.UKAZE_SIE_W_NRRow r in emisje) |
| | 141 | //{ |
| | 142 | // if (r.RowState != DataRowState.Deleted) |
| | 143 | // { |
| | 144 | // if (r.Nr_Wydania == emisjaDoZmiany && nowaEmisja.HasValue) |
| | 145 | // { |
| | 146 | // r.Nr_Wydania = nowaEmisja.Value; |
| | 147 | // r.EndEdit(); |
| | 148 | // break; |
| | 149 | // } |
| | 150 | // } |
| | 151 | //} |
| | 152 | nowaEmisja = GetNewIssueNumber(); |
| | 153 | |
| | 154 | } |
| | 155 | |
| | 156 | private short? GetNewIssueNumber() |
| | 157 | { |
| | 158 | short? newIssueNumer = null; |
| | 159 | bool? isIssueChecked; |
| | 160 | |
| | 161 | foreach (DataGridViewRow row in nRDataGridView.Rows) |
| | 162 | { |
| | 163 | if (row.ReadOnly || (row.DefaultCellStyle.BackColor != Color.White && row.DefaultCellStyle.BackColor != Color.LightYellow)) continue; |
| | 164 | |
| | 165 | isIssueChecked = (bool?)row.Cells[3].Value; |
| | 166 | if (!isIssueChecked.HasValue || !isIssueChecked.Value) continue; |
| | 167 | |
| | 168 | newIssueNumer = (short)row.Cells[0].Value; |
| | 169 | break; |
| | 170 | } |
| | 171 | |
| | 172 | return newIssueNumer; |
| 173 | | if (e.RowIndex >= 0) |
| 174 | | { |
| 175 | | if (!nRDataGridView.Rows[e.RowIndex].ReadOnly) |
| 176 | | { |
| 177 | | if (e.ColumnIndex == 3) |
| 178 | | { |
| 179 | | if (nRDataGridView.Rows[e.RowIndex].DefaultCellStyle.BackColor == Color.White) |
| 180 | | { |
| 181 | | if (emisjaDoZmiany != 0 && index != -1) |
| 182 | | { |
| 183 | | nRDataGridView.Rows[index].Cells[3].Value = false; |
| 184 | | nRDataGridView.Rows[index].DefaultCellStyle.BackColor = Color.White; |
| 185 | | } |
| 186 | | |
| 187 | | nowaEmisja = (short)nRDataGridView.Rows[e.RowIndex].Cells[0].Value; |
| 188 | | index = e.RowIndex; |
| 189 | | |
| 190 | | nRDataGridView.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.LightYellow; |
| 191 | | } |
| 192 | | else |
| 193 | | { |
| 194 | | nowaEmisja = (short)nRDataGridView.Rows[e.RowIndex].Cells[0].Value; |
| 195 | | index = e.RowIndex; |
| 196 | | |
| 197 | | nRDataGridView.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.White; |
| 198 | | } |
| 199 | | |
| 200 | | } |
| 201 | | } |
| | 177 | if (e.RowIndex < 0) return; |
| | 178 | |
| | 179 | if (nRDataGridView.Rows[e.RowIndex].ReadOnly) return; |
| | 180 | |
| | 181 | if (e.ColumnIndex != 3) return; |
| | 182 | |
| | 183 | if (nRDataGridView.Rows[e.RowIndex].DefaultCellStyle.BackColor == Color.White) |
| | 184 | { |
| | 185 | if (emisjaDoZmiany != 0 && index != -1) |
| | 186 | { |
| | 187 | nRDataGridView.Rows[index].Cells[3].Value = false; |
| | 188 | nRDataGridView.Rows[index].DefaultCellStyle.BackColor = Color.White; |
| | 189 | } |
| | 190 | |
| | 191 | nowaEmisja = (short) nRDataGridView.Rows[e.RowIndex].Cells[0].Value; |
| | 192 | index = e.RowIndex; |
| | 193 | |
| | 194 | nRDataGridView.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.LightYellow; |
| | 195 | } |
| | 196 | else |
| | 197 | { |
| | 198 | nowaEmisja = (short) nRDataGridView.Rows[e.RowIndex].Cells[0].Value; |
| | 199 | index = e.RowIndex; |
| | 200 | |
| | 201 | nRDataGridView.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.White; |
| 225 | | if (e.ListChangedType == ListChangedType.Reset) |
| 226 | | { |
| 227 | | foreach (DataGridViewRow row in nRDataGridView.Rows) |
| 228 | | { |
| 229 | | row.DefaultCellStyle.BackColor = Color.White; |
| 230 | | |
| 231 | | row.Cells[2].Value = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.DayNames |
| 232 | | [(int)Convert.ToDateTime(row.Cells[1].Value).DayOfWeek]; |
| 233 | | |
| 234 | | DataRow[] table = emisje.Select("[Nr Wydania]=" + row.Cells[0].Value); |
| 235 | | |
| 236 | | if (table != null && table.Length > 0) |
| | 220 | if (e.ListChangedType != ListChangedType.Reset) return; |
| | 221 | |
| | 222 | foreach (DataGridViewRow row in nRDataGridView.Rows) |
| | 223 | { |
| | 224 | row.DefaultCellStyle.BackColor = Color.White; |
| | 225 | |
| | 226 | row.Cells[2].Value = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.DayNames |
| | 227 | [(int) Convert.ToDateTime(row.Cells[1].Value).DayOfWeek]; |
| | 228 | |
| | 229 | DataRow[] table = emisje.Select("[Nr Wydania]=" + row.Cells[0].Value); |
| | 230 | |
| | 231 | if (table != null && table.Length > 0) |
| | 232 | { |
| | 233 | row.ReadOnly = true; |
| | 234 | row.Cells[3].Value = true; |
| | 235 | row.DefaultCellStyle.BackColor = Color.WhiteSmoke; |
| | 236 | |
| | 237 | REKLAMADataSet.UKAZE_SIE_W_NRRow em = |
| | 238 | (REKLAMADataSet.UKAZE_SIE_W_NRRow) table[0]; |
| | 239 | |
| | 240 | if (Convert.ToDateTime(row.Cells[1].Value) < DateTime.Today) |
| | 241 | { |
| | 242 | row.DefaultCellStyle.BackColor = Color.MintCream; |
| | 243 | } |
| | 244 | else |
| | 245 | { |
| | 246 | if (em.zafakturowana) |
| | 247 | { |
| | 248 | row.DefaultCellStyle.BackColor = Color.LightGray; |
| | 249 | } |
| | 250 | |
| | 251 | //anulowana |
| | 252 | if (em.status == 2) |
| | 253 | { |
| | 254 | row.DefaultCellStyle.ForeColor = Color.Red; |
| | 255 | } |
| | 256 | |
| | 257 | if (emisjaDoZmiany == (short) row.Cells[0].Value) |
| | 258 | { |
| | 259 | row.DefaultCellStyle.BackColor = Color.MistyRose; |
| | 260 | } |
| | 261 | } |
| | 262 | } |
| | 263 | else if (emisjaDoZmiany == 0) |
| | 264 | { |
| | 265 | //emisja nie zosta³a wczeniej wybrana, ale jej misi¹c ju¿ |
| | 266 | // jest zafakturowany |
| | 267 | DateTime dataWydania = (DateTime) row.Cells[1].Value; |
| | 268 | if (dataWydania.Year <= dataOstatatniejZafakturowanejEmisji.Year |
| | 269 | && |
| | 270 | dataWydania.Month <= dataOstatatniejZafakturowanejEmisji.Month) |
| 239 | | row.Cells[3].Value = true; |
| 240 | | row.DefaultCellStyle.BackColor = Color.WhiteSmoke; |
| 241 | | |
| 242 | | REKLAMADataSet.UKAZE_SIE_W_NRRow em = |
| 243 | | (REKLAMADataSet.UKAZE_SIE_W_NRRow)table[0]; |
| 244 | | |
| 245 | | if (Convert.ToDateTime(row.Cells[1].Value) < DateTime.Today) |
| 246 | | { |
| 247 | | row.DefaultCellStyle.BackColor = Color.MintCream; |
| 248 | | } |
| 249 | | else |
| 250 | | { |
| 251 | | if (em.zafakturowana) |
| 252 | | { |
| 253 | | row.DefaultCellStyle.BackColor = Color.LightGray; |
| 254 | | } |
| 255 | | |
| 256 | | //anulowana |
| 257 | | if (em.status == 2) |
| 258 | | { |
| 259 | | row.DefaultCellStyle.ForeColor = Color.Red; |
| 260 | | } |
| 261 | | |
| 262 | | if (emisjaDoZmiany == (short)row.Cells[0].Value) |
| 263 | | { |
| 264 | | row.DefaultCellStyle.BackColor = Color.MistyRose; |
| 265 | | } |
| 266 | | } |
| 267 | | } |
| 268 | | else if (emisjaDoZmiany == 0) |
| 269 | | { |
| 270 | | //emisja nie zosta³a wczeniej wybrana, ale jej misi¹c ju¿ |
| 271 | | // jest zafakturowany |
| 272 | | DateTime dataWydania = (DateTime)row.Cells[1].Value; |
| 273 | | if (dataWydania.Year <= dataOstatatniejZafakturowanejEmisji.Year |
| 274 | | && |
| 275 | | dataWydania.Month <= dataOstatatniejZafakturowanejEmisji.Month) |
| 276 | | { |
| 277 | | row.ReadOnly = true; |
| 278 | | row.DefaultCellStyle.BackColor = Color.LightGray; |
| 279 | | } |
| 280 | | } |
| 281 | | } |
| 282 | | } |
| 283 | | } |
| 284 | | |
| | 273 | row.DefaultCellStyle.BackColor = Color.LightGray; |
| | 274 | } |
| | 275 | } |
| | 276 | } |
| | 277 | } |