private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            string        Query       = "INSERT INTO sales_agent_master VALUES ('" + this.agnt_nameTextBox.Text + "', '" + this.agnt_addrTextBox.Text + "', '" + this.agnt_phneTextBox.Text + "'); ";
            SqlCommand    cmdDataBase = new SqlCommand(Query, conDataBase);
            SqlDataReader myReader;

            try
            {
                conDataBase.Open();
                myReader = cmdDataBase.ExecuteReader();
                MessageBox.Show("Saved");
                while (myReader.Read())
                {
                    adpt.Update(dt);
                    con.Close();
                    Fillprod_masterDataGrid();
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            //reload window after add to show details
            var salesAgentWindow = new SalesAgentWindow();

            salesAgentWindow.Show();
            Close();
        }
        private void ListViewItem_Sales_Selected(object sender, RoutedEventArgs e)
        {
            var salesAgentWindow = new SalesAgentWindow();

            salesAgentWindow.Show();
            Close();
        }
 private void btnDelete_Click(object sender, RoutedEventArgs e)
 {
     if (agnt_nameTextBox.Text != "")
     {
         con = new SqlConnection(connectionString);
         con.Open();
         cmd    = new SqlCommand("DELETE FROM [sales_agent_master] WHERE [agnt_name] = '" + agnt_nameTextBox.Text.ToString() + "'", con);
         reader = cmd.ExecuteReader();
         if (reader.Read())
         {
             MessageBox.Show("success");
             var salesAgentWindow = new SalesAgentWindow();
             salesAgentWindow.Show();
             Close();
         }
         else
         {
             //reload window after add to show details
             //ALSO code is completely busted, datagrid panics for some reason and code identifies the delete as failing, hence why
             //this is in the else portion of the statement
             //but it doesnt actually fail (the datagrid wigs out before it redirects to the view tab)
             var salesAgentWindow = new SalesAgentWindow();
             salesAgentWindow.Show();
             Close();
         }
         reader.Close();
         con.Close();
     }
     else
     {
         MessageBox.Show("Please Select Record to Delete");
     }
 }