using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Baza_Reklam
{
    public partial class AgencjaAddForm : Form
    {
        public AgencjaAddForm(int idAgencji)
        {
            InitializeComponent();

            this.aGENCJETableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;

            if (idAgencji == 0)
            {
                 DataView table = ( DataView)aGENCJEBindingSource.List;
                 table.AddNew();
            }
            else
            {
                this.aGENCJETableAdapter.FillByIdAgencji(this.sLOWNIKDataSet.AGENCJE, idAgencji);             

            }
        }

        private void ZapiszButton_Click(object sender, EventArgs e)
        {
            if (symbolTextBox.Text == "")
            {
                MessageBox.Show("Wpisz symbol agencji");
                return;
            }

            this.aGENCJEBindingSource.EndEdit();
            this.aGENCJETableAdapter.Update(this.sLOWNIKDataSet.AGENCJE);
            MessageBox.Show("Zmiany zostały zapisane");
            this.Close();
        }

        private void AnulujButton_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}