| 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 AddZamowienieForm(int idZam, int idKlienta)
|
|---|
| 17 | {
|
|---|
| 18 | InitializeComponent();
|
|---|
| 19 |
|
|---|
| 20 | this.zamowieniaTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 21 | this.kONTATableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 22 | this.aGENCITableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 23 | this.klienciTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
|
|---|
| 24 |
|
|---|
| 25 | List<BoundItem> list = new List<BoundItem>();
|
|---|
| 26 | list.Add(new BoundItem(7,"7 dni"));
|
|---|
| 27 | list.Add(new BoundItem(14,"14 dni"));
|
|---|
| 28 | list.Add(new BoundItem(30,"30 dni"));
|
|---|
| 29 | czasPlatnosciListBox.DisplayMember = "DisplayValue";
|
|---|
| 30 | czasPlatnosciListBox.ValueMember = "IDEvalue1";
|
|---|
| 31 | czasPlatnosciListBox.DataSource = list;
|
|---|
| 32 |
|
|---|
| 33 | REKLAMADataSet.zamowieniaRow row;
|
|---|
| 34 | if (idZam == 0)
|
|---|
| 35 | {
|
|---|
| 36 | DataView table = (DataView)zamowieniaBindingSource.List;
|
|---|
| 37 | DataRowView r = table.AddNew();
|
|---|
| 38 | row = (REKLAMADataSet.zamowieniaRow)r.Row;
|
|---|
| 39 |
|
|---|
| 40 | row.nrZamowienia = Utils.numerNowegoZamowienia(idKlienta, DateTime.Today.Year);
|
|---|
| 41 | row.rokZamowienia = DateTime.Today.Year;
|
|---|
| 42 | row.kodAgenta = User.getUser().Kod_agenta;
|
|---|
| 43 | row.idKlienta = idKlienta;
|
|---|
| 44 |
|
|---|
| 45 | row.EndEdit();
|
|---|
| 46 | this.zamowieniaBindingSource.EndEdit();
|
|---|
| 47 | }
|
|---|
| 48 | else
|
|---|
| 49 | {
|
|---|
| 50 | this.zamowieniaTableAdapter.FillByIdZamowienia(this.rEKLAMADataSet.zamowienia, idZam);
|
|---|
| 51 | row = this.rEKLAMADataSet.zamowienia[0];
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 | REKLAMADataSet.KLIENCIRow k = (REKLAMADataSet.KLIENCIRow)klienciTableAdapter.GetDataByCustomerId(row.idKlienta)[0];
|
|---|
| 55 | numerZamowieniaLabel1.Text = k.kodKlienta + "/" + row.rokZamowienia + "/" + row.kodAgenta + "/" + row.nrZamowienia;
|
|---|
| 56 |
|
|---|
| 57 | notatkaKierownikTextBox.ReadOnly = !(User.getUser().St_kierownik);
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 | private void AddZamowienieForm_Load(object sender, EventArgs e)
|
|---|
| 61 | {
|
|---|
| 62 | string agent = ((DataRowView)zamowieniaBindingSource.Current)["kodAgenta"].ToString();
|
|---|
| 63 | int idAgencji = Utils.idAgencji(agent);
|
|---|
| 64 |
|
|---|
| 65 | this.kONTATableAdapter.FillByIdAgencji(this.sLOWNIKDataSet.KONTA, idAgencji);
|
|---|
| 66 | this.aGENCITableAdapter.FillByAktywny(this.sLOWNIKDataSet.AGENCI);
|
|---|
| 67 |
|
|---|
| 68 | this.zamowieniaBindingSource.ResetBindings(false);
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 | private void anulujButton_Click(object sender, EventArgs e)
|
|---|
| 72 | {
|
|---|
| 73 |
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 | private void button3_Click(object sender, EventArgs e)
|
|---|
| 77 | {
|
|---|
| 78 | if (kONTABindingSource.Current != null)
|
|---|
| 79 | {
|
|---|
| 80 | DataRowView row = (DataRowView)kONTABindingSource.Current;
|
|---|
| 81 | MessageBox.Show(row["konto"].ToString());
|
|---|
| 82 | }
|
|---|
| 83 | }
|
|---|
| 84 |
|
|---|
| 85 | private void zapiszButton_Click(object sender, EventArgs e)
|
|---|
| 86 | {
|
|---|
| 87 | this.zamowieniaBindingSource.EndEdit();
|
|---|
| 88 | zamowieniaTableAdapter.Update(this.rEKLAMADataSet.zamowienia);
|
|---|
| 89 | }
|
|---|
| 90 | }
|
|---|
| 91 | } |
|---|