Пример #1
0
 public void HandleEntity(string procedure, Dictionary <string, object> dict, string statement)
 {
     using (SqlConnection con = DBsecurity.GetConnection())
     {
         SqlCommand cmd = new SqlCommand(procedure, con);
         cmd.CommandType = CommandType.StoredProcedure;
         foreach (var item in dict)
         {
             cmd.Parameters.AddWithValue(item.Key, item.Value);
         }
         cmd.Parameters.AddWithValue("@StatementType", statement);
         cmd.ExecuteNonQuery();
     }
 }
Пример #2
0
 public void FindEntities(string procedure, Dictionary <string, object> parameters, DataGridView grid)
 {
     using (SqlConnection con = DBsecurity.GetConnection())
     {
         SqlCommand cmd   = new SqlCommand(procedure, con);
         DataTable  table = new DataTable();
         cmd.CommandType = CommandType.StoredProcedure;
         foreach (var item in parameters)
         {
             cmd.Parameters.AddWithValue(item.Key, item.Value);
         }
         cmd.Parameters.AddWithValue("@StatementType", "Select");
         SqlDataAdapter da = new SqlDataAdapter(cmd);
         da.Fill(table);
         grid.DataSource = new BindingSource(table, null);
     }
 }