private void button6_Click(object sender, EventArgs e)
 {
     // Setting up the edit button
     try
     {
         if (SellIdTb.Text == "" || SellNameTb.Text == "" || SellAgeTb.Text == "" || SellPhoneTb.Text == "" || SellPassTb.Text == "")
         {
             MessageBox.Show("Please select an item in the DataGrid");
         }
         else
         {
             Con.Open();
             string     query = "update SellerTbl set SellerName='" + SellNameTb.Text + "',SellerAge='" + SellAgeTb.Text + "',SellerPhone='" + SellPhoneTb.Text + "',SellerPass='******' where SellerId=" + SellIdTb.Text + ";";
             SqlCommand cmd   = new SqlCommand(query, Con);
             cmd.ExecuteNonQuery();
             MessageBox.Show("Seller updated Successfully");
             Con.Close();
             populate();
             SellIdTb.Text    = "";
             SellNameTb.Text  = "";
             SellAgeTb.Text   = "";
             SellPhoneTb.Text = "";
             SellPassTb.Text  = "";
             SellIdTb.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 private void button7_Click(object sender, EventArgs e)
 {
     // delete from the database and update the DVG
     try
     {
         if (SellIdTb.Text == "")
         {
             MessageBox.Show("Select the Seller to delete");
         }
         else
         {
             Con.Open();
             string     query = "delete from SelllerTbl where SellerId=" + SellIdTb.Text + "";
             SqlCommand cmd   = new SqlCommand(query, Con);
             cmd.ExecuteNonQuery();
             MessageBox.Show("Seller Deleted Successfully");
             Con.Close();
             populate();
             SellIdTb.Text    = "";
             SellNameTb.Text  = "";
             SellAgeTb.Text   = "";
             SellPhoneTb.Text = "";
             SellPassTb.Text  = "";
             SellIdTb.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 private void button4_Click(object sender, EventArgs e)
 {
     //Putting the information in the text boxes into the database with message  boxes and error handling
     try
     {
         Con.Open();
         string     query = "insert into SellerTbl values(" + SellIdTb.Text + ",'" + SellNameTb.Text + "','" + SellAgeTb.Text + "', '" + SellPhoneTb.Text + "', '" + SellPassTb.Text + "')";
         SqlCommand cmd   = new SqlCommand(query, Con);
         cmd.ExecuteNonQuery();
         MessageBox.Show("Seller Added Successfully");
         Con.Close();
         populate();
         SellIdTb.Text    = "";
         SellNameTb.Text  = "";
         SellAgeTb.Text   = "";
         SellPhoneTb.Text = "";
         SellPassTb.Text  = "";
         SellIdTb.Focus();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }