class Sqlcon
    {
          public static bool Sqlconnect(string strSql,string strSqlType ,DataGridView dataGridView1)
          {
        
              string myconnectString = global::UUtool.Properties.Settings.Default.SantaiUUConnectionString;
                   SqlConnection MyConnection = null;
                   MyConnection = new SqlConnection(myconnectString);
                   SqlCommand MyCommand = new SqlCommand(strSql, MyConnection);

                   switch (strSqlType)
                   {
                       case "select":
                          
                           try
                           {
                               MyCommand.CommandTimeout = 0;
                               MyConnection.Open();

                               SqlDataReader MyReader1 = MyCommand.ExecuteReader();
                               DataTable MyTable1 = new DataTable();
                               MyTable1.Load(MyReader1);
                               dataGridView1.DataSource = MyTable1;
                           }
          
                     
                           catch (SqlException ex) { MessageBox.Show(ex.Message); }
                           finally { MyConnection.Close();}
                           break;
                       case "delete":
                           try
                           {
                               MyCommand.CommandTimeout = 0;
                               MyConnection.Open();
                               MessageBox.Show("删除成功" + MyCommand.ExecuteNonQuery().ToString() + "条记录");

                           }
                           catch (SqlException ex) { MessageBox.Show(ex.Message); }
                           finally { MyConnection.Close(); }
                           break;
                       case "update":
                           MessageBox.Show("dd");
                           break;                        
                   }

                   return true;
          }

    }