| 1 | using System;
|
|---|
| 2 | using System.Collections.Specialized;
|
|---|
| 3 | using System.Collections.Generic;
|
|---|
| 4 | using System.ComponentModel;
|
|---|
| 5 | using System.Data;
|
|---|
| 6 | using System.Data.SqlClient;
|
|---|
| 7 | using System.Drawing;
|
|---|
| 8 | using System.Text;
|
|---|
| 9 | using System.Windows.Forms;
|
|---|
| 10 | using System.Text.RegularExpressions;
|
|---|
| 11 | using System.Diagnostics;
|
|---|
| 12 |
|
|---|
| 13 | namespace Baza_Reklam
|
|---|
| 14 | {
|
|---|
| 15 | public partial class OrderDetails : Form
|
|---|
| 16 | {
|
|---|
| 17 | SLOWNIKDataSet.Kursy_WalutRow kurs;
|
|---|
| 18 |
|
|---|
| 19 | //zmienna wy³¹czaj¹ca obs³ugê zdarzeñ, gdy formularz jest ukryty
|
|---|
| 20 | private bool obslugaZdarzen;
|
|---|
| 21 |
|
|---|
| 22 | //zmienna ustawiana na TRUE przy wznawianiu lub dodawnaniu nowego zamówienia
|
|---|
| 23 | private bool nowyRekord;
|
|---|
| 24 | private bool bylyZmiany;
|
|---|
| 25 | private bool juzSieUkazaloWgazecie;
|
|---|
| 26 | private double maksymalnyRabat = (double)0.3;
|
|---|
| 27 |
|
|---|
| 28 | //numery reklam dla nowych zamówieñ
|
|---|
| 29 | StringDictionary numeryReklam = new StringDictionary();
|
|---|
| 30 |
|
|---|
| 31 | private static OrderDetails orderDetails;
|
|---|
| 32 |
|
|---|
| 33 | public static OrderDetails getOrderDetails()
|
|---|
| 34 | {
|
|---|
| 35 | if (orderDetails == null)
|
|---|
| 36 | {
|
|---|
| 37 | orderDetails = new OrderDetails();
|
|---|
| 38 | }
|
|---|
| 39 |
|
|---|
| 40 | return orderDetails;
|
|---|
| 41 | }
|
|---|
| 42 |
|
|---|
| 43 | private ErrorProvider errProvider;
|
|---|
| 44 |
|
|---|
| 45 | // przechowuje id aktualnie wywietlanej reklamy
|
|---|
| 46 | private int reklamaId;
|
|---|
| 47 |
|
|---|
| 48 | // przechowuje id klienta , którego dotyczy aktualnie wywietlana reklama
|
|---|
| 49 | private int customerId;
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 | Baza_Reklam.REKLAMADataSetTableAdapters.zmianyEmisjiTableAdapter
|
|---|
| 53 | zmianyEmisjiTableAdapter = new Baza_Reklam.REKLAMADataSetTableAdapters.zmianyEmisjiTableAdapter();
|
|---|
| 54 |
|
|---|
| 55 | //private event ZmianaParametrowZamowienia
|
|---|
| 56 |
|
|---|
| 57 | private OrderDetails()
|
|---|
| 58 | {
|
|---|
| 59 | InitializeComponent();
|
|---|
| 60 |
|
|---|
| 61 | this.rEKLAMADataSet.UKAZE_SIE_W_NR.Constraints.Remove("FAKTURY_UKAZE_SIE_W_NR");
|
|---|
| 62 |
|
|---|
| 63 | errProvider = new ErrorProvider();
|
|---|
| 64 |
|
|---|
| 65 | // funckje formatuj¹ce Decimal <-> %
|
|---|
| 66 | rABATTextBox.DataBindings[0].Format += new ConvertEventHandler(DecimalToProcent);
|
|---|
| 67 | rABATTextBox.DataBindings[0].Parse += new ConvertEventHandler(ProcentToDecimal);
|
|---|
| 68 |
|
|---|
| 69 | pROCENT_PROWIZJITextBox.DataBindings[0].Format += new ConvertEventHandler(DecimalToProcent);
|
|---|
| 70 | pROCENT_PROWIZJITextBox.DataBindings[0].Parse += new ConvertEventHandler(ProcentToDecimal);
|
|---|
| 71 |
|
|---|
| 72 | pVATComboBox.DataBindings[0].Format += new ConvertEventHandler(DecimalToProcent);
|
|---|
| 73 | pVATComboBox.DataBindings[0].Parse += new ConvertEventHandler(ProcentToDecimal);
|
|---|
| 74 |
|
|---|
| 75 | rEKLAMADataSet.UKAZE_SIE_W_NR.TableNewRow += nowaEmisja;
|
|---|
| 76 |
|
|---|
| 77 | nAZWY_MODULOWTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 78 | gRZBIETYTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 79 | pROMOCJETableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 80 | lISTA_TYPOW_REKLAMYTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 81 | lISTA_TYTULOWTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 82 | kursy_WalutTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 83 | rEKLAMATableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 84 | uKAZE_SIE_W_NRTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 85 | rEKLAMA_STRONATableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 86 | reklama_Info_DodTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 87 | aGENCITableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 88 | ogl_dzialyTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 89 | ogl_rozdzialyTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 90 | zmianyEmisjiTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 91 |
|
|---|
| 92 | this.nAZWY_MODULOWTableAdapter.Fill(this.sLOWNIKDataSet.NAZWY_MODULOW);
|
|---|
| 93 | this.gRZBIETYTableAdapter.Fill(this.sLOWNIKDataSet.GRZBIETY);
|
|---|
| 94 | this.pROMOCJETableAdapter.Fill(this.sLOWNIKDataSet.PROMOCJE);
|
|---|
| 95 |
|
|---|
| 96 | if (User.getUser().St_kierownik || User.getUser().St_produkcja)
|
|---|
| 97 | {
|
|---|
| 98 | this.lISTA_TYPOW_REKLAMYTableAdapter.Fill(this.sLOWNIKDataSet.LISTA_TYPOW_REKLAMY);
|
|---|
| 99 | }
|
|---|
| 100 | else
|
|---|
| 101 | {
|
|---|
| 102 | this.lISTA_TYPOW_REKLAMYTableAdapter.FillByBezBezplatnych(this.sLOWNIKDataSet.LISTA_TYPOW_REKLAMY);
|
|---|
| 103 | }
|
|---|
| 104 | this.lISTA_TYTULOWTableAdapter.Fill(this.sLOWNIKDataSet.LISTA_TYTULOW);
|
|---|
| 105 | this.aGENCITableAdapter.FillByAktywny(this.sLOWNIKDataSet.AGENCI);
|
|---|
| 106 | this.ogl_dzialyTableAdapter.Fill(this.sLOWNIKDataSet.ogl_dzialy);
|
|---|
| 107 | this.ogl_rozdzialyTableAdapter.Fill(this.sLOWNIKDataSet.ogl_rozdzialy);
|
|---|
| 108 |
|
|---|
| 109 | usunToolStripMenuItem.Click += usunEmisje;
|
|---|
| 110 | anulujToolStripMenuItem.Click += anulujEmisje;
|
|---|
| 111 | zmienToolStripMenuItem.Click += zmienEmisje;
|
|---|
| 112 |
|
|---|
| 113 | walutyComboBox.SelectedIndex = 0;
|
|---|
| 114 | }
|
|---|
| 115 |
|
|---|
| 116 | private void OrderDetails_Load(object sender, EventArgs e)
|
|---|
| 117 | {
|
|---|
| 118 | wyroznienie_exportedCheckBox.Enabled = User.getUser().St_produkcja;
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | /// <summary>
|
|---|
| 122 | /// Filtruje modu³y i grzbiety wg tytu³u gazety.
|
|---|
| 123 | /// </summary>
|
|---|
| 124 | private void tYTULComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
|---|
| 125 | {
|
|---|
| 126 | if (obslugaZdarzen)
|
|---|
| 127 | {
|
|---|
| 128 | if (tYTULComboBox.SelectedValue != null)
|
|---|
| 129 | {
|
|---|
| 130 | this.nAZWYMODULOWBindingSource.Filter = "tytul='" + tYTULComboBox.SelectedValue.ToString() + "'";
|
|---|
| 131 | this.iD_REKLAMYTextBox.Text = (nowyRekord) ? this.numeryReklam[tYTULComboBox.SelectedValue.ToString()] : this.iD_REKLAMYTextBox.Text;
|
|---|
| 132 | this.gRZBIETYBindingSource.Filter = "Nazwa like '%" + tYTULComboBox.SelectedValue.ToString() + "%'";
|
|---|
| 133 | int i = lISTATYTULOWBindingSource.Find("SYMB", tYTULComboBox.SelectedValue);
|
|---|
| 134 | this.maksymalnyRabat = Convert.ToDouble(((DataRowView)lISTATYTULOWBindingSource.List[i])["max_rabat"]);
|
|---|
| 135 |
|
|---|
| 136 | DataRowView row = (DataRowView)lISTATYTULOWBindingSource.Current;
|
|---|
| 137 | this.ogl_dzialyBindingSource.Filter = "TYTUL=" + row["id"].ToString();
|
|---|
| 138 |
|
|---|
| 139 | switch (tYTULComboBox.SelectedValue.ToString())
|
|---|
| 140 | {
|
|---|
| 141 | case "AMT":
|
|---|
| 142 | this.ogl_dzialyBindingSource.Filter = "TYTUL='2'";
|
|---|
| 143 | break;
|
|---|
| 144 | case "GS":
|
|---|
| 145 | this.ogl_dzialyBindingSource.Filter = "TYTUL='1'";
|
|---|
| 146 | break;
|
|---|
| 147 | case "AGRO":
|
|---|
| 148 | this.ogl_dzialyBindingSource.Filter = "TYTUL='7'";
|
|---|
| 149 | break;
|
|---|
| 150 | case "adMot":
|
|---|
| 151 | this.ogl_dzialyBindingSource.Filter = "TYTUL='6'";
|
|---|
| 152 | break;
|
|---|
| 153 | default:
|
|---|
| 154 | this.ogl_dzialyBindingSource.Filter = "";
|
|---|
| 155 | break;
|
|---|
| 156 | }
|
|---|
| 157 | }
|
|---|
| 158 | }
|
|---|
| 159 | }
|
|---|
| 160 |
|
|---|
| 161 | private void grzbietComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
|---|
| 162 | {
|
|---|
| 163 | if (obslugaZdarzen)
|
|---|
| 164 | {
|
|---|
| 165 | if ((int)grzbietComboBox.SelectedValue == 9)
|
|---|
| 166 | {
|
|---|
| 167 | this.iD_REKLAMYTextBox.Text = (nowyRekord) ? this.numeryReklam["slaski"] : this.iD_REKLAMYTextBox.Text;
|
|---|
| 168 | }
|
|---|
| 169 | else
|
|---|
| 170 | {
|
|---|
| 171 | this.iD_REKLAMYTextBox.Text = (nowyRekord) ? this.numeryReklam[tYTULComboBox.SelectedValue.ToString()] : this.iD_REKLAMYTextBox.Text;
|
|---|
| 172 | }
|
|---|
| 173 | }
|
|---|
| 174 | }
|
|---|
| 175 |
|
|---|
| 176 | private void anulujButton_Click(object sender, EventArgs e)
|
|---|
| 177 | {
|
|---|
| 178 | if (nowyRekord)
|
|---|
| 179 | {
|
|---|
| 180 | //usuwa dodany wczesniej do bazy wiersz
|
|---|
| 181 | if (rEKLAMABindingSource.Current != null)
|
|---|
| 182 | {
|
|---|
| 183 | rEKLAMABindingSource.RemoveCurrent();
|
|---|
| 184 | rEKLAMABindingSource.EndEdit();
|
|---|
| 185 | rEKLAMATableAdapter.Update(this.rEKLAMADataSet.REKLAMA);
|
|---|
| 186 | }
|
|---|
| 187 | }
|
|---|
| 188 | else
|
|---|
| 189 | {
|
|---|
| 190 | //usuwa zmiany w zleceniu
|
|---|
| 191 | rEKLAMADataSet.REKLAMA.RejectChanges();
|
|---|
| 192 | rEKLAMADataSet.UKAZE_SIE_W_NR.RejectChanges();
|
|---|
| 193 | }
|
|---|
| 194 |
|
|---|
| 195 | this.obslugaZdarzen = false;
|
|---|
| 196 | liczbaEmisjiLabel.Text = "-";
|
|---|
| 197 |
|
|---|
| 198 | this.DialogResult = bylyZmiany ? DialogResult.OK : DialogResult.Cancel;
|
|---|
| 199 | }
|
|---|
| 200 |
|
|---|
| 201 | /// <summary>
|
|---|
| 202 | /// Zapisuje zmiany w wierszu oraz dodaje rekordy do "UKAZE SIE W NR" i "InfoDod"
|
|---|
| 203 | /// </summary>
|
|---|
| 204 | private void dodajButton_Click(object sender, EventArgs e)
|
|---|
| 205 | {
|
|---|
| 206 | this.Cursor = Cursors.WaitCursor;
|
|---|
| 207 |
|
|---|
| 208 | this.Validate();
|
|---|
| 209 | rEKLAMABindingSource.EndEdit();
|
|---|
| 210 |
|
|---|
| 211 | DataRowView row = (DataRowView)rEKLAMABindingSource.Current;
|
|---|
| 212 |
|
|---|
| 213 | /*
|
|---|
| 214 | if (!(brutto_EuroTextBox.Text != "0" ^ walutyComboBox.SelectedIndex == -1))
|
|---|
| 215 | {
|
|---|
| 216 | MessageBox.Show("Popraw walutê!");
|
|---|
| 217 | this.Cursor = Cursors.Default;
|
|---|
| 218 | return;
|
|---|
| 219 | }*/
|
|---|
| 220 |
|
|---|
| 221 | if (wyroznienieCheckBox.Checked ^ Convert.ToDecimal(row["wyroznienie_kwota"]) != 0)
|
|---|
| 222 | {
|
|---|
| 223 | MessageBox.Show("Zosta³a zmieniona opcja wyró¿nienia. Zamówienie nale¿y ponownie przeliczyæ");
|
|---|
| 224 | this.Cursor = Cursors.Default;
|
|---|
| 225 | return;
|
|---|
| 226 | }
|
|---|
| 227 |
|
|---|
| 228 | row["USERID"] = User.getUser().Login;
|
|---|
| 229 |
|
|---|
| 230 | rEKLAMAUKAZESIEWNRBindingSource.EndEdit();
|
|---|
| 231 | rEKLAMAReklamaInfoDodBindingSource.EndEdit();
|
|---|
| 232 |
|
|---|
| 233 | //MessageBox.Show(rEKLAMAUKAZESIEWNRBindingSource.List.Count.ToString() + " " + rEKLAMADataSet.UKAZE_SIE_W_NR.Count.ToString());
|
|---|
| 234 |
|
|---|
| 235 | this.rEKLAMATableAdapter.Update(this.rEKLAMADataSet.REKLAMA);
|
|---|
| 236 | this.uKAZE_SIE_W_NRTableAdapter.Update(this.rEKLAMADataSet.UKAZE_SIE_W_NR);
|
|---|
| 237 | this.reklama_Info_DodTableAdapter.Update(this.rEKLAMADataSet.Reklama_Info_Dod);
|
|---|
| 238 | this.zmianyEmisjiTableAdapter.Update(this.rEKLAMADataSet.zmianyEmisji);
|
|---|
| 239 | MessageBox.Show("Zmiany zapisane");
|
|---|
| 240 |
|
|---|
| 241 | zmiany();
|
|---|
| 242 |
|
|---|
| 243 | nowyRekord = false;
|
|---|
| 244 | bylyZmiany = true;
|
|---|
| 245 | //this.obslugaZdarzen = false;
|
|---|
| 246 |
|
|---|
| 247 | this.Cursor = Cursors.Default;
|
|---|
| 248 | }
|
|---|
| 249 |
|
|---|
| 250 | private void sZERTextBox_Validating(object sender, CancelEventArgs e)
|
|---|
| 251 | {
|
|---|
| 252 | if (!sZERTextBox.Text.Equals(""))
|
|---|
| 253 | {
|
|---|
| 254 | if (!Regex.IsMatch(sZERTextBox.Text, "^[0-8]{1}$", RegexOptions.IgnoreCase))
|
|---|
| 255 | {
|
|---|
| 256 | e.Cancel = true;
|
|---|
| 257 |
|
|---|
| 258 | errProvider.SetError((Control)sender, "1-8");
|
|---|
| 259 | return;
|
|---|
| 260 | }
|
|---|
| 261 |
|
|---|
| 262 | }
|
|---|
| 263 | errProvider.SetError((Control)sender, "");
|
|---|
| 264 | }
|
|---|
| 265 |
|
|---|
| 266 | private void wYSTextBox_Validating(object sender, CancelEventArgs e)
|
|---|
| 267 | {
|
|---|
| 268 | if (!sZERTextBox.Text.Equals(""))
|
|---|
| 269 | {
|
|---|
| 270 | if (!Regex.IsMatch(sZERTextBox.Text, "^[0-8]{1}$", RegexOptions.IgnoreCase))
|
|---|
| 271 | {
|
|---|
| 272 | e.Cancel = true;
|
|---|
| 273 |
|
|---|
| 274 | errProvider.SetError((Control)sender, "1-8");
|
|---|
| 275 | return;
|
|---|
| 276 | }
|
|---|
| 277 |
|
|---|
| 278 | }
|
|---|
| 279 | errProvider.SetError((Control)sender, "");
|
|---|
| 280 | }
|
|---|
| 281 |
|
|---|
| 282 | private void promocjaComboBox_TextChanged(object sender, EventArgs e)
|
|---|
| 283 | {
|
|---|
| 284 | if (obslugaZdarzen)
|
|---|
| 285 | {
|
|---|
| 286 | if (promocjaComboBox.Text == "")
|
|---|
| 287 | {
|
|---|
| 288 | if (rEKLAMABindingSource.Current != null)
|
|---|
| 289 | {
|
|---|
| 290 | DataRowView row = (DataRowView)rEKLAMABindingSource.Current;
|
|---|
| 291 | row["PROMOCJA"] = DBNull.Value;
|
|---|
| 292 | rEKLAMABindingSource.EndEdit();
|
|---|
| 293 | }
|
|---|
| 294 | }
|
|---|
| 295 | }
|
|---|
| 296 | }
|
|---|
| 297 |
|
|---|
| 298 | private void zATWIERDZONO_DO_DRUKUCheckBox_Click(object sender, EventArgs e)
|
|---|
| 299 | {
|
|---|
| 300 | if (zATWIERDZONO_DO_DRUKUCheckBox.Checked)
|
|---|
| 301 | {
|
|---|
| 302 | if (rEKLAMABindingSource.Current != null)
|
|---|
| 303 | {
|
|---|
| 304 | DataRowView row = (DataRowView)rEKLAMABindingSource.Current;
|
|---|
| 305 |
|
|---|
| 306 | sprawdzBledy();
|
|---|
| 307 |
|
|---|
| 308 | if (!User.getUser().St_kierownik)
|
|---|
| 309 | {
|
|---|
| 310 | if (Convert.ToDouble(row["rabat"]) > this.maksymalnyRabat)
|
|---|
| 311 | {
|
|---|
| 312 | MessageBox.Show("Rabat wy¿szy ni¿ " + this.maksymalnyRabat.ToString("P") + ". Zamówienie musi byæ zatwierdzone do druku przez kierownika");
|
|---|
| 313 | zATWIERDZONO_DO_DRUKUCheckBox.CheckState = CheckState.Unchecked;
|
|---|
| 314 | }
|
|---|
| 315 |
|
|---|
| 316 | if (nAZWYMODULOWBindingSource.Current != null)
|
|---|
| 317 | {
|
|---|
| 318 | DataRowView r = (DataRowView)nAZWYMODULOWBindingSource.Current;
|
|---|
| 319 | //decimal cenaJedn = Convert.ToDecimal(row["CENA JEDN"]);
|
|---|
| 320 | decimal cenaMinMod = Convert.ToDecimal(r["CENA_MIN"]);
|
|---|
| 321 |
|
|---|
| 322 | decimal cenaJedn = Convert.ToDecimal(row["NETTO"]) / (Convert.ToDecimal(row["SZER"]) * Convert.ToDecimal(row["WYS"]) * Convert.ToDecimal(row["KROTNOÆ"]));
|
|---|
| 323 | cenaJedn = Math.Round(cenaJedn, 2);
|
|---|
| 324 |
|
|---|
| 325 | if (cenaJedn < cenaMinMod)
|
|---|
| 326 | {
|
|---|
| 327 | MessageBox.Show("Cena modu³u ni¿sza ni¿ cena cennikowa. Zamówienie musi byæ zatwierdzone do druku przez kierownika");
|
|---|
| 328 | zATWIERDZONO_DO_DRUKUCheckBox.CheckState = CheckState.Unchecked;
|
|---|
| 329 | }
|
|---|
| 330 | }
|
|---|
| 331 |
|
|---|
| 332 | string typ = Convert.ToString(row["typ"]);
|
|---|
| 333 | if ((typ == "BEZP£ATNA") || (typ == "BARTER") || (typ == "REKLAMACJA"))
|
|---|
| 334 | {
|
|---|
| 335 | MessageBox.Show("Zamówienie musi byæ zatwierdzone do druku przez kierownika");
|
|---|
| 336 | zATWIERDZONO_DO_DRUKUCheckBox.CheckState = CheckState.Unchecked;
|
|---|
| 337 | }
|
|---|
| 338 | }
|
|---|
| 339 | }
|
|---|
| 340 | }
|
|---|
| 341 | }
|
|---|
| 342 |
|
|---|
| 343 | private void pROCENT_PROWIZJITextBox_Leave(object sender, EventArgs e)
|
|---|
| 344 | {
|
|---|
| 345 | rEKLAMABindingSource.EndEdit();
|
|---|
| 346 | }
|
|---|
| 347 |
|
|---|
| 348 | /// <summary>
|
|---|
| 349 | /// Blokuje czêæ formuklarze w zale¿noci od stanu zamówienia i praw u¿ytkownika...
|
|---|
| 350 | /// </summary>
|
|---|
| 351 | private void OrderDetails_Shown(object sender, EventArgs e)
|
|---|
| 352 | {
|
|---|
| 353 | // BindingSource sa resetowane, by ustawily sie wszytskie filtry
|
|---|
| 354 | kurs = null;
|
|---|
| 355 |
|
|---|
| 356 | obslugaZdarzen = true;
|
|---|
| 357 |
|
|---|
| 358 | tYTULComboBox.SelectedIndex = -1;
|
|---|
| 359 | rEKLAMABindingSource.ResetBindings(false);
|
|---|
| 360 |
|
|---|
| 361 | mOD_TYPComboBox.SelectedIndex = -1;
|
|---|
| 362 | rEKLAMABindingSource.ResetBindings(false);
|
|---|
| 363 |
|
|---|
| 364 | ogl_dzialComboBox.SelectedIndex = -1;
|
|---|
| 365 | rEKLAMABindingSource.ResetBindings(false);
|
|---|
| 366 |
|
|---|
| 367 | ogl_rozdzialComboBox.SelectedIndex = -1;
|
|---|
| 368 | rEKLAMABindingSource.ResetBindings(false);
|
|---|
| 369 |
|
|---|
| 370 | blokowanieZrealizowanychEmisji();
|
|---|
| 371 | zmiany();
|
|---|
| 372 | init();
|
|---|
| 373 | }
|
|---|
| 374 |
|
|---|
| 375 | private void ukazeSieDataGridView_DataError(object sender, DataGridViewDataErrorEventArgs e)
|
|---|
| 376 | {
|
|---|
| 377 | if (rEKLAMAUKAZESIEWNRBindingSource.Current != null)
|
|---|
| 378 | {
|
|---|
| 379 | rEKLAMAUKAZESIEWNRBindingSource.RemoveCurrent();
|
|---|
| 380 | }
|
|---|
| 381 | blokowanieZrealizowanychEmisji();
|
|---|
| 382 | }
|
|---|
| 383 |
|
|---|
| 384 | private void ukazeSieDataGridView_Leave(object sender, EventArgs e)
|
|---|
| 385 | {
|
|---|
| 386 | Validate();
|
|---|
| 387 |
|
|---|
| 388 | rEKLAMAUKAZESIEWNRBindingSource.EndEdit();
|
|---|
| 389 |
|
|---|
| 390 | liczbaEmisjiLabel.Text = rEKLAMAUKAZESIEWNRBindingSource.List.Count.ToString();
|
|---|
| 391 |
|
|---|
| 392 | if (rEKLAMABindingSource.Current != null)
|
|---|
| 393 | {
|
|---|
| 394 | DataRowView row = (DataRowView)rEKLAMABindingSource.Current;
|
|---|
| 395 |
|
|---|
| 396 | if (row["ID_FAKTURY"] == DBNull.Value)
|
|---|
| 397 | {
|
|---|
| 398 | kROTNOSCTextBox.Text = rEKLAMAUKAZESIEWNRBindingSource.List.Count.ToString();
|
|---|
| 399 | }
|
|---|
| 400 | }
|
|---|
| 401 | }
|
|---|
| 402 |
|
|---|
| 403 | /// <summary>
|
|---|
| 404 | /// Blokuje emisje,które ju¿ siê ukaza³y.
|
|---|
| 405 | /// </summary>
|
|---|
| 406 | private void blokowanieZrealizowanychEmisji()
|
|---|
| 407 | {
|
|---|
| 408 | // ukazeSieDataGridView.Enabled = true;
|
|---|
| 409 | foreach (DataGridViewRow r in ukazeSieDataGridView.Rows)
|
|---|
| 410 | {
|
|---|
| 411 | REKLAMADataSet.UKAZE_SIE_W_NRRow em =
|
|---|
| 412 | (REKLAMADataSet.UKAZE_SIE_W_NRRow)((DataRowView)r.DataBoundItem).Row;
|
|---|
| 413 |
|
|---|
| 414 | //anulowana
|
|---|
| 415 | if (em.status == 2)
|
|---|
| 416 | {
|
|---|
| 417 | r.ReadOnly = true;
|
|---|
| 418 | r.DefaultCellStyle.ForeColor = Color.Red;
|
|---|
| 419 | }
|
|---|
| 420 |
|
|---|
| 421 | foreach (DataGridViewRow s in ukazaloSieDataGridView.Rows)
|
|---|
| 422 | {
|
|---|
| 423 | if (em.Nr_Wydania.ToString() == s.Cells["NR_WYDANIA"].Value.ToString())
|
|---|
| 424 | {
|
|---|
| 425 | r.ReadOnly = true;
|
|---|
| 426 | r.DefaultCellStyle.BackColor = Color.MintCream;
|
|---|
| 427 | this.juzSieUkazaloWgazecie = true;
|
|---|
| 428 | break;
|
|---|
| 429 | }
|
|---|
| 430 | }
|
|---|
| 431 | }
|
|---|
| 432 |
|
|---|
| 433 | }
|
|---|
| 434 |
|
|---|
| 435 |
|
|---|
| 436 | public void zablokujGroupBoxa(GroupBox g)
|
|---|
| 437 | {
|
|---|
| 438 | foreach (Control c in g.Controls)
|
|---|
| 439 | {
|
|---|
| 440 | if (c is TextBox)
|
|---|
| 441 | {
|
|---|
| 442 | ((TextBox)c).ReadOnly = true;
|
|---|
| 443 | }
|
|---|
| 444 |
|
|---|
| 445 | if (c is ComboBox)
|
|---|
| 446 | {
|
|---|
| 447 | ((ComboBox)c).Enabled = false;
|
|---|
| 448 | }
|
|---|
| 449 | }
|
|---|
| 450 | }
|
|---|
| 451 |
|
|---|
| 452 | public void odblokujGroupBoxa(GroupBox g)
|
|---|
| 453 | {
|
|---|
| 454 | foreach (Control c in g.Controls)
|
|---|
| 455 | {
|
|---|
| 456 | if (c is TextBox)
|
|---|
| 457 | {
|
|---|
| 458 | ((TextBox)c).ReadOnly = false;
|
|---|
| 459 | }
|
|---|
| 460 |
|
|---|
| 461 | if (c is ComboBox)
|
|---|
| 462 | {
|
|---|
| 463 | ((ComboBox)c).Enabled = true;
|
|---|
| 464 | }
|
|---|
| 465 | }
|
|---|
| 466 | }
|
|---|
| 467 |
|
|---|
| 468 | /// <summary>
|
|---|
| 469 | /// Blokuje kontrolki zwi¹zane z danymi zamówienia
|
|---|
| 470 | /// </summary>
|
|---|
| 471 | private void zablokujGroupBoxy()
|
|---|
| 472 | {
|
|---|
| 473 | zablokujGroupBoxa(groupBox1);
|
|---|
| 474 |
|
|---|
| 475 | if (!(User.getUser().St_produkcja | User.getUser().St_kierownik))
|
|---|
| 476 | {
|
|---|
| 477 | zablokujGroupBoxa(groupBox2);
|
|---|
| 478 | }
|
|---|
| 479 | zablokujGroupBoxa(groupBox3);
|
|---|
| 480 | zablokujGroupBoxa(groupBox4);
|
|---|
| 481 |
|
|---|
| 482 | //lokalizacje mo¿na zmieniaæ
|
|---|
| 483 | sTRONATextBox.ReadOnly = false;
|
|---|
| 484 |
|
|---|
| 485 | }
|
|---|
| 486 |
|
|---|
| 487 | /// <summary>
|
|---|
| 488 | /// Odblokuje kontrolki zwi¹zane z danymi zamówienia
|
|---|
| 489 | /// </summary>
|
|---|
| 490 | private void odblokujGroupBoxy()
|
|---|
| 491 | {
|
|---|
| 492 | odblokujGroupBoxa(groupBox1);
|
|---|
| 493 | odblokujGroupBoxa(groupBox2);
|
|---|
| 494 | odblokujGroupBoxa(groupBox3);
|
|---|
| 495 | odblokujGroupBoxa(groupBox4);
|
|---|
| 496 | }
|
|---|
| 497 |
|
|---|
| 498 | /// <summary>
|
|---|
| 499 | /// Buduje nr zamowienia dla danego handlowca
|
|---|
| 500 | /// </summary>
|
|---|
| 501 | private string nrRek(string symAgenta, string tagAgenta)
|
|---|
| 502 | {
|
|---|
| 503 | if (User.getUser().St_handlowiec)
|
|---|
| 504 | {
|
|---|
| 505 | string nr = Baza_Reklam.Utils.numerNowejReklamy(symAgenta, tagAgenta).ToString();
|
|---|
| 506 | switch (nr.Length)
|
|---|
| 507 | {
|
|---|
| 508 | case 1:
|
|---|
| 509 | nr = tagAgenta + "00" + nr + "_00";
|
|---|
| 510 | break;
|
|---|
| 511 | case 2:
|
|---|
| 512 | nr = tagAgenta + "0" + nr + "_00";
|
|---|
| 513 | break;
|
|---|
| 514 | case 3:
|
|---|
| 515 | nr = tagAgenta + nr + "_00";
|
|---|
| 516 | break;
|
|---|
| 517 | }
|
|---|
| 518 | return nr;
|
|---|
| 519 | }
|
|---|
| 520 | return "";
|
|---|
| 521 | }
|
|---|
| 522 |
|
|---|
| 523 | /// <summary>
|
|---|
| 524 | /// Sprawdza poprawnoæ zamówienia... pewnie niekompletnie
|
|---|
| 525 | /// </summary>
|
|---|
| 526 | private void sprawdzBledy()
|
|---|
| 527 | {
|
|---|
| 528 | if (ogl_dzialComboBox.SelectedValue == null)
|
|---|
| 529 | {
|
|---|
| 530 | MessageBox.Show("Wybierz dzia³.");
|
|---|
| 531 | zATWIERDZONO_DO_DRUKUCheckBox.CheckState = CheckState.Unchecked;
|
|---|
| 532 | return;
|
|---|
| 533 | }
|
|---|
| 534 |
|
|---|
| 535 |
|
|---|
| 536 | if (mOD_TYPComboBox.Text == "")
|
|---|
| 537 | {
|
|---|
| 538 | MessageBox.Show("Wybierz rodzaj modu³u.");
|
|---|
| 539 | zATWIERDZONO_DO_DRUKUCheckBox.CheckState = CheckState.Unchecked;
|
|---|
| 540 | return;
|
|---|
| 541 | }
|
|---|
| 542 |
|
|---|
| 543 | string grzbiet = grzbietComboBox.Text;
|
|---|
| 544 | string tytul = tYTULComboBox.Text;
|
|---|
| 545 |
|
|---|
| 546 | if (grzbiet == "")
|
|---|
| 547 | {
|
|---|
| 548 | MessageBox.Show("Wybierz grzbiet.");
|
|---|
| 549 | zATWIERDZONO_DO_DRUKUCheckBox.CheckState = CheckState.Unchecked;
|
|---|
| 550 | return;
|
|---|
| 551 | }
|
|---|
| 552 | else
|
|---|
| 553 | {
|
|---|
| 554 | if (!grzbiet.Contains(tytul))
|
|---|
| 555 | {
|
|---|
| 556 | MessageBox.Show("Wybierz poprawny grzbiet.");
|
|---|
| 557 | zATWIERDZONO_DO_DRUKUCheckBox.CheckState = CheckState.Unchecked;
|
|---|
| 558 | return;
|
|---|
| 559 | }
|
|---|
| 560 | }
|
|---|
| 561 |
|
|---|
| 562 | //lokalizacja
|
|---|
| 563 | if (sTRONATextBox.Text == "")
|
|---|
| 564 | {
|
|---|
| 565 | MessageBox.Show("Podaj lokalizacjê.");
|
|---|
| 566 | zATWIERDZONO_DO_DRUKUCheckBox.CheckState = CheckState.Unchecked;
|
|---|
| 567 | return;
|
|---|
| 568 | }
|
|---|
| 569 |
|
|---|
| 570 | if (rEKLAMAUKAZESIEWNRBindingSource.List.Count == 0)
|
|---|
| 571 | {
|
|---|
| 572 | MessageBox.Show("Brak wyznaczonych emisji.");
|
|---|
| 573 | zATWIERDZONO_DO_DRUKUCheckBox.CheckState = CheckState.Unchecked;
|
|---|
| 574 | return;
|
|---|
| 575 | }
|
|---|
| 576 | }
|
|---|
| 577 |
|
|---|
| 578 | /// <summary>
|
|---|
| 579 | /// Przelicza wartoæ zamówienia.
|
|---|
| 580 | /// </summary>
|
|---|
| 581 | private void przelicz()
|
|---|
| 582 | {
|
|---|
| 583 | DataRowView row = (DataRowView)rEKLAMABindingSource.Current;
|
|---|
| 584 |
|
|---|
| 585 | if ((row["KROTNOÆ"] != null) && (row["CENA JEDN"] != null) && (row["VAT"] != null)
|
|---|
| 586 | && (row["PROCENT PROWIZJI"] != null) && (row["RABAT"] != null)
|
|---|
| 587 | && (row["SZER"] != null) && (row["WYS"] != null))
|
|---|
| 588 | {
|
|---|
| 589 | int szer = Convert.ToInt32(row["SZER"]);
|
|---|
| 590 | int wys = Convert.ToInt32(row["WYS"]);
|
|---|
| 591 | int krotnosc = Convert.ToInt32(row["KROTNOÆ"]);
|
|---|
| 592 |
|
|---|
| 593 | if (krotnosc == 0)
|
|---|
| 594 | {
|
|---|
| 595 | MessageBox.Show("Iloæ emisji równa siê 0");
|
|---|
| 596 | return;
|
|---|
| 597 | }
|
|---|
| 598 |
|
|---|
| 599 | decimal cenaJednostkowa = Convert.ToDecimal(row["CENA JEDN"]);
|
|---|
| 600 | decimal vatProcent = Convert.ToDecimal(row["VAT"]);
|
|---|
| 601 | decimal prowizjaProcent = Convert.ToDecimal(row["PROCENT PROWIZJI"]);
|
|---|
| 602 | decimal rabatProcent = Convert.ToDecimal(row["RABAT"]);
|
|---|
| 603 |
|
|---|
| 604 |
|
|---|
| 605 | //rabatWartosc
|
|---|
| 606 | decimal rabatWartosc = rabatProcent * cenaJednostkowa;
|
|---|
| 607 | rabatWartosc = Math.Round(rabatWartosc, 2);
|
|---|
| 608 |
|
|---|
| 609 | //netto
|
|---|
| 610 | decimal netto = (cenaJednostkowa - rabatWartosc) * krotnosc;
|
|---|
| 611 | netto = Math.Round(netto, 2);
|
|---|
| 612 |
|
|---|
| 613 | nettoBezBOTextBox.Text = String.Format("{0:C}", netto);
|
|---|
| 614 |
|
|---|
| 615 | //cena modulu
|
|---|
| 616 | decimal cenaModulu = netto / (szer * wys * krotnosc);
|
|---|
| 617 | cenaModulu = Math.Round(cenaModulu, 2);
|
|---|
| 618 |
|
|---|
| 619 | if (Convert.ToBoolean(row["wyroznienie"]) == true)
|
|---|
| 620 | {
|
|---|
| 621 | row["wyroznienie_procent"] = 0.15M;
|
|---|
| 622 | decimal kwotaWyroznienia = Math.Round(netto * 0.15M, 2);
|
|---|
| 623 | row["wyroznienie_kwota"] = kwotaWyroznienia;
|
|---|
| 624 | netto = netto + kwotaWyroznienia;
|
|---|
| 625 | }
|
|---|
| 626 | else
|
|---|
| 627 | {
|
|---|
| 628 | row["wyroznienie_procent"] = 0;
|
|---|
| 629 | row["wyroznienie_kwota"] = 0;
|
|---|
| 630 | }
|
|---|
| 631 |
|
|---|
| 632 | //vatWartosc
|
|---|
| 633 | decimal vatWartosc = vatProcent * netto;
|
|---|
| 634 | vatWartosc = Math.Round(vatWartosc, 2);
|
|---|
| 635 |
|
|---|
| 636 | //brutto
|
|---|
| 637 | decimal brutto = netto + vatWartosc;
|
|---|
| 638 | brutto = Math.Round(brutto, 2);
|
|---|
| 639 |
|
|---|
| 640 | //prowizja
|
|---|
| 641 | decimal prowizjaWartosc = prowizjaProcent * netto;
|
|---|
| 642 | prowizjaWartosc = Math.Round(prowizjaWartosc, 2);
|
|---|
| 643 |
|
|---|
| 644 | cenaModuluLabel.Text = String.Format("{0:C}", cenaModulu);
|
|---|
| 645 | row["RABAT WARTOÆ"] = rabatWartosc.ToString();
|
|---|
| 646 | row["NETTO"] = netto.ToString();
|
|---|
| 647 | row["BRUTTO"] = brutto.ToString();
|
|---|
| 648 | row["PVAT"] = vatWartosc.ToString();
|
|---|
| 649 | row["PROWIZJA"] = prowizjaWartosc.ToString();
|
|---|
| 650 |
|
|---|
| 651 | rEKLAMABindingSource.EndEdit();
|
|---|
| 652 | }
|
|---|
| 653 |
|
|---|
| 654 | }
|
|---|
| 655 |
|
|---|
| 656 | /// <summary>
|
|---|
| 657 | /// Przelicza kwotê w z³otówkach na wybran¹ walutê.
|
|---|
| 658 | /// </summary>
|
|---|
| 659 | private void przeliczNaWalute(SLOWNIKDataSet.Kursy_WalutRow kurs)
|
|---|
| 660 | {
|
|---|
| 661 | if (rEKLAMABindingSource.Current != null)
|
|---|
| 662 | {
|
|---|
| 663 | DataRowView row = (DataRowView)rEKLAMABindingSource.Current;
|
|---|
| 664 |
|
|---|
| 665 | if (row["BRUTTO"] != DBNull.Value)
|
|---|
| 666 | {
|
|---|
| 667 |
|
|---|
| 668 | decimal brutto = Convert.ToDecimal(row["BRUTTO"]);
|
|---|
| 669 | brutto = Math.Round(brutto, 2);
|
|---|
| 670 |
|
|---|
| 671 | // waluty
|
|---|
| 672 | row["waluta_tabela_nr"] = kurs.Numer_Tabeli;
|
|---|
| 673 | row["waluta_Przelicznik"] = kurs.przelicznik;
|
|---|
| 674 | row["waluta_kurs_z_dnia"] = kurs.Data_Publikacji;
|
|---|
| 675 | row["Brutto_Euro_Miano"] = kurs.Kod_Waluty;
|
|---|
| 676 |
|
|---|
| 677 | //zmiana kursu dla poznania
|
|---|
| 678 | if (User.getUser().IdAgencji == 6)
|
|---|
| 679 | {
|
|---|
| 680 | row["waluta_kurs"] = kurs.Kurs_Sredni_Poznan;
|
|---|
| 681 | row["Brutto_Euro"] = Math.Round(brutto / Convert.ToDecimal(kurs.Kurs_Sredni_Poznan) * Convert.ToInt32(kurs.przelicznik), 2);
|
|---|
| 682 | }
|
|---|
| 683 | else
|
|---|
| 684 | {
|
|---|
| 685 | row["waluta_kurs"] = kurs.Kurs_Sredni;
|
|---|
| 686 | row["Brutto_Euro"] = Math.Round(brutto / Convert.ToDecimal(kurs.Kurs_Sredni) * Convert.ToInt32(kurs.przelicznik), 2);
|
|---|
| 687 | }
|
|---|
| 688 |
|
|---|
| 689 | // zmiana domylnego konta do faktury dla EUR
|
|---|
| 690 | if (User.getUser().IdAgencji != 4 & (row["Brutto_Euro_Miano"].ToString() == "EUR"))
|
|---|
| 691 | {
|
|---|
| 692 | if (User.getUser().IdAgencji == 1223940396 | User.getUser().IdAgencji == 1223940398)
|
|---|
| 693 | {
|
|---|
| 694 | row["FAKTURA ID KONTA"] = 3;
|
|---|
| 695 | }
|
|---|
| 696 | else
|
|---|
| 697 | {
|
|---|
| 698 | row["FAKTURA ID KONTA"] = 5;
|
|---|
| 699 | }
|
|---|
| 700 | }
|
|---|
| 701 |
|
|---|
| 702 | rEKLAMABindingSource.EndEdit();
|
|---|
| 703 | }
|
|---|
| 704 | }
|
|---|
| 705 | }
|
|---|
| 706 |
|
|---|
| 707 | /// <summary>
|
|---|
| 708 | /// Przelicza kwotê w walucie na z³otówki.
|
|---|
| 709 | /// </summary>
|
|---|
| 710 | private void przeliczWaluteNaZlotowki(SLOWNIKDataSet.Kursy_WalutRow kurs)
|
|---|
| 711 | {
|
|---|
| 712 | DataRowView row = (DataRowView)rEKLAMABindingSource.Current;
|
|---|
| 713 |
|
|---|
| 714 | if (row["Brutto_Euro"] != DBNull.Value)
|
|---|
| 715 | {
|
|---|
| 716 | // waluty
|
|---|
| 717 | row["waluta_tabela_nr"] = kurs.Numer_Tabeli;
|
|---|
| 718 | row["waluta_Przelicznik"] = kurs.przelicznik;
|
|---|
| 719 | row["waluta_kurs"] = kurs.Kurs_Sredni;
|
|---|
| 720 | row["waluta_kurs_z_dnia"] = kurs.Data_Publikacji;
|
|---|
| 721 | row["Brutto_Euro_Miano"] = kurs.Kod_Waluty;
|
|---|
| 722 |
|
|---|
| 723 | //zmiana kursu dla poznania
|
|---|
| 724 | if (User.getUser().IdAgencji == 6)
|
|---|
| 725 | {
|
|---|
| 726 | row["waluta_kurs"] = kurs.Kurs_Sredni_Poznan;
|
|---|
| 727 | }
|
|---|
| 728 |
|
|---|
| 729 | int szer = Convert.ToInt32(row["SZER"]);
|
|---|
| 730 | int wys = Convert.ToInt32(row["WYS"]);
|
|---|
| 731 | int krotnosc = Convert.ToInt32(row["KROTNOÆ"]);
|
|---|
| 732 |
|
|---|
| 733 | if (krotnosc == 0)
|
|---|
| 734 | {
|
|---|
| 735 | MessageBox.Show("Iloæ emisji równa siê 0");
|
|---|
| 736 | return;
|
|---|
| 737 | }
|
|---|
| 738 |
|
|---|
| 739 | decimal vatProcent = Convert.ToDecimal(row["VAT"]);
|
|---|
| 740 | decimal prowizjaProcent = Convert.ToDecimal(row["PROCENT PROWIZJI"]);
|
|---|
| 741 | decimal rabatProcent = Convert.ToDecimal(row["RABAT"]);
|
|---|
| 742 |
|
|---|
| 743 | //przeliczanie z waluty na zlotowki
|
|---|
| 744 | decimal brutto = Math.Round(Convert.ToDecimal(row["Brutto_Euro"]) * Convert.ToDecimal(row["waluta_kurs"]) / Convert.ToInt32(row["waluta_Przelicznik"]), 2);
|
|---|
| 745 |
|
|---|
| 746 | decimal netto = brutto / (1 + vatProcent);
|
|---|
| 747 | netto = Math.Round(netto, 2);
|
|---|
| 748 |
|
|---|
| 749 | decimal nettoZBO = netto;
|
|---|
| 750 |
|
|---|
| 751 | if (Convert.ToBoolean(row["wyroznienie"]) == true)
|
|---|
| 752 | {
|
|---|
| 753 | row["wyroznienie_procent"] = 0.15M;
|
|---|
| 754 | decimal nettoBezBO = Math.Round(netto / 1.15M, 2);
|
|---|
| 755 | row["wyroznienie_kwota"] = Math.Round(netto - nettoBezBO, 2);
|
|---|
| 756 | netto = nettoBezBO;
|
|---|
| 757 | }
|
|---|
| 758 | else
|
|---|
| 759 | {
|
|---|
| 760 | row["wyroznienie_procent"] = 0;
|
|---|
| 761 | row["wyroznienie_kwota"] = 0;
|
|---|
| 762 | }
|
|---|
| 763 |
|
|---|
| 764 | nettoBezBOTextBox.Text = String.Format("{0:C}", netto);
|
|---|
| 765 |
|
|---|
| 766 | decimal vatWartosc = vatProcent * nettoZBO;
|
|---|
| 767 | vatWartosc = Math.Round(vatWartosc, 2);
|
|---|
| 768 |
|
|---|
| 769 | decimal prowizjaWartosc = prowizjaProcent * nettoZBO;
|
|---|
| 770 | prowizjaWartosc = Math.Round(prowizjaWartosc, 2);
|
|---|
| 771 |
|
|---|
| 772 | decimal rabatWartosc = netto * rabatProcent / (krotnosc * (1 - rabatProcent));
|
|---|
| 773 | rabatWartosc = Math.Round(rabatWartosc, 2);
|
|---|
| 774 |
|
|---|
| 775 | decimal cenaJednostkowa = (netto / (decimal)krotnosc) + rabatWartosc;
|
|---|
| 776 | cenaJednostkowa = Math.Round(cenaJednostkowa, 2);
|
|---|
| 777 |
|
|---|
| 778 | //cena modulu
|
|---|
| 779 | decimal cenaModulu = netto / (szer * wys * krotnosc);
|
|---|
| 780 | cenaModulu = Math.Round(cenaModulu, 2);
|
|---|
| 781 |
|
|---|
| 782 | cenaModuluLabel.Text = String.Format("{0:C}", cenaModulu);
|
|---|
| 783 | row["RABAT WARTOÆ"] = rabatWartosc.ToString();
|
|---|
| 784 | row["NETTO"] = nettoZBO.ToString();
|
|---|
| 785 | row["BRUTTO"] = brutto.ToString();
|
|---|
| 786 | row["PVAT"] = vatWartosc.ToString();
|
|---|
| 787 | row["PROWIZJA"] = prowizjaWartosc.ToString();
|
|---|
| 788 | row["CENA JEDN"] = cenaJednostkowa.ToString();
|
|---|
| 789 |
|
|---|
| 790 |
|
|---|
| 791 | // zmiana domylnego konta do faktury dla EUR
|
|---|
| 792 | if (User.getUser().IdAgencji != 4 & (row["Brutto_Euro_Miano"].ToString() == "EUR"))
|
|---|
| 793 | {
|
|---|
| 794 | if (User.getUser().IdAgencji == 1223940396 | User.getUser().IdAgencji == 1223940398)
|
|---|
| 795 | {
|
|---|
| 796 | row["FAKTURA ID KONTA"] = 3;
|
|---|
| 797 | }
|
|---|
| 798 | else
|
|---|
| 799 | {
|
|---|
| 800 | row["FAKTURA ID KONTA"] = 5;
|
|---|
| 801 | }
|
|---|
| 802 | }
|
|---|
| 803 |
|
|---|
| 804 | rEKLAMABindingSource.EndEdit();
|
|---|
| 805 |
|
|---|
| 806 | }
|
|---|
| 807 | }
|
|---|
| 808 |
|
|---|
| 809 | public void dodajNoweZamowienie(int custId, string kodKlienta)
|
|---|
| 810 | {
|
|---|
| 811 | this.nowyRekord = true;
|
|---|
| 812 | this.bylyZmiany = false;
|
|---|
| 813 | this.juzSieUkazaloWgazecie = false;
|
|---|
| 814 |
|
|---|
| 815 | this.numeryReklam.Clear();
|
|---|
| 816 |
|
|---|
| 817 | string nr;
|
|---|
| 818 | foreach (DataRowView r in lISTATYTULOWBindingSource.List)
|
|---|
| 819 | {
|
|---|
| 820 | nr = nrRek(User.getUser().Symbol_agenta, r["SYMB2"].ToString().Trim() + User.getUser().Kod_agenta);
|
|---|
| 821 | this.numeryReklam.Add((string)r["SYMB"], nr);
|
|---|
| 822 | }
|
|---|
| 823 | //autosalon l¹ski
|
|---|
| 824 | nr = nrRek(User.getUser().Symbol_agenta, "G" + User.getUser().Kod_agenta);
|
|---|
| 825 | this.numeryReklam.Add("slaski", nr);
|
|---|
| 826 |
|
|---|
| 827 | this.rEKLAMADataSet.REKLAMA.Clear();
|
|---|
| 828 | this.rEKLAMADataSet.UKAZE_SIE_W_NR.Clear();
|
|---|
| 829 | this.rEKLAMADataSet.Reklama_Info_Dod.Clear();
|
|---|
| 830 |
|
|---|
| 831 | this.customerId = custId;
|
|---|
| 832 |
|
|---|
| 833 | DataView datatable = (DataView)this.rEKLAMABindingSource.List;
|
|---|
| 834 | DataRowView row = datatable.AddNew();
|
|---|
| 835 |
|
|---|
| 836 | row["CustomerId"] = this.customerId;
|
|---|
| 837 | row["DATA ZAMÓWIENIA"] = DateTime.Now;
|
|---|
| 838 | row["nick name"] = kodKlienta;
|
|---|
| 839 | if (Utils.czyKlientMaNrVIES(this.customerId))
|
|---|
| 840 | {
|
|---|
| 841 | row["VAT"] = 0;
|
|---|
| 842 | }
|
|---|
| 843 |
|
|---|
| 844 | if (User.getUser().St_handlowiec | User.getUser().St_subhandlowiec)
|
|---|
| 845 | {
|
|---|
| 846 | row["symbol akwizytora"] = User.getUser().Symbol_agenta;
|
|---|
| 847 | row["ID Reklamy"] = this.numeryReklam["AMT"];
|
|---|
| 848 |
|
|---|
| 849 | //Katowice
|
|---|
| 850 | if (User.getUser().IdAgencji == 4)
|
|---|
| 851 | {
|
|---|
| 852 | row["customerId_Sub"] = 678;
|
|---|
| 853 | }
|
|---|
| 854 |
|
|---|
| 855 | //Poznan
|
|---|
| 856 | if (User.getUser().IdAgencji == 6)
|
|---|
| 857 | {
|
|---|
| 858 | row["customerId_Sub"] = 18845;
|
|---|
| 859 | }
|
|---|
| 860 | }
|
|---|
| 861 |
|
|---|
| 862 | row["USERID"] = User.getUser().Login;
|
|---|
| 863 |
|
|---|
| 864 | Validate();
|
|---|
| 865 |
|
|---|
| 866 | rEKLAMABindingSource.EndEdit();
|
|---|
| 867 | rEKLAMATableAdapter.Update(rEKLAMADataSet.REKLAMA);
|
|---|
| 868 | rEKLAMABindingSource.MoveLast();
|
|---|
| 869 | }
|
|---|
| 870 |
|
|---|
| 871 | public void pokazSzczegolyZamowienia(int rekId)
|
|---|
| 872 | {
|
|---|
| 873 | this.nowyRekord = false;
|
|---|
| 874 | this.bylyZmiany = false;
|
|---|
| 875 | this.reklamaId = rekId;
|
|---|
| 876 |
|
|---|
| 877 | this.rEKLAMATableAdapter.ClearBeforeFill = true;
|
|---|
| 878 | this.rEKLAMATableAdapter.FillByReklamaId(this.rEKLAMADataSet.REKLAMA, reklamaId);
|
|---|
| 879 | this.reklama_Info_DodTableAdapter.FillByReklamaId(this.rEKLAMADataSet.Reklama_Info_Dod, reklamaId);
|
|---|
| 880 | this.rEKLAMA_STRONATableAdapter.FillByReklamaId(this.rEKLAMADataSet.REKLAMA_STRONA, this.reklamaId);
|
|---|
| 881 | this.uKAZE_SIE_W_NRTableAdapter.FillByReklamaId(this.rEKLAMADataSet.UKAZE_SIE_W_NR, this.reklamaId);
|
|---|
| 882 | }
|
|---|
| 883 |
|
|---|
| 884 | public void wznowZamowienie(int rekId)
|
|---|
| 885 | {
|
|---|
| 886 | this.nowyRekord = true;
|
|---|
| 887 | this.bylyZmiany = false;
|
|---|
| 888 | this.juzSieUkazaloWgazecie = false;
|
|---|
| 889 |
|
|---|
| 890 | REKLAMADataSet.REKLAMADataTable old = this.rEKLAMATableAdapter.GetDataByReklamaId(rekId);
|
|---|
| 891 | DataRow oldRow = old.Rows[0];
|
|---|
| 892 |
|
|---|
| 893 | this.rEKLAMADataSet.REKLAMA.Clear();
|
|---|
| 894 | this.rEKLAMADataSet.UKAZE_SIE_W_NR.Clear();
|
|---|
| 895 | this.rEKLAMADataSet.Reklama_Info_Dod.Clear();
|
|---|
| 896 |
|
|---|
| 897 | DataView datatable = (DataView)this.rEKLAMABindingSource.List;
|
|---|
| 898 | DataRowView newRow = datatable.AddNew();
|
|---|
| 899 |
|
|---|
| 900 | this.customerId = Convert.ToInt32(oldRow["CustomerID"]);
|
|---|
| 901 |
|
|---|
| 902 | newRow["CustomerID"] = oldRow["CustomerID"];
|
|---|
| 903 | newRow["DATA ZAMÓWIENIA"] = DateTime.Now;
|
|---|
| 904 | newRow["SYMBOL AKWIZYTORA"] = oldRow["SYMBOL AKWIZYTORA"];
|
|---|
| 905 | newRow["ID REKLAMY"] = oldRow["ID REKLAMY"];
|
|---|
| 906 | newRow["TYTU£"] = oldRow["TYTU£"];
|
|---|
| 907 | newRow["TYP"] = oldRow["TYP"];
|
|---|
| 908 | newRow["NICK NAME"] = oldRow["NICK NAME"];
|
|---|
| 909 | newRow["SZER"] = oldRow["SZER"];
|
|---|
| 910 | newRow["WYS"] = oldRow["WYS"];
|
|---|
| 911 | newRow["MOD_TYP"] = oldRow["MOD_TYP"];
|
|---|
| 912 | newRow["KROTNOÆ"] = oldRow["KROTNOÆ"];
|
|---|
| 913 | newRow["ODSTÊP"] = oldRow["ODSTÊP"];
|
|---|
| 914 | newRow["KOLOR"] = oldRow["KOLOR"];
|
|---|
| 915 | newRow["RABAT"] = oldRow["RABAT"];
|
|---|
| 916 | newRow["CENA JEDN"] = oldRow["CENA JEDN"];
|
|---|
| 917 | newRow["VAT"] = oldRow["VAT"];
|
|---|
| 918 | newRow["PROCENT PROWIZJI"] = oldRow["PROCENT PROWIZJI"];
|
|---|
| 919 | newRow["PROMOCJA"] = oldRow["PROMOCJA"];
|
|---|
| 920 | newRow["GRZBIET"] = oldRow["GRZBIET"];
|
|---|
| 921 | newRow["STRONA"] = oldRow["STRONA"];
|
|---|
| 922 | newRow["customerId_Sub"] = oldRow["customerId_Sub"];
|
|---|
| 923 | newRow["ogl_dzial"] = oldRow["ogl_dzial"];
|
|---|
| 924 | newRow["ogl_rozdzial"] = oldRow["ogl_rozdzial"];
|
|---|
| 925 |
|
|---|
| 926 | //zmiana numerka
|
|---|
| 927 | try
|
|---|
| 928 | {
|
|---|
| 929 | string starySym = newRow["Id reklamy"].ToString();
|
|---|
| 930 | string symPart1 = starySym.Substring(0, starySym.Length - 2);
|
|---|
| 931 | string symPart2 = starySym.Substring(starySym.Length - 2, 2);
|
|---|
| 932 | int nowyNr = Int32.Parse(symPart2);
|
|---|
| 933 | nowyNr++;
|
|---|
| 934 | switch (nowyNr.ToString().Length)
|
|---|
| 935 | {
|
|---|
| 936 | case 1:
|
|---|
| 937 | newRow["Id reklamy"] = symPart1 + "0" + nowyNr.ToString();
|
|---|
| 938 | break;
|
|---|
| 939 | default:
|
|---|
| 940 | newRow["Id reklamy"] = symPart1 + nowyNr.ToString();
|
|---|
| 941 | break;
|
|---|
| 942 | }
|
|---|
| 943 | }
|
|---|
| 944 | catch (Exception e1)
|
|---|
| 945 | {
|
|---|
| 946 | newRow["Id reklamy"] = oldRow["Id reklamy"];
|
|---|
| 947 | }
|
|---|
| 948 |
|
|---|
| 949 | this.numeryReklam.Clear();
|
|---|
| 950 | string nr;
|
|---|
| 951 | foreach (DataRowView r in lISTATYTULOWBindingSource.List)
|
|---|
| 952 | {
|
|---|
| 953 | nr = nrRek(User.getUser().Symbol_agenta, r["SYMB2"].ToString().Trim() + User.getUser().Kod_agenta);
|
|---|
| 954 | this.numeryReklam.Add((string)r["SYMB"], nr);
|
|---|
| 955 | }
|
|---|
| 956 | //autosalon l¹ski
|
|---|
| 957 | nr = nrRek(User.getUser().Symbol_agenta, "G" + User.getUser().Kod_agenta);
|
|---|
| 958 | this.numeryReklam.Add("slaski", nr);
|
|---|
| 959 |
|
|---|
| 960 | Validate();
|
|---|
| 961 |
|
|---|
| 962 | rEKLAMABindingSource.EndEdit();
|
|---|
| 963 | rEKLAMATableAdapter.Update(rEKLAMADataSet.REKLAMA);
|
|---|
| 964 | // rEKLAMABindingSource.MoveLast();
|
|---|
| 965 | }
|
|---|
| 966 |
|
|---|
| 967 | private void dataGridView1_RowLeave(object sender, DataGridViewCellEventArgs e)
|
|---|
| 968 | {
|
|---|
| 969 | try
|
|---|
| 970 | {
|
|---|
| 971 | DataRowView rowView = dataGridView1[e.ColumnIndex, e.RowIndex].OwningRow.DataBoundItem as DataRowView;
|
|---|
| 972 |
|
|---|
| 973 | if ((rowView != null) && rowView.IsNew)
|
|---|
| 974 | {
|
|---|
| 975 | rowView["Data"] = DateTime.Now;
|
|---|
| 976 | }
|
|---|
| 977 | }
|
|---|
| 978 | catch (Exception e1)
|
|---|
| 979 | {
|
|---|
| 980 | throw e1;
|
|---|
| 981 | }
|
|---|
| 982 |
|
|---|
| 983 | dataGridView1.Refresh();
|
|---|
| 984 | }
|
|---|
| 985 |
|
|---|
| 986 | private void dataGridView1_Leave(object sender, EventArgs e)
|
|---|
| 987 | {
|
|---|
| 988 | this.dataGridView1.EndEdit();
|
|---|
| 989 |
|
|---|
| 990 | Validate();
|
|---|
| 991 |
|
|---|
| 992 | this.rEKLAMAReklamaInfoDodBindingSource.EndEdit();
|
|---|
| 993 | }
|
|---|
| 994 |
|
|---|
| 995 | private void OrderDetails_FormClosing(object sender, FormClosingEventArgs e)
|
|---|
| 996 | {
|
|---|
| 997 | if (nowyRekord)
|
|---|
| 998 | {
|
|---|
| 999 | if (rEKLAMABindingSource.Current != null)
|
|---|
| 1000 | {
|
|---|
| 1001 | rEKLAMABindingSource.RemoveCurrent();
|
|---|
| 1002 | rEKLAMABindingSource.EndEdit();
|
|---|
| 1003 | rEKLAMATableAdapter.Update(this.rEKLAMADataSet.REKLAMA);
|
|---|
| 1004 | }
|
|---|
| 1005 |
|
|---|
| 1006 | }
|
|---|
| 1007 | else
|
|---|
| 1008 | {
|
|---|
| 1009 | //usuwa zmiany w zleceniu
|
|---|
| 1010 | rEKLAMADataSet.REKLAMA.RejectChanges();
|
|---|
| 1011 | rEKLAMADataSet.UKAZE_SIE_W_NR.RejectChanges();
|
|---|
| 1012 | }
|
|---|
| 1013 |
|
|---|
| 1014 | this.obslugaZdarzen = false;
|
|---|
| 1015 | liczbaEmisjiLabel.Text = "-";
|
|---|
| 1016 | this.nettoBezBOTextBox.Clear();
|
|---|
| 1017 | this.kurs = null;
|
|---|
| 1018 | this.DialogResult = bylyZmiany ? DialogResult.OK : DialogResult.Cancel;
|
|---|
| 1019 | }
|
|---|
| 1020 |
|
|---|
| 1021 | /// <summary>
|
|---|
| 1022 | /// Koloruje formularz, blokuje pola etc.
|
|---|
| 1023 | /// </summary>
|
|---|
| 1024 | private void zmiany()
|
|---|
| 1025 | {
|
|---|
| 1026 | if (this.rEKLAMABindingSource.Current != null)
|
|---|
| 1027 | {
|
|---|
| 1028 | DataRowView reklamRow = (DataRowView)this.rEKLAMABindingSource.Current;
|
|---|
| 1029 |
|
|---|
| 1030 | bool zablokujProwizje = Convert.ToBoolean(reklamRow["zablokuj_prowizje"]);
|
|---|
| 1031 | bool zatwiedzonoDoDruku = reklamRow["ZATWIERDZONO DO DRUKU"] == DBNull.Value ? false : Convert.ToBoolean(reklamRow["ZATWIERDZONO DO DRUKU"]);
|
|---|
| 1032 | bool kierownikZatwierdzil = reklamRow["kier_zatwierdzil"] == DBNull.Value ? false : Convert.ToBoolean(reklamRow["kier_zatwierdzil"]);
|
|---|
| 1033 | bool rabatPonad30 = (bool)(Convert.ToDouble(reklamRow["rabat"]) > this.maksymalnyRabat);
|
|---|
| 1034 | bool wystawionoFakture = reklamRow["FAKTURA WYSTAWIONO"] == DBNull.Value ? false : Convert.ToBoolean(reklamRow["FAKTURA WYSTAWIONO"]);
|
|---|
| 1035 |
|
|---|
| 1036 | //blokowanie prowizji
|
|---|
| 1037 | pROWIZJATextBox.ReadOnly = zablokujProwizje;
|
|---|
| 1038 | pROCENT_PROWIZJITextBox.ReadOnly = zablokujProwizje;
|
|---|
| 1039 |
|
|---|
| 1040 | //oznaczenie ZD
|
|---|
| 1041 | ZDpanel.BackColor = zatwiedzonoDoDruku ? Color.LightGreen : Color.Red;
|
|---|
| 1042 |
|
|---|
| 1043 | //UPRAWnienia
|
|---|
| 1044 | kier_notatkaTextBox.ReadOnly = !User.getUser().St_kierownik;
|
|---|
| 1045 | kier_zatwierdzilCheckBox.Enabled = User.getUser().St_kierownik;
|
|---|
| 1046 | zablokuj_prowizjeCheckBox.Enabled = User.getUser().St_kierownik;
|
|---|
| 1047 |
|
|---|
| 1048 | if (!User.getUser().St_kierownik)
|
|---|
| 1049 | {
|
|---|
| 1050 | cENA_JEDNTextBox.ReadOnly = zatwiedzonoDoDruku;
|
|---|
| 1051 | rABATTextBox.ReadOnly = zatwiedzonoDoDruku;
|
|---|
| 1052 |
|
|---|
| 1053 | if (wystawionoFakture)
|
|---|
| 1054 | {
|
|---|
| 1055 | zablokujGroupBoxy();
|
|---|
| 1056 | }
|
|---|
| 1057 | else
|
|---|
| 1058 | {
|
|---|
| 1059 | odblokujGroupBoxy();
|
|---|
| 1060 | }
|
|---|
| 1061 | }
|
|---|
| 1062 |
|
|---|
| 1063 | blokowanieZrealizowanychEmisji();
|
|---|
| 1064 | }
|
|---|
| 1065 | }
|
|---|
| 1066 |
|
|---|
| 1067 | private void ukazeSieDataGridView_KeyUp(object sender, KeyEventArgs e)
|
|---|
| 1068 | {
|
|---|
| 1069 | if (e.Control && e.KeyCode == Keys.C)
|
|---|
| 1070 | {
|
|---|
| 1071 | if (this.ukazeSieDataGridView.GetCellCount(DataGridViewElementStates.Selected) > 0)
|
|---|
| 1072 | {
|
|---|
| 1073 | try
|
|---|
| 1074 | {
|
|---|
| 1075 | // Add the selection to the clipboard.
|
|---|
| 1076 | Clipboard.SetDataObject(
|
|---|
| 1077 | this.ukazeSieDataGridView.GetClipboardContent());
|
|---|
| 1078 | }
|
|---|
| 1079 | catch (System.Runtime.InteropServices.ExternalException)
|
|---|
| 1080 | {
|
|---|
| 1081 |
|
|---|
| 1082 | }
|
|---|
| 1083 | }
|
|---|
| 1084 | }
|
|---|
| 1085 |
|
|---|
| 1086 | if (e.Control && e.KeyCode == Keys.V)
|
|---|
| 1087 | {
|
|---|
| 1088 | Validate();
|
|---|
| 1089 |
|
|---|
| 1090 | rEKLAMAUKAZESIEWNRBindingSource.EndEdit();
|
|---|
| 1091 |
|
|---|
| 1092 | //czy user ma uprawnienia do dodawania wierszy
|
|---|
| 1093 | if (ukazeSieDataGridView.AllowUserToAddRows)
|
|---|
| 1094 | {
|
|---|
| 1095 | char[] rowSplitter = { '\r', '\n' };
|
|---|
| 1096 | char[] columnSplitter = { '\t' };
|
|---|
| 1097 |
|
|---|
| 1098 | IDataObject dataInClipboard = Clipboard.GetDataObject();
|
|---|
| 1099 | string stringInClipboard = (string)dataInClipboard.GetData(DataFormats.Text);
|
|---|
| 1100 |
|
|---|
| 1101 | string[] rowsInClipboard = stringInClipboard.Split(rowSplitter, StringSplitOptions.RemoveEmptyEntries);
|
|---|
| 1102 |
|
|---|
| 1103 | string nrWydania = "0";
|
|---|
| 1104 |
|
|---|
| 1105 | for (int iRow = 0; iRow < rowsInClipboard.Length; iRow++)
|
|---|
| 1106 | {
|
|---|
| 1107 | string[] valuesInRow = rowsInClipboard[iRow].Split(columnSplitter);
|
|---|
| 1108 |
|
|---|
| 1109 | for (int i = 0; i <= valuesInRow.Length - 1; i++)
|
|---|
| 1110 | {
|
|---|
| 1111 | if (valuesInRow[i] != "")
|
|---|
| 1112 | {
|
|---|
| 1113 | nrWydania = valuesInRow[i];
|
|---|
| 1114 |
|
|---|
| 1115 | try
|
|---|
| 1116 | {
|
|---|
| 1117 | DataView datatable = (DataView)this.rEKLAMAUKAZESIEWNRBindingSource.List;
|
|---|
| 1118 | DataRowView row = datatable.AddNew();
|
|---|
| 1119 | row["Nr Wydania"] = nrWydania;
|
|---|
| 1120 |
|
|---|
| 1121 | rEKLAMAUKAZESIEWNRBindingSource.EndEdit();
|
|---|
| 1122 | }
|
|---|
| 1123 | catch (Exception e1)
|
|---|
| 1124 | {
|
|---|
| 1125 | Debugger.Log(0, "ttt", e1.Message);
|
|---|
| 1126 | }
|
|---|
| 1127 | }
|
|---|
| 1128 | }
|
|---|
| 1129 | }
|
|---|
| 1130 | }
|
|---|
| 1131 | }
|
|---|
| 1132 | }
|
|---|
| 1133 |
|
|---|
| 1134 | private void ogl_dzialComboBox_SelectedValueChanged(object sender, EventArgs e)
|
|---|
| 1135 | {
|
|---|
| 1136 | if (obslugaZdarzen)
|
|---|
| 1137 | {
|
|---|
| 1138 | if ((ogl_dzialComboBox.SelectedValue != null) && (lISTATYTULOWBindingSource.Current != null))
|
|---|
| 1139 | {
|
|---|
| 1140 | DataRowView row = (DataRowView)lISTATYTULOWBindingSource.Current;
|
|---|
| 1141 | string filter = "dzial=" + ogl_dzialComboBox.SelectedValue.ToString();
|
|---|
| 1142 |
|
|---|
| 1143 | switch (tYTULComboBox.SelectedValue.ToString())
|
|---|
| 1144 | {
|
|---|
| 1145 | case "AMT":
|
|---|
| 1146 | filter += " AND TYTU£='2'";
|
|---|
| 1147 | break;
|
|---|
| 1148 | case "GS":
|
|---|
| 1149 | filter += " AND TYTU£='1'";
|
|---|
| 1150 | break;
|
|---|
| 1151 | case "AGRO":
|
|---|
| 1152 | filter += " AND TYTU£='7'";
|
|---|
| 1153 | break;
|
|---|
| 1154 | case "adMot":
|
|---|
| 1155 | filter += " AND TYTU£='6'";
|
|---|
| 1156 | break;
|
|---|
| 1157 | default:
|
|---|
| 1158 | break;
|
|---|
| 1159 | }
|
|---|
| 1160 |
|
|---|
| 1161 | oglrozdzialyBindingSource.Filter = filter;
|
|---|
| 1162 |
|
|---|
| 1163 | DataRowView Rekrow = (DataRowView)rEKLAMABindingSource.Current;
|
|---|
| 1164 |
|
|---|
| 1165 | if (Rekrow["ogl_rozdzial"] == DBNull.Value)
|
|---|
| 1166 | {
|
|---|
| 1167 | ogl_rozdzialComboBox.SelectedIndex = -1;
|
|---|
| 1168 | ogl_rozdzialComboBox.SelectedIndex = -1;
|
|---|
| 1169 | }
|
|---|
| 1170 | }
|
|---|
| 1171 | }
|
|---|
| 1172 | }
|
|---|
| 1173 |
|
|---|
| 1174 | private void EmailButton_Click(object sender, EventArgs e)
|
|---|
| 1175 | {
|
|---|
| 1176 | StringBuilder tresc = new StringBuilder();
|
|---|
| 1177 |
|
|---|
| 1178 | tresc.Append("Potwierdzamy przyjêcie podpisanego zamówienia na publikacjê reklamy w ");
|
|---|
| 1179 |
|
|---|
| 1180 | if (tYTULComboBox.Text != "adMoto")
|
|---|
| 1181 | {
|
|---|
| 1182 | tresc.Append(" gazecie \"" + tYTULComboBox.Text + "\"");
|
|---|
| 1183 | }
|
|---|
| 1184 | else
|
|---|
| 1185 | {
|
|---|
| 1186 | tresc.Append(" portalu internetowym " + tYTULComboBox.Text);
|
|---|
| 1187 | }
|
|---|
| 1188 |
|
|---|
| 1189 | tresc.Append(" o wartoci " + bRUTTOTextBox.Text + ".");
|
|---|
| 1190 | //String.Format("{0:P}", cevent.Value);
|
|---|
| 1191 |
|
|---|
| 1192 | tresc.AppendLine("");
|
|---|
| 1193 | tresc.AppendLine("Reklamy zostan¹ wyemitowane zgodnie z umow¹ w wydaniu(-ach) nr: \n");
|
|---|
| 1194 |
|
|---|
| 1195 | foreach (DataGridViewRow r in ukazeSieDataGridView.Rows)
|
|---|
| 1196 | {
|
|---|
| 1197 | if (r.Cells["nrWydaniaDataGridViewTextBoxColumn"].Value != null)
|
|---|
| 1198 | {
|
|---|
| 1199 | tresc.Append(r.Cells["nrWydaniaDataGridViewTextBoxColumn"].Value.ToString() + ", ");
|
|---|
| 1200 | }
|
|---|
| 1201 | }
|
|---|
| 1202 |
|
|---|
| 1203 | tresc.Remove(tresc.Length - 2, 1);
|
|---|
| 1204 |
|
|---|
| 1205 | tresc.AppendLine(" w/w tytu³u i udokumentowane faktur¹ VAT przes³an¹ na wskazany adres.");
|
|---|
| 1206 |
|
|---|
| 1207 | MailForm mf = new MailForm(Utils.customerId(this.reklamaId), "Potwierdzenie z³o¿enia zamówienia " + iD_REKLAMYTextBox.Text, "", tresc.ToString());
|
|---|
| 1208 |
|
|---|
| 1209 | mf.ShowDialog();
|
|---|
| 1210 | }
|
|---|
| 1211 |
|
|---|
| 1212 | private void button3_Click(object sender, EventArgs e)
|
|---|
| 1213 | {
|
|---|
| 1214 | ogl_rozdzialComboBox.SelectedIndex = -1;
|
|---|
| 1215 | ogl_rozdzialComboBox.SelectedIndex = -1;
|
|---|
| 1216 | }
|
|---|
| 1217 |
|
|---|
| 1218 | private void kalendarzButton_Click(object sender, EventArgs e)
|
|---|
| 1219 | {
|
|---|
| 1220 | if (tYTULComboBox.SelectedValue != null)
|
|---|
| 1221 | {
|
|---|
| 1222 | // nie moze byc Copy() bo moze zawierac wiersza do skasowania
|
|---|
| 1223 | REKLAMADataSet.UKAZE_SIE_W_NRDataTable table =
|
|---|
| 1224 | (REKLAMADataSet.UKAZE_SIE_W_NRDataTable)
|
|---|
| 1225 | this.rEKLAMADataSet.UKAZE_SIE_W_NR.Copy();
|
|---|
| 1226 |
|
|---|
| 1227 | REKLAMADataSet.REKLAMARow reklama = (REKLAMADataSet.REKLAMARow)
|
|---|
| 1228 | ((DataRowView)(this.rEKLAMABindingSource.Current)).Row;
|
|---|
| 1229 |
|
|---|
| 1230 | KalendarzEmisji kalendarz =
|
|---|
| 1231 | new KalendarzEmisji(tYTULComboBox.SelectedValue.ToString(), reklama, table);
|
|---|
| 1232 |
|
|---|
| 1233 | if (kalendarz.ShowDialog() == DialogResult.OK)
|
|---|
| 1234 | {
|
|---|
| 1235 | DataRow[] rows = kalendarz.Emisje.Select("1=1", "[nr wydania] asc");
|
|---|
| 1236 | // this.rEKLAMADataSet.UKAZE_SIE_W_NR.Clear();
|
|---|
| 1237 | for (int i = 0; i < rows.Length; i++)
|
|---|
| 1238 | {
|
|---|
| 1239 | if (rEKLAMADataSet.UKAZE_SIE_W_NR.FindByID(
|
|---|
| 1240 | Convert.ToDecimal(rows[i]["id"])) == null)
|
|---|
| 1241 | {
|
|---|
| 1242 | this.rEKLAMADataSet.UKAZE_SIE_W_NR.ImportRow(
|
|---|
| 1243 | (REKLAMADataSet.UKAZE_SIE_W_NRRow)rows[i]);
|
|---|
| 1244 | }
|
|---|
| 1245 | }
|
|---|
| 1246 |
|
|---|
| 1247 | kalendarz.Close();
|
|---|
| 1248 |
|
|---|
| 1249 | ukazeSieDataGridView.EndEdit();
|
|---|
| 1250 | rEKLAMAUKAZESIEWNRBindingSource.EndEdit();
|
|---|
| 1251 |
|
|---|
| 1252 | // int il = this.rEKLAMADataSet.UKAZE_SIE_W_NR.Count;
|
|---|
| 1253 | int il = ukazeSieDataGridView.Rows.Count;
|
|---|
| 1254 | this.kROTNOSCTextBox.Text = il.ToString();
|
|---|
| 1255 | this.liczbaEmisjiLabel.Text = il.ToString();
|
|---|
| 1256 | rEKLAMABindingSource.EndEdit();
|
|---|
| 1257 |
|
|---|
| 1258 | PrzeliczCaleZamowienie();
|
|---|
| 1259 | }
|
|---|
| 1260 | }
|
|---|
| 1261 | }
|
|---|
| 1262 |
|
|---|
| 1263 | private void nowaEmisja(object sender, DataTableNewRowEventArgs e)
|
|---|
| 1264 | {
|
|---|
| 1265 | ((REKLAMADataSet.UKAZE_SIE_W_NRRow)e.Row).dataDodania = DateTime.Today;
|
|---|
| 1266 | }
|
|---|
| 1267 |
|
|---|
| 1268 | private void ukazeSieDataGridView_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
|
|---|
| 1269 | {
|
|---|
| 1270 | DataGridViewRow clickedRow = ukazeSieDataGridView.Rows[e.RowIndex];
|
|---|
| 1271 |
|
|---|
| 1272 | if (!ukazeSieDataGridView.SelectedRows.Contains(clickedRow))
|
|---|
| 1273 | {
|
|---|
| 1274 | e.ContextMenuStrip = null;
|
|---|
| 1275 | return;
|
|---|
| 1276 | }
|
|---|
| 1277 |
|
|---|
| 1278 | zmienToolStripMenuItem.Visible = true;
|
|---|
| 1279 | usunToolStripMenuItem.Visible = true;
|
|---|
| 1280 | anulujToolStripMenuItem.Visible = false;
|
|---|
| 1281 |
|
|---|
| 1282 | if (ukazeSieDataGridView.SelectedRows.Count == 1)
|
|---|
| 1283 | {
|
|---|
| 1284 | if (clickedRow.Selected)
|
|---|
| 1285 | {
|
|---|
| 1286 | if (clickedRow.DefaultCellStyle.BackColor == Color.MintCream)
|
|---|
| 1287 | {
|
|---|
| 1288 | zmienToolStripMenuItem.Visible = false;
|
|---|
| 1289 | usunToolStripMenuItem.Visible = false;
|
|---|
| 1290 | anulujToolStripMenuItem.Visible = false;
|
|---|
| 1291 |
|
|---|
| 1292 | e.ContextMenuStrip = emisjeContextMenuStrip;
|
|---|
| 1293 | return;
|
|---|
| 1294 | }
|
|---|
| 1295 |
|
|---|
| 1296 | DataRowView emisja = (DataRowView)ukazeSieDataGridView.Rows[e.RowIndex].DataBoundItem;
|
|---|
| 1297 | REKLAMADataSet.UKAZE_SIE_W_NRRow emisjaRow = (REKLAMADataSet.UKAZE_SIE_W_NRRow)emisja.Row;
|
|---|
| 1298 |
|
|---|
| 1299 | if (emisjaRow.zafakturowana)
|
|---|
| 1300 | {
|
|---|
| 1301 | zmienToolStripMenuItem.Visible = true;
|
|---|
| 1302 | usunToolStripMenuItem.Visible = false;
|
|---|
| 1303 | anulujToolStripMenuItem.Visible = true;
|
|---|
| 1304 |
|
|---|
| 1305 | e.ContextMenuStrip = emisjeContextMenuStrip;
|
|---|
| 1306 | return;
|
|---|
| 1307 | }
|
|---|
| 1308 | }
|
|---|
| 1309 | }
|
|---|
| 1310 |
|
|---|
| 1311 | else if (ukazeSieDataGridView.SelectedRows.Count > 1)
|
|---|
| 1312 | {
|
|---|
| 1313 | zmienToolStripMenuItem.Visible = false;
|
|---|
| 1314 | usunToolStripMenuItem.Visible = true;
|
|---|
| 1315 | anulujToolStripMenuItem.Visible = false;
|
|---|
| 1316 |
|
|---|
| 1317 | foreach (DataGridViewRow r in ukazeSieDataGridView.SelectedRows)
|
|---|
| 1318 | {
|
|---|
| 1319 | if (r.DefaultCellStyle.BackColor == Color.MintCream)
|
|---|
| 1320 | {
|
|---|
| 1321 | usunToolStripMenuItem.Visible = false;
|
|---|
| 1322 | break;
|
|---|
| 1323 | }
|
|---|
| 1324 |
|
|---|
| 1325 | if (Convert.ToBoolean(((DataRowView)r.DataBoundItem)["zafakturowana"]) == true)
|
|---|
| 1326 | {
|
|---|
| 1327 | usunToolStripMenuItem.Visible = false;
|
|---|
| 1328 | break;
|
|---|
| 1329 | }
|
|---|
| 1330 | }
|
|---|
| 1331 |
|
|---|
| 1332 | e.ContextMenuStrip = emisjeContextMenuStrip;
|
|---|
| 1333 | return;
|
|---|
| 1334 | }
|
|---|
| 1335 |
|
|---|
| 1336 | e.ContextMenuStrip = emisjeContextMenuStrip;
|
|---|
| 1337 |
|
|---|
| 1338 | }
|
|---|
| 1339 |
|
|---|
| 1340 | public void usunEmisje(object sender, EventArgs e)
|
|---|
| 1341 | {
|
|---|
| 1342 | foreach (DataGridViewRow r in ukazeSieDataGridView.SelectedRows)
|
|---|
| 1343 | {
|
|---|
| 1344 | ukazeSieDataGridView.Rows.Remove(r);
|
|---|
| 1345 | }
|
|---|
| 1346 |
|
|---|
| 1347 | ukazeSieDataGridView.EndEdit();
|
|---|
| 1348 | rEKLAMAUKAZESIEWNRBindingSource.EndEdit();
|
|---|
| 1349 |
|
|---|
| 1350 | // int il = this.rEKLAMADataSet.UKAZE_SIE_W_NR.Count;
|
|---|
| 1351 | int il = ukazeSieDataGridView.Rows.Count;
|
|---|
| 1352 | this.kROTNOSCTextBox.Text = il.ToString();
|
|---|
| 1353 | this.liczbaEmisjiLabel.Text = il.ToString();
|
|---|
| 1354 | rEKLAMABindingSource.EndEdit();
|
|---|
| 1355 |
|
|---|
| 1356 | PrzeliczCaleZamowienie();
|
|---|
| 1357 |
|
|---|
| 1358 | }
|
|---|
| 1359 |
|
|---|
| 1360 | private void anulujEmisje(object sender, EventArgs e)
|
|---|
| 1361 | {
|
|---|
| 1362 | if (ukazeSieDataGridView.CurrentCell != null)
|
|---|
| 1363 | {
|
|---|
| 1364 | DataGridViewRow r1 = ukazeSieDataGridView.CurrentCell.OwningRow;
|
|---|
| 1365 |
|
|---|
| 1366 | REKLAMADataSet.UKAZE_SIE_W_NRRow row = (REKLAMADataSet.UKAZE_SIE_W_NRRow)(((DataRowView)r1.DataBoundItem).Row);
|
|---|
| 1367 |
|
|---|
| 1368 | row.status = 2;
|
|---|
| 1369 | row.dataAnulowania = DateTime.Now;
|
|---|
| 1370 | }
|
|---|
| 1371 | }
|
|---|
| 1372 |
|
|---|
| 1373 | private void zmienEmisje(object sender, EventArgs e)
|
|---|
| 1374 | {
|
|---|
| 1375 | if (tYTULComboBox.SelectedValue != null)
|
|---|
| 1376 | {
|
|---|
| 1377 | REKLAMADataSet.UKAZE_SIE_W_NRDataTable table =
|
|---|
| 1378 | (REKLAMADataSet.UKAZE_SIE_W_NRDataTable)
|
|---|
| 1379 | this.rEKLAMADataSet.UKAZE_SIE_W_NR.Copy();
|
|---|
| 1380 |
|
|---|
| 1381 | REKLAMADataSet.REKLAMARow reklama = (REKLAMADataSet.REKLAMARow)
|
|---|
| 1382 | ((DataRowView)(this.rEKLAMABindingSource.Current)).Row;
|
|---|
| 1383 |
|
|---|
| 1384 | KalendarzEmisji kalendarz = new KalendarzEmisji(
|
|---|
| 1385 | tYTULComboBox.SelectedValue.ToString(),
|
|---|
| 1386 | reklama,
|
|---|
| 1387 | table,
|
|---|
| 1388 | (short)ukazeSieDataGridView.CurrentCell.Value);
|
|---|
| 1389 |
|
|---|
| 1390 | if (kalendarz.ShowDialog() == DialogResult.OK)
|
|---|
| 1391 | {
|
|---|
| 1392 | if (ukazeSieDataGridView.CurrentCell != null)
|
|---|
| 1393 | {
|
|---|
| 1394 | DataGridViewRow r1 = ukazeSieDataGridView.CurrentCell.OwningRow;
|
|---|
| 1395 | REKLAMADataSet.UKAZE_SIE_W_NRRow row = (REKLAMADataSet.UKAZE_SIE_W_NRRow)(((DataRowView)r1.DataBoundItem).Row);
|
|---|
| 1396 |
|
|---|
| 1397 | if (row.zafakturowana && (row.Nr_Wydania != kalendarz.NowaEmisja))
|
|---|
| 1398 | {
|
|---|
| 1399 | rEKLAMADataSet.zmianyEmisji.AddzmianyEmisjiRow(row, row.Nr_Wydania, kalendarz.NowaEmisja, DateTime.Now);
|
|---|
| 1400 | }
|
|---|
| 1401 |
|
|---|
| 1402 | row.Nr_Wydania = kalendarz.NowaEmisja;
|
|---|
| 1403 | kalendarz.Close();
|
|---|
| 1404 |
|
|---|
| 1405 | row.EndEdit();
|
|---|
| 1406 | this.rEKLAMADataSet.UKAZE_SIE_W_NR.EndInit();
|
|---|
| 1407 | this.rEKLAMAUKAZESIEWNRBindingSource.ResetBindings(false);
|
|---|
| 1408 | }
|
|---|
| 1409 | }
|
|---|
| 1410 | }
|
|---|
| 1411 | }
|
|---|
| 1412 |
|
|---|
| 1413 |
|
|---|
| 1414 | private void ukazeSieDataGridView_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
|
|---|
| 1415 | {
|
|---|
| 1416 | if (ukazaloSieDataGridView.Rows.Count > 0)
|
|---|
| 1417 | {
|
|---|
| 1418 | tYTULComboBox.Enabled = false;
|
|---|
| 1419 | }
|
|---|
| 1420 | else
|
|---|
| 1421 | {
|
|---|
| 1422 | tYTULComboBox.Enabled = true;
|
|---|
| 1423 | }
|
|---|
| 1424 | }
|
|---|
| 1425 |
|
|---|
| 1426 | private void ukazeSieDataGridView_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
|
|---|
| 1427 | {
|
|---|
| 1428 | blokowanieZrealizowanychEmisji();
|
|---|
| 1429 | }
|
|---|
| 1430 |
|
|---|
| 1431 | private void walutyComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
|---|
| 1432 | {
|
|---|
| 1433 | if (obslugaZdarzen)
|
|---|
| 1434 | {
|
|---|
| 1435 | if (walutyComboBox.SelectedIndex != -1)
|
|---|
| 1436 | {
|
|---|
| 1437 | kurs = PobierzKurs(walutyComboBox.SelectedItem.ToString());
|
|---|
| 1438 | PrzeliczCaleZamowienie();
|
|---|
| 1439 | }
|
|---|
| 1440 | }
|
|---|
| 1441 | }
|
|---|
| 1442 |
|
|---|
| 1443 | private void PrzeliczCaleZamowienie()
|
|---|
| 1444 | {
|
|---|
| 1445 | DataRowView row = (DataRowView)rEKLAMABindingSource.Current;
|
|---|
| 1446 | REKLAMADataSet.REKLAMARow reklama = (REKLAMADataSet.REKLAMARow)row.Row;
|
|---|
| 1447 |
|
|---|
| 1448 | if (walutyComboBox.SelectedIndex != 0)
|
|---|
| 1449 | {
|
|---|
| 1450 | if (reklama.IsBrutto_EuroNull()){
|
|---|
| 1451 | reklama.Brutto_Euro = 0;
|
|---|
| 1452 | reklama.EndEdit();
|
|---|
| 1453 | }
|
|---|
| 1454 |
|
|---|
| 1455 | if (kurs != null)
|
|---|
| 1456 | {
|
|---|
| 1457 | przeliczWaluteNaZlotowki(kurs);
|
|---|
| 1458 | }
|
|---|
| 1459 | else
|
|---|
| 1460 | {
|
|---|
| 1461 | kurs = PobierzKurs(walutyComboBox.SelectedItem.ToString());
|
|---|
| 1462 |
|
|---|
| 1463 | if (kurs == null)
|
|---|
| 1464 | {
|
|---|
| 1465 | MessageBox.Show("Wyst¹pi³ b³¹d!");
|
|---|
| 1466 | }
|
|---|
| 1467 | else
|
|---|
| 1468 | {
|
|---|
| 1469 | przeliczWaluteNaZlotowki(kurs);
|
|---|
| 1470 | }
|
|---|
| 1471 | }
|
|---|
| 1472 | }
|
|---|
| 1473 | else
|
|---|
| 1474 | {
|
|---|
| 1475 | if (row["id_faktury"] == DBNull.Value)
|
|---|
| 1476 | {
|
|---|
| 1477 | row["waluta_tabela_nr"] = DBNull.Value;
|
|---|
| 1478 | row["waluta_Przelicznik"] = DBNull.Value;
|
|---|
| 1479 | row["waluta_kurs"] = DBNull.Value;
|
|---|
| 1480 | row["waluta_kurs_z_dnia"] = DBNull.Value;
|
|---|
| 1481 | row["Brutto_Euro"] = DBNull.Value;
|
|---|
| 1482 | row["Brutto_Euro_Miano"] = DBNull.Value;
|
|---|
| 1483 | row["FAKTURA ID KONTA"] = 1;
|
|---|
| 1484 |
|
|---|
| 1485 | rEKLAMABindingSource.EndEdit();
|
|---|
| 1486 | przelicz();
|
|---|
| 1487 | }
|
|---|
| 1488 | else
|
|---|
| 1489 | {
|
|---|
| 1490 | MessageBox.Show("Faktura zosta³a ju¿ wystawiona!");
|
|---|
| 1491 | }
|
|---|
| 1492 | }
|
|---|
| 1493 | }
|
|---|
| 1494 |
|
|---|
| 1495 | private SLOWNIKDataSet.Kursy_WalutRow PobierzKurs(string kodWaluty)
|
|---|
| 1496 | {
|
|---|
| 1497 | SLOWNIKDataSet.Kursy_WalutDataTable kursy = kursy_WalutTableAdapter.GetDataByDataPublikacji(
|
|---|
| 1498 | kodWaluty, DateTime.Today);
|
|---|
| 1499 |
|
|---|
| 1500 | if (kursy.Count == 0)
|
|---|
| 1501 | {
|
|---|
| 1502 | return null;
|
|---|
| 1503 | }
|
|---|
| 1504 | else
|
|---|
| 1505 | {
|
|---|
| 1506 | return kursy[0];
|
|---|
| 1507 | }
|
|---|
| 1508 | }
|
|---|
| 1509 |
|
|---|
| 1510 | private void brutto_EuroTextBox_Leave(object sender, EventArgs e)
|
|---|
| 1511 | {
|
|---|
| 1512 | rEKLAMABindingSource.EndEdit();
|
|---|
| 1513 | PrzeliczCaleZamowienie();
|
|---|
| 1514 | }
|
|---|
| 1515 |
|
|---|
| 1516 | private void rABATTextBox_Leave(object sender, EventArgs e)
|
|---|
| 1517 | {
|
|---|
| 1518 | rEKLAMABindingSource.EndEdit();
|
|---|
| 1519 | PrzeliczCaleZamowienie();
|
|---|
| 1520 | }
|
|---|
| 1521 |
|
|---|
| 1522 | private void pVATComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
|---|
| 1523 | {
|
|---|
| 1524 | rEKLAMABindingSource.EndEdit();
|
|---|
| 1525 | PrzeliczCaleZamowienie();
|
|---|
| 1526 | }
|
|---|
| 1527 |
|
|---|
| 1528 | private void cENA_JEDNTextBox_Leave(object sender, EventArgs e)
|
|---|
| 1529 | {
|
|---|
| 1530 | rEKLAMABindingSource.EndEdit();
|
|---|
| 1531 | PrzeliczCaleZamowienie();
|
|---|
| 1532 | }
|
|---|
| 1533 |
|
|---|
| 1534 | private void wyroznienieCheckBox_Click(object sender, EventArgs e)
|
|---|
| 1535 | {
|
|---|
| 1536 | this.rEKLAMABindingSource.EndEdit();
|
|---|
| 1537 | PrzeliczCaleZamowienie();
|
|---|
| 1538 |
|
|---|
| 1539 | }
|
|---|
| 1540 |
|
|---|
| 1541 | /// <summary>
|
|---|
| 1542 | /// formatowanie do decimal -> %
|
|---|
| 1543 | /// </summary>
|
|---|
| 1544 | private void DecimalToProcent(object sender, ConvertEventArgs cevent)
|
|---|
| 1545 | {
|
|---|
| 1546 | if (Convert.ToDecimal(cevent.Value) > 1)
|
|---|
| 1547 | {
|
|---|
| 1548 | // cevent.Value = Convert.ToDecimal(cevent.Value) / 100;
|
|---|
| 1549 | }
|
|---|
| 1550 | cevent.Value = String.Format("{0:P}", cevent.Value);
|
|---|
| 1551 | }
|
|---|
| 1552 |
|
|---|
| 1553 | /// <summary>
|
|---|
| 1554 | /// formatowanie do % -> decimal
|
|---|
| 1555 | /// </summary>
|
|---|
| 1556 | private void ProcentToDecimal(object sender, ConvertEventArgs cevent)
|
|---|
| 1557 | {
|
|---|
| 1558 | string pom = cevent.Value.ToString();
|
|---|
| 1559 | if (cevent.Value.ToString().EndsWith("%"))
|
|---|
| 1560 | {
|
|---|
| 1561 | pom = cevent.Value.ToString().Substring(0, cevent.Value.ToString().Length - 1);
|
|---|
| 1562 | }
|
|---|
| 1563 | decimal p = Decimal.Parse(pom) / 100;
|
|---|
| 1564 | cevent.Value = p.ToString();
|
|---|
| 1565 | }
|
|---|
| 1566 |
|
|---|
| 1567 | private void init()
|
|---|
| 1568 | {
|
|---|
| 1569 | if (rEKLAMABindingSource.Current != null)
|
|---|
| 1570 | {
|
|---|
| 1571 | DataRowView row = (DataRowView)rEKLAMABindingSource.Current;
|
|---|
| 1572 | REKLAMADataSet.REKLAMARow reklama = (REKLAMADataSet.REKLAMARow)row.Row;
|
|---|
| 1573 | //wyliczona cena modulu
|
|---|
| 1574 | double szer = reklama.SZER;
|
|---|
| 1575 | double wys = reklama.WYS;
|
|---|
| 1576 | int krotnosc = reklama.KROTNOÆ;
|
|---|
| 1577 | double cenaJednostkowa = reklama.CENA_JEDN;
|
|---|
| 1578 | double vatProcent = reklama.VAT;
|
|---|
| 1579 | double prowizjaProcent = reklama.PROCENT_PROWIZJI;
|
|---|
| 1580 | double rabatProcent = reklama.RABAT;
|
|---|
| 1581 | double rabatWartosc = rabatProcent * cenaJednostkowa;
|
|---|
| 1582 | double netto = (cenaJednostkowa - rabatWartosc) * krotnosc;
|
|---|
| 1583 | double cenaModulu;
|
|---|
| 1584 | if ((szer * wys * krotnosc) != 0)
|
|---|
| 1585 | {
|
|---|
| 1586 | cenaModulu = netto / (szer * wys * krotnosc);
|
|---|
| 1587 | cenaModuluLabel.Text = String.Format("{0:C}", cenaModulu);
|
|---|
| 1588 | }
|
|---|
| 1589 | else
|
|---|
| 1590 | {
|
|---|
| 1591 | cenaModuluLabel.Text = "---";
|
|---|
| 1592 | }
|
|---|
| 1593 |
|
|---|
| 1594 | liczbaEmisjiLabel.Text = this.rEKLAMADataSet.UKAZE_SIE_W_NR.Rows.Count.ToString();
|
|---|
| 1595 |
|
|---|
| 1596 | this.obslugaZdarzen = false;
|
|---|
| 1597 | if (!reklama.IsBrutto_Euro_MianoNull())
|
|---|
| 1598 | {
|
|---|
| 1599 | walutyComboBox.SelectedItem = reklama.Brutto_Euro_Miano;
|
|---|
| 1600 | }
|
|---|
| 1601 | else
|
|---|
| 1602 | {
|
|---|
| 1603 | walutyComboBox.SelectedIndex = 0; //PLN
|
|---|
| 1604 | }
|
|---|
| 1605 | this.obslugaZdarzen = true;
|
|---|
| 1606 | }
|
|---|
| 1607 | }
|
|---|
| 1608 | }
|
|---|
| 1609 | }
|
|---|