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 BB_Romanovskaya
{
    public partial class client_ : Form
    {
        public client_()
        {
            InitializeComponent();
        }

        private void client2BindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.client2BindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.bB_RomanovskayaDataSet);

        }

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

        }

        private void button3_Click(object sender, EventArgs e)
        {
            client2BindingSource.Filter = "Фамилия = '" + comboBox1.Text + "'";
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            button1.Enabled = true;
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void button4_Click(object sender, EventArgs e)
        {
            client2BindingSource.Filter = "";
        }

        private void button5_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < client2DataGridView.ColumnCount; i++)
                for (int j = 0; j < client2DataGridView.RowCount; j++)
                {
                    client2DataGridView[i, j].Style.BackColor = Color.White;
                    client2DataGridView[i, j].Style.ForeColor = Color.Black;
                }
            for (int i = 0; i < client2DataGridView.ColumnCount; i++)
                for (int j = 0; j < client2DataGridView.RowCount; j++)
                    if (client2DataGridView[i, j].Value != null)
                        if (client2DataGridView[i, j].Value.ToString().IndexOf(textBox1.Text) > -1)
                        {
                            client2DataGridView[i, j].Style.BackColor = Color.AliceBlue;
                            client2DataGridView[i, j].Style.ForeColor = Color.Blue;
                        }
        }

        private void button6_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {
            DataGridViewColumn Col = null;
            switch (listBox1.SelectedIndex)
            {
                case 0:
                    Col = dataGridViewTextBoxColumn2;
                    break;
                case 1:
                    Col = dataGridViewTextBoxColumn3;
                    break;
                case 2:
                    Col = dataGridViewTextBoxColumn4;
                    break;
                case 3:
                    Col = dataGridViewTextBoxColumn5;
                    break;
                case 4:
                    Col = dataGridViewTextBoxColumn6;
                    break;
                
                    //case 11: Col = dataGridViewTextBoxColumn1;//    break;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            client2BindingSource.AddNew();
        }

        private void button8_Click(object sender, EventArgs e)
        {
            uslugi f = new uslugi();
            f.Show();
            this.Hide();
        }

        private void button7_Click(object sender, EventArgs e)
        {
            client2BindingSource.RemoveCurrent();
        }
    }
}