| 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 |
|
|---|
| 16 | public REKLAMADataSet.zamowieniaDataTable Zamowienia
|
|---|
| 17 | {
|
|---|
| 18 | get
|
|---|
| 19 | {
|
|---|
| 20 | return this.rEKLAMADataSet.zamowienia;
|
|---|
| 21 | }
|
|---|
| 22 | }
|
|---|
| 23 |
|
|---|
| 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;
|
|---|
| 40 |
|
|---|
| 41 | REKLAMADataSet.zamowieniaRow row;
|
|---|
| 42 | if (idZam == 0)
|
|---|
| 43 | {
|
|---|
| 44 | DataView table = (DataView)zamowieniaBindingSource.List;
|
|---|
| 45 | DataRowView r = table.AddNew();
|
|---|
| 46 | row = (REKLAMADataSet.zamowieniaRow)r.Row;
|
|---|
| 47 |
|
|---|
| 48 | row.nrZamowienia = Utils.numerNowegoZamowienia(idKlienta, DateTime.Today.Year);
|
|---|
| 49 | row.rokZamowienia = DateTime.Today.Year;
|
|---|
| 50 | row.kodAgenta = User.getUser().Kod_agenta;
|
|---|
| 51 | row.idKlienta = idKlienta;
|
|---|
| 52 |
|
|---|
| 53 | row.EndEdit();
|
|---|
| 54 | this.zamowieniaBindingSource.EndEdit();
|
|---|
| 55 | }
|
|---|
| 56 | else
|
|---|
| 57 | {
|
|---|
| 58 | this.zamowieniaTableAdapter.FillByIdZamowienia(this.rEKLAMADataSet.zamowienia, idZam);
|
|---|
| 59 | row = this.rEKLAMADataSet.zamowienia[0];
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 | REKLAMADataSet.KLIENCIRow k = (REKLAMADataSet.KLIENCIRow)klienciTableAdapter.GetDataByCustomerId(row.idKlienta)[0];
|
|---|
| 63 | numerZamowieniaLabel1.Text = k.kodKlienta + "/" + row.rokZamowienia + "/" + row.kodAgenta + "/" + row.nrZamowienia;
|
|---|
| 64 |
|
|---|
| 65 | notatkaKierownikTextBox.ReadOnly = !(User.getUser().St_kierownik);
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | private void AddZamowienieForm_Load(object sender, EventArgs e)
|
|---|
| 69 | {
|
|---|
| 70 | string agent = ((DataRowView)zamowieniaBindingSource.Current)["kodAgenta"].ToString();
|
|---|
| 71 | int idAgencji = Utils.idAgencji(agent);
|
|---|
| 72 |
|
|---|
| 73 | this.kONTATableAdapter.FillByIdAgencji(this.sLOWNIKDataSet.KONTA, idAgencji);
|
|---|
| 74 | this.aGENCITableAdapter.FillByAktywny(this.sLOWNIKDataSet.AGENCI);
|
|---|
| 75 |
|
|---|
| 76 | this.zamowieniaBindingSource.ResetBindings(false);
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 | private void anulujButton_Click(object sender, EventArgs e)
|
|---|
| 80 | {
|
|---|
| 81 |
|
|---|
| 82 | }
|
|---|
| 83 |
|
|---|
| 84 | private void button3_Click(object sender, EventArgs e)
|
|---|
| 85 | {
|
|---|
| 86 | if (kONTABindingSource.Current != null)
|
|---|
| 87 | {
|
|---|
| 88 | DataRowView row = (DataRowView)kONTABindingSource.Current;
|
|---|
| 89 | MessageBox.Show(row["konto"].ToString());
|
|---|
| 90 | }
|
|---|
| 91 | }
|
|---|
| 92 |
|
|---|
| 93 | private void zapiszButton_Click(object sender, EventArgs e)
|
|---|
| 94 | {
|
|---|
| 95 | this.zamowieniaBindingSource.EndEdit();
|
|---|
| 96 | zamowieniaTableAdapter.Update(this.rEKLAMADataSet.zamowienia);
|
|---|
| 97 | }
|
|---|
| 98 | }
|
|---|
| 99 | } |
|---|