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;
using System.Data.SqlClient;

namespace Setting
{
    public partial class frmInfo : Form
    {
        public frmInfo()
        {
            InitializeComponent();
        }
        SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=DBSetting;Integrated Security=True");
        private void btnSave_Click(object sender, EventArgs e)
        {

            SqlCommand sqlcmdedit = new SqlCommand();
            sqlcmdedit.CommandText = "update tblStoreInfo set Code=@Code,StoreName=@StoreName,Seller=@Seller,Phone=@Phone,Address=@Address where ID=@ID";
            sqlcmdedit.Connection = con;
            sqlcmdedit.Parameters.Add("@ID", SqlDbType.NChar).Value = "1";
            sqlcmdedit.Parameters.Add("@Code", SqlDbType.NVarChar).Value =txt_code.Text;
            sqlcmdedit.Parameters.Add("@StoreName", SqlDbType.NVarChar).Value = txt_shopname.Text;
            sqlcmdedit.Parameters.Add("@Seller", SqlDbType.NVarChar).Value = txt_owner.Text;
            sqlcmdedit.Parameters.Add("@Phone", SqlDbType.NVarChar).Value = txt_tel.Text;
            sqlcmdedit.Parameters.Add("@Address", SqlDbType.NVarChar).Value = txt_address.Text;
            con.Open();
            sqlcmdedit.ExecuteNonQuery();
            con.Close();
            this.Close();
        }

       

        private void frmInfo_Load(object sender, EventArgs e)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.CommandType = CommandType.Text;
            cmd.Connection = con;
            SqlDataReader Myreader;
            cmd.CommandText = "select * from tblStoreInfo where  ID=@ID";
            cmd.Parameters.Add("@ID", SqlDbType.NVarChar).Value = "1";
            con.Open();
            Myreader = cmd.ExecuteReader();
            if (Myreader.Read())
            {
                txt_code.Text = Myreader[1].ToString();
                txt_shopname.Text = Myreader[2].ToString();
                txt_owner.Text = Myreader[3].ToString();
                txt_tel.Text = Myreader[4].ToString();
                txt_address.Text = Myreader[5].ToString();
                Myreader.Close();

            }
            con.Close();
        }

 

       

    }
}
