| [65] | 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 AddZamowienieForm : Form
|
|---|
| 12 | {
|
|---|
| 13 | private REKLAMADataSetTableAdapters.KLIENCITableAdapter klienciTableAdapter =
|
|---|
| 14 | new Baza_Reklam.REKLAMADataSetTableAdapters.KLIENCITableAdapter();
|
|---|
| 15 |
|
|---|
| [67] | 16 | public REKLAMADataSet.zamowieniaDataTable Zamowienia
|
|---|
| 17 | {
|
|---|
| 18 | get
|
|---|
| 19 | {
|
|---|
| 20 | return this.rEKLAMADataSet.zamowienia;
|
|---|
| 21 | }
|
|---|
| 22 | }
|
|---|
| 23 |
|
|---|
| [65] | 24 | public AddZamowienieForm(int idZam, int idKlienta)
|
|---|
| 25 | {
|
|---|
| 26 | InitializeComponent();
|
|---|
| 27 |
|
|---|
| 28 | this.zamowieniaTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 29 | this.kONTATableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 30 | this.aGENCITableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 31 | this.klienciTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 32 |
|
|---|
| 33 | List<BoundItem> list = new List<BoundItem>();
|
|---|
| 34 | list.Add(new BoundItem(7,"7 dni"));
|
|---|
| 35 | list.Add(new BoundItem(14,"14 dni"));
|
|---|
| 36 | list.Add(new BoundItem(30,"30 dni"));
|
|---|
| 37 | czasPlatnosciListBox.DisplayMember = "DisplayValue";
|
|---|
| 38 | czasPlatnosciListBox.ValueMember = "IDEvalue1";
|
|---|
| 39 | czasPlatnosciListBox.DataSource = list;
|
|---|
| [71] | 40 |
|
|---|
| [84] | 41 | procentProwizjiTextBox.DataBindings[0].Format += new ConvertEventHandler(DecimalToProcent);
|
|---|
| 42 | procentProwizjiTextBox.DataBindings[0].Parse += new ConvertEventHandler(ProcentToDecimal);
|
|---|
| 43 |
|
|---|
| [104] | 44 | //rABATTextBox.DataBindings[0].Format += new ConvertEventHandler(DecimalToProcent);
|
|---|
| 45 | //rABATTextBox.DataBindings[0].Parse += new ConvertEventHandler(ProcentToDecimal);
|
|---|
| [84] | 46 |
|
|---|
| [65] | 47 | REKLAMADataSet.zamowieniaRow row;
|
|---|
| 48 | if (idZam == 0)
|
|---|
| 49 | {
|
|---|
| 50 | DataView table = (DataView)zamowieniaBindingSource.List;
|
|---|
| 51 | DataRowView r = table.AddNew();
|
|---|
| 52 | row = (REKLAMADataSet.zamowieniaRow)r.Row;
|
|---|
| 53 |
|
|---|
| 54 | row.nrZamowienia = Utils.numerNowegoZamowienia(idKlienta, DateTime.Today.Year);
|
|---|
| 55 | row.rokZamowienia = DateTime.Today.Year;
|
|---|
| 56 | row.kodAgenta = User.getUser().Kod_agenta;
|
|---|
| 57 | row.idKlienta = idKlienta;
|
|---|
| 58 |
|
|---|
| 59 | row.EndEdit();
|
|---|
| 60 | this.zamowieniaBindingSource.EndEdit();
|
|---|
| 61 | }
|
|---|
| 62 | else
|
|---|
| 63 | {
|
|---|
| 64 | this.zamowieniaTableAdapter.FillByIdZamowienia(this.rEKLAMADataSet.zamowienia, idZam);
|
|---|
| 65 | row = this.rEKLAMADataSet.zamowienia[0];
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | REKLAMADataSet.KLIENCIRow k = (REKLAMADataSet.KLIENCIRow)klienciTableAdapter.GetDataByCustomerId(row.idKlienta)[0];
|
|---|
| 69 | numerZamowieniaLabel1.Text = k.kodKlienta + "/" + row.rokZamowienia + "/" + row.kodAgenta + "/" + row.nrZamowienia;
|
|---|
| 70 |
|
|---|
| [84] | 71 | kierownikGroupBox.Enabled = User.getUser().St_kierownik;
|
|---|
| [65] | 72 | }
|
|---|
| 73 |
|
|---|
| 74 | private void AddZamowienieForm_Load(object sender, EventArgs e)
|
|---|
| 75 | {
|
|---|
| 76 | string agent = ((DataRowView)zamowieniaBindingSource.Current)["kodAgenta"].ToString();
|
|---|
| [108] | 77 | int idAgencji = Utils.idAgencjiWgKoduAgenta(agent);
|
|---|
| [65] | 78 |
|
|---|
| 79 | this.kONTATableAdapter.FillByIdAgencji(this.sLOWNIKDataSet.KONTA, idAgencji);
|
|---|
| 80 | this.aGENCITableAdapter.FillByAktywny(this.sLOWNIKDataSet.AGENCI);
|
|---|
| 81 |
|
|---|
| 82 | this.zamowieniaBindingSource.ResetBindings(false);
|
|---|
| 83 | }
|
|---|
| 84 |
|
|---|
| 85 | private void anulujButton_Click(object sender, EventArgs e)
|
|---|
| 86 | {
|
|---|
| 87 |
|
|---|
| 88 | }
|
|---|
| 89 |
|
|---|
| 90 | private void button3_Click(object sender, EventArgs e)
|
|---|
| 91 | {
|
|---|
| 92 | if (kONTABindingSource.Current != null)
|
|---|
| 93 | {
|
|---|
| 94 | DataRowView row = (DataRowView)kONTABindingSource.Current;
|
|---|
| 95 | MessageBox.Show(row["konto"].ToString());
|
|---|
| 96 | }
|
|---|
| 97 | }
|
|---|
| 98 |
|
|---|
| 99 | private void zapiszButton_Click(object sender, EventArgs e)
|
|---|
| 100 | {
|
|---|
| 101 | this.zamowieniaBindingSource.EndEdit();
|
|---|
| 102 | zamowieniaTableAdapter.Update(this.rEKLAMADataSet.zamowienia);
|
|---|
| 103 | }
|
|---|
| [84] | 104 |
|
|---|
| 105 | /// <summary>
|
|---|
| 106 | /// formatowanie do decimal -> %
|
|---|
| 107 | /// </summary>
|
|---|
| 108 | private void DecimalToProcent(object sender, ConvertEventArgs cevent)
|
|---|
| 109 | {
|
|---|
| 110 | if (Convert.ToDecimal(cevent.Value) > 1)
|
|---|
| 111 | {
|
|---|
| 112 | // cevent.Value = Convert.ToDecimal(cevent.Value) / 100;
|
|---|
| 113 | }
|
|---|
| 114 | cevent.Value = String.Format("{0:P}", cevent.Value);
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | /// <summary>
|
|---|
| 118 | /// formatowanie do % -> decimal
|
|---|
| 119 | /// </summary>
|
|---|
| 120 | private void ProcentToDecimal(object sender, ConvertEventArgs cevent)
|
|---|
| 121 | {
|
|---|
| 122 | string pom = cevent.Value.ToString();
|
|---|
| 123 | if (cevent.Value.ToString().EndsWith("%"))
|
|---|
| 124 | {
|
|---|
| 125 | pom = cevent.Value.ToString().Substring(0, cevent.Value.ToString().Length - 1);
|
|---|
| 126 | }
|
|---|
| 127 | decimal p = Decimal.Parse(pom) / 100;
|
|---|
| 128 | cevent.Value = p.ToString();
|
|---|
| 129 | }
|
|---|
| [104] | 130 |
|
|---|
| 131 | private void procentProwizjiTextBox_TextChanged(object sender, EventArgs e)
|
|---|
| 132 | {
|
|---|
| 133 | this.zamowieniaBindingSource.EndEdit();
|
|---|
| 134 | }
|
|---|
| [65] | 135 | }
|
|---|
| 136 | } |
|---|