using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace hukpiWinApp
{
    public partial class SearchPartnerForm : BaseForm
    {
       public SearchPartnerForm()
        {
            InitializeComponent();
            
            this.Text = "Partnerek keresése";
        }

        private void buttonSearchStart_Click(object sender, EventArgs e)
        {
            try
            {
                this.partnerDataViewTableAdapter.FillBySearch(this.hukpiDatabaseDataSet.PartnerDataView, "%" + textBoxSearchName.Text + "%", "%" + textBoxSearchPartnerNumber.Text + "%", "%" + textBoxSearchOrderNumber.Text + "%", "%" + textBoxSearchPlace.Text + "%");
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
        }

        //private void SearchPartnerForm_Load(object sender, EventArgs e)
        //{
        //    // TODO: This line of code loads data into the 'hukpiDatabaseDataSet.PartnerDataView' table. You can move, or remove it, as needed.
        //    this.partnerDataViewTableAdapter.Fill(this.hukpiDatabaseDataSet.PartnerDataView);
            

        //}

        private void fillBySearchToolStripButton_Click(object sender, EventArgs e)
        {
            

        }

        public override void refreshData()
        {
            buttonSearchStart_Click(null, null);
        }

        private void dataGridViewSearchResult_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            PartnerForm partnerForm = new PartnerForm(Convert.ToInt64(dataGridViewSearchResult.SelectedRows[0].Cells[0].Value));
            ((MainForm)this.MdiParent).openNewMDIChildForm(partnerForm);
        }

        private void clearAll()
        {
            ((MainForm)MdiParent).openNewMDIChildForm(new SearchPartnerForm());
            this.Dispose();
        }

        private void buttonSearchNew_Click(object sender, EventArgs e)
        {
            clearAll();
        }
    }
}
