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

namespace WindowsApplication2
{
    public partial class DeleteMember : Form
    {
        public DeleteMember()
        {
            InitializeComponent();
        }

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

        }

        private void fillBy8ToolStripButton_Click(object sender, EventArgs e)
        {
            try
            {
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }

        }

        private void fillBy9ToolStripButton_Click(object sender, EventArgs e)
        {
            try
            {
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }

        }

        private void button2_Click(object sender, EventArgs e)
        {
            sqlDataAdapter1.Update(dataSet21);
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {

            
            
            MMDClassLibrary.MMessageBox p = new MMDClassLibrary.MMessageBox();
            if (p.ShowDeleteDialog())
            {
                   
                sqlDataAdapter1.SelectCommand.Parameters.Clear();
                sqlConnection1.Open();
                sqlDataAdapter1.DeleteCommand.Parameters.Clear();
                sqlDataAdapter1.DeleteCommand.CommandText = "DELETE FROM remembers WHERE idRemember = @id";
                sqlDataAdapter1.DeleteCommand.Parameters.AddWithValue("@id", Convert.ToInt16(textBox1.Text));
                try
                {
                    sqlDataAdapter1.DeleteCommand.ExecuteNonQuery();

                    pictureBox1.Visible = false;
                    pictureBox2.Visible = true;
                }
                catch
                {
                    dError error1 = new dError();
                    error1.ShowDialog();
                }
                sqlConnection1.Close();
                sqlDataAdapter1.SelectCommand.CommandText = "SELECT remembers.* FROM remembers";
                this.remembersTableAdapter.Fill(this.dataSet21.remembers);
            }
        }

        private void fillBy5ToolStripButton_Click(object sender, EventArgs e)
        {
            try
            {
                this.remembersTableAdapter.FillBy5(this.dataSet21.remembers, ((long)(System.Convert.ChangeType(idToolStripTextBox.Text, typeof(long)))));
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }

        }

        private void fillBy6ToolStripButton_Click(object sender, EventArgs e)
        {
            try
            {
                this.remembersTableAdapter.FillBy6(this.dataSet21.remembers, nToolStripTextBox.Text, fToolStripTextBox.Text, fnToolStripTextBox.Text);
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }

        }
    }
}