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 _02Trade
{


    enum RoWState
    {
        Existed,
        New,
        Modified,
        ModifiedNew,
        Delected
    }

    public partial class ФормаАдмин : Form
    {
        public ФормаАдмин()
        {
            InitializeComponent();
        }
        DB dataBase = new DB();
        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 ФормаАдмин_Load(object sender, EventArgs e)
        {
            // TODO: данная строка кода позволяет загрузить данные в таблицу "_02TradeDataSet.Service". При необходимости она может быть перемещена или удалена.
            this.serviceTableAdapter.Fill(this._02TradeDataSet.Service);

        }

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

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

                textBox1.Text = row.Cells[0].Value.ToString();
                textBox2.Text = row.Cells[1].Value.ToString();
                textBox3.Text = row.Cells[2].Value.ToString();
                textBox4.Text = row.Cells[3].Value.ToString();
                textBox5.Text = row.Cells[4].Value.ToString();
                textBox6.Text = row.Cells[5].Value.ToString();
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Add form1 = new Add();
            form1.Show();
            this.Hide();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.serviceTableAdapter.Update(this._02TradeDataSet.Service);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            serviceBindingSource.RemoveCurrent();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            serviceBindingSource.Sort = "Cost ASC";
        }

        private void button5_Click(object sender, EventArgs e)
        {
            serviceBindingSource.Sort = "Cost Desc";

        }

        private void button6_Click(object sender, EventArgs e)
        {
            serviceBindingSource.Filter = "Discount = '" + discountComboBox.Text + "'";
        }

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

        private void panel8_Paint(object sender, PaintEventArgs e)
        {

        }

        private void button8_Click(object sender, EventArgs e)
        {
            serviceBindingSource.Filter = "Title = '" + titleTextBox.Text + "'";
        }

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

        private void button10_Click(object sender, EventArgs e)
        {
            ДобавлениеКлиента form1 = new ДобавлениеКлиента();
            form1.Show();
            this.Hide();
        }
    }
}
