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 EditCD : Form
    {
        public EditCD()
        {
            InitializeComponent();
        }

        private void Form9_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'dataSet21.cd' table. You can move, or remove it, as needed.
            this.cdTableAdapter.Fill(this.dataSet21.cd);
        }
       private void button2_Click(object sender, EventArgs e)
        {
            sqlDataAdapter1.Update(dataSet21);
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void fillBy5ToolStripButton_Click(object sender, EventArgs e)
        {
            try
            {
                this.cdTableAdapter.FillBy5(this.dataSet21.cd, nameToolStripTextBox.Text);
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }

        }

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

        private void button4_Click(object sender, EventArgs e)
        {
            sqlDataAdapter1.UpdateCommand.Parameters.Clear();

            sqlDataAdapter1.UpdateCommand.CommandText = "UPDATE [cd] SET [idCd] = @idCd, [nameCd] = @nameCd, [typeCd] = @typeCd, [rateCd] = @rateCd, [numberCd] = @numberCd, [discription] = @discription WHERE idCd = @idCd" ;
            sqlDataAdapter1.UpdateCommand.Parameters.AddWithValue("@idCd", Convert.ToInt64(label6.Text));
            sqlDataAdapter1.UpdateCommand.Parameters.AddWithValue("@nameCd", textBox1.Text);
            sqlDataAdapter1.UpdateCommand.Parameters.AddWithValue("@typeCd", comboBox1.Text);
            sqlDataAdapter1.UpdateCommand.Parameters.AddWithValue("@rateCd", Convert.ToInt64( textBox2.Text));
            sqlDataAdapter1.UpdateCommand.Parameters.AddWithValue("@numberCd",Convert.ToInt64( textBox3.Text));
            sqlDataAdapter1.UpdateCommand.Parameters.AddWithValue("@discription", textBox4.Text);

            sqlConnection1.Open();
            sqlDataAdapter1.UpdateCommand.ExecuteNonQuery();
            sqlConnection1.Close();

            sqlDataAdapter1.Update(dataSet21);
            
            MMDClassLibrary.MMessageBox p = new MMDClassLibrary.MMessageBox();
            p.ShowSaveDialog1();


            this.cdTableAdapter.Fill(this.dataSet21.cd);

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }
    }
}