private void btnAdd_Click(object sender, EventArgs e)
        {
            if (txtCodeProduct.Text.Equals("") || txtUnitPrice.Text.Equals("") || txtNameProduct.Text.Equals(""))
            {
                MessageBox.Show("Not enough of data!!!");
                return;
            }
            try
            {
                /*connection = new SqlConnection(connectionString);
                 * connection.Open();
                 * String sql = "exec nhap '" + txtCodeProduct.Text + "', '" + txtNameProduct.Text + "', " + Convert.ToInt32(cbKindOfProduct.SelectedValue) + "," + Convert.ToSingle(txtUnitPrice.Text);
                 * cmd = new SqlCommand(sql, connection);
                 * cmd.ExecuteNonQuery();
                 * loadData();
                 * MessageBox.Show("Add complete !!!");*/

                dbDataContext data       = new dbDataContext();
                SanPham       addProduct = new SanPham();
                addProduct.ma_sp   = txtCodeProduct.Text;
                addProduct.ten_sp  = txtNameProduct.Text;
                addProduct.ma_loai = Convert.ToInt32(cbKindOfProduct.SelectedValue);
                addProduct.don_gia = Convert.ToSingle(txtUnitPrice.Text);
                data.SanPhams.InsertOnSubmit(addProduct);
                data.SubmitChanges();
                loadData();
                MessageBox.Show("Add complete !!!");
            }
            catch (SqlException)
            {
                MessageBox.Show("Error!!!");
            }
        }
        private void btnEdit_Click(object sender, EventArgs e)
        {
            try
            {
                /*connection = new SqlConnection(connectionString);
                 * connection.Open();
                 * String sql = "Update SanPham set ten_sp = '" + txtNameProduct.Text + "', ma_loai = " + Convert.ToInt32(cbKindOfProduct.SelectedValue) + ", don_gia =" + Convert.ToSingle(txtUnitPrice.Text) + " where ma_sp ='" + txtCodeProduct.Text + "'";
                 * MessageBox.Show(sql);
                 * cmd = new SqlCommand(sql, connection);
                 * cmd.ExecuteNonQuery();
                 * loadData();
                 * MessageBox.Show("Edit complete !!!");*/

                dbDataContext data          = new dbDataContext();
                var           updateProduct = data.SanPhams.Single(sp => sp.ma_sp == txtCodeProduct.Text);
                updateProduct.ten_sp  = txtNameProduct.Text;
                updateProduct.ma_loai = Convert.ToInt32(cbKindOfProduct.SelectedValue);
                updateProduct.don_gia = Convert.ToSingle(txtUnitPrice.Text);
                data.SubmitChanges();
                loadData();
                MessageBox.Show("Edit complete !!!");
            }
            catch (SqlException)
            {
                MessageBox.Show("Error!!!");
            }
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are you sure?", "Warning!!!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.No)
            {
                return;
            }
            try
            {
                /*connection = new SqlConnection(connectionString);
                 * connection.Open();
                 * String sql = "Delete From SanPham where ma_sp = '" + txtCodeProduct.Text + "'";
                 * cmd = new SqlCommand(sql, connection);
                 * cmd.ExecuteNonQuery();
                 * loadData();
                 * MessageBox.Show("Delete complete !!!");*/

                dbDataContext data          = new dbDataContext();
                var           deleteProduct = from sp in data.SanPhams where sp.ma_sp == txtCodeProduct.Text select sp;
                foreach (var i in deleteProduct)
                {
                    data.SanPhams.DeleteOnSubmit(i);
                    data.SubmitChanges();
                }
                loadData();
                MessageBox.Show("Delete complete !!!");
            }
            catch (SqlException)
            {
                MessageBox.Show("Error!!!");
            }
        }
        private void loadData()
        {
            /*dataAdapter = new SqlDataAdapter("select * from SanPham", connection);
             * dataTable = new DataTable();
             * dataAdapter.Fill(dataTable);
             * dataGridView1.DataSource = dataTable;*/

            dbDataContext data = new dbDataContext();
            var           sp   = from sanPham in data.SanPhams select sanPham;

            dataGridView1.DataSource = sp;
        }
        private void loadTimKiem(int loai)
        {
            /*dataAdapter = new SqlDataAdapter("select * from SanPham where ma_loai = " + loai, connection);
             * dataTable = new DataTable();
             * dataTable.Clear();
             * dataAdapter.Fill(dataTable);
             * dataGridView1.DataSource = dataTable;*/

            dbDataContext data   = new dbDataContext();
            var           search = from s in data.SanPhams where s.ma_loai == loai select new { s.ma_sp, s.ten_sp, s.ma_loai, s.don_gia };

            dataGridView1.DataSource = search;
        }
        private void loadCombo()
        {
            /*dataAdapter = new SqlDataAdapter("Select * from LoaiSP", connection);
             * dataTable = new DataTable();
             * dataAdapter.Fill(dataTable);
             * cbKindOfProduct.DataSource = dataTable;
             * cbKindOfProduct.DisplayMember = "ten_loai";
             * cbKindOfProduct.ValueMember = "ma_loai";*/

            dbDataContext data = new dbDataContext();
            var           lsp  = from loaiSanPham in data.LoaiSPs select loaiSanPham;

            cbKindOfProduct.DataSource    = lsp;
            cbKindOfProduct.DisplayMember = "ten_loai";
            cbKindOfProduct.ValueMember   = "ma_loai";
        }