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

namespace Brovi11
{
    public partial class Manufacturer : Form
    {
        public Manufacturer()
        {
            InitializeComponent();
        }
        int selectedRow;


        private void ReadSingleRow(DataGridView dgw, IDataRecord record)
        {
            dgw.Rows.Add(record.GetInt32(0), record.GetString(1), record.GetString(2), record.GetString(3), record.GetString(4), RoWState.ModifiedNew);
        }

        private void Manufacturer_Load(object sender, EventArgs e)
        {
            // TODO: данная строка кода позволяет загрузить данные в таблицу "_1Brovi11DataSet.Manufacturer". При необходимости она может быть перемещена или удалена.
            this.manufacturerTableAdapter.Fill(this._1Brovi11DataSet.Manufacturer);

        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            selectedRow = e.RowIndex;

            if (e.RowIndex >= 0)
            {
                DataGridViewRow row = dataGridView1.Rows[selectedRow];

                titleTextBox.Text = row.Cells[0].Value.ToString();
                costTextBox.Text = row.Cells[1].Value.ToString();
            }
        }

        private void button9_Click(object sender, EventArgs e)
        {
            FormaAdmin f1 = new FormaAdmin();
            f1.Show();
            this.Hide();
        }

        private void button1_Click(object sender, EventArgs e)
        {
        manufacturerBindingSource.Sort = "Name ASC";            
        }

        private void button2_Click(object sender, EventArgs e)
        {
            manufacturerBindingSource.Sort = "Name Desc";
        }

        private void button3_Click(object sender, EventArgs e)
        {
            manufacturerBindingSource.Filter = "Name = '" + manufacturerIDComboBox.Text + "'";
        }

        private void button5_Click(object sender, EventArgs e)
        {
            manufacturerBindingSource.Filter = null;
        }

        private void panel7_Paint(object sender, PaintEventArgs e)
        {

        }

        private void button6_Click(object sender, EventArgs e)
        {
            AddM f1 = new AddM();
            f1.Show();
            this.Hide();
        }

        private void button11_Click(object sender, EventArgs e)
        {
            manufacturerBindingSource.RemoveCurrent();
        }

        private void button10_Click(object sender, EventArgs e)
        {
            this.manufacturerTableAdapter.Update(this._1Brovi11DataSet.Manufacturer);
        }

        private void button4_Click(object sender, EventArgs e)
        {
            EditMan f1 = new EditMan();
            f1.Show();
            this.Hide();
        }
    }
}