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

namespace Library
{
    public partial class FormBook_Edit : Form
    {
        public FormBook_Edit()
        {
            InitializeComponent();
        }

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

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (!checkBox1.Checked)
                panel1.Visible = true;
            else
                panel1.Visible = false;
        }

        private void btnok_Click(object sender, EventArgs e)
        {
            DataAccess da = new DataAccess();
            da.Connect();            
            string sql = @"update book set bname=N'{0}',bauthor=N'{1}',btranslate=N'{2}',isfarsi={3},
                        bcount={4},catid_fk={5} where bid={6}";
            sql = string.Format(sql, txtname.Text, txtauthor.Text, txttranslate.Text,
                Convert.ToInt32(checkBox1.Checked), Int32.Parse(txtcount.Text), comboBox1.SelectedValue, txtid.Text);
            da.DoCommand(sql);
            this.Close();           
            da.DisConnect();
        }

        private void buttonX2_Click(object sender, EventArgs e)
        {
            DataAccess da = new DataAccess();
            da.Connect();            
            string sql = @"update book set bname=N'{0}',bauthor=N'{1}',btranslate=N'{2}',isfarsi={3},
                        bcount={4},catid_fk={5} where bid={6}";
            sql = string.Format(sql, txtname.Text, txtauthor.Text, txttranslate.Text,
                Convert.ToInt32(checkBox1.Checked), Int32.Parse(txtcount.Text), comboBox1.SelectedValue, txtid.Text);
            da.DoCommand(sql);
            this.Close();
            da.DisConnect();
        }
    }
}
