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 PaymentForm2 : Form
    {
        private int idWplaty;

        public int IdWplaty
        {
            get { return idWplaty; }
            set { idWplaty = value; }
        }
        private int idFaktury;

        public PaymentForm2(int idWplaty, int idFaktury)
        {
            this.idWplaty = idWplaty;
            this.idFaktury = idFaktury;
            InitializeComponent();
        }

        private void PaymentForm_Load(object sender, EventArgs e)
        {

            this.rEKLAMADataSet.Wplaty.Constraints.Remove("FAKTURY_Wplaty");

            wplatyTableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;
            VIEW_ZESTAWIENIE_FAKTUR_NOWETableAdapter.Connection.ConnectionString = ConnString.getConnString().Value;

            this.VIEW_ZESTAWIENIE_FAKTUR_NOWETableAdapter.FillByIdFaktury(this.rEKLAMADataSet.VIEW_ZESTAWIENIE_FAKTUR_NOWE, idFaktury);

            if (idWplaty == 0)
            {
                DataRowView row = (DataRowView)wplatyBindingSource.AddNew();
                row["idFaktury"] = idFaktury;
                row["idZamowienia"] = this.rEKLAMADataSet.VIEW_ZESTAWIENIE_FAKTUR_NOWE[0].idZamowienia;
                wplatyBindingSource.EndEdit();
            }
            else
            {
                wplatyTableAdapter.FillByIdWplaty(this.rEKLAMADataSet.Wplaty, idWplaty);
            }
        }

        private void dodajButton_Click(object sender, EventArgs e)
        {
            /*
            if ((sYMBOL_POTWIERDZENIATextBox.Text == "") | (rODZAJ_POTWIERDZENIAComboBox.SelectedIndex == -1))
            {
                MessageBox.Show("Uzupełnij wszystkie pola");
                return;
            }
            
            this.Validate();

            this.wplatyBindingSource.EndEdit();
            this.wplatyTableAdapter.Update(this.rEKLAMADataSet.Wplaty);
            this.idWplaty = rEKLAMADataSet.Wplaty[0].idWplaty;
             */
            this.DialogResult = DialogResult.OK;
        }

        private void anulujButton_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }
    }
}