Ver Mensaje Individual
  #6 (permalink)  
Antiguo 07/08/2015, 14:17
uagrm
 
Fecha de Ingreso: agosto-2010
Mensajes: 126
Antigüedad: 13 años, 8 meses
Puntos: 9
Respuesta: [Aporte] Sistema de Ventas en C# y SQL Server

La idea es tener métodos (insertar, actualizar, buscar..etc) que luego podas reutilizar en las clases que sea necesaria.

class ADO
Código PHP:
Ver original
  1. /*Este método permite registrar, funciona para todos los Insert*/
  2.         public int Create(string stored, ArrayList sqlParametros)
  3.         {
  4.             SqlCommand commmand = new SqlCommand();
  5.             SqlTransaction transaccion;
  6.             Conectar();
  7.             transaccion = conexion.BeginTransaction();
  8.             commmand.Connection = conexion;
  9.             commmand.Transaction = transaccion;
  10.             commmand.CommandType = CommandType.StoredProcedure;
  11.             commmand.CommandText = stored;
  12.             SqlCommandBuilder.DeriveParameters(commmand);
  13.             for (int i = 1; i <= commmand.Parameters.Count - 1; i++)
  14.             {
  15.                 commmand.Parameters[i].Value = sqlParametros[i - 1];
  16.             }
  17.  
  18.             string filasaceptadas = commmand.ExecuteScalar().ToString();
  19.  
  20.             if (Convert.ToInt32(filasaceptadas) != 0)
  21.             {
  22.                 transaccion.Commit();
  23.             }
  24.             else
  25.             {
  26.                 transaccion.Rollback();
  27.             }
  28.  
  29.             Desconcestar();
  30.             return Convert.ToInt32(filasaceptadas);
  31.         }


Código PHP:
Ver original
  1. /*Insertar de tu class DCategorias*/
  2.         public static int Insertar(String parNombre_Categoria, String parDescripcion)
  3.         {
  4.             int resultado = 0;
  5.             ArrayList array = new ArrayList();
  6.             array.Add(parNombre_Categoria);
  7.             array.Add(String parDescripcion);
  8.             resultado = ado.Create("Produccion.InsertarCategoria", array);
  9.  
  10.             return resultado;
  11.         }

Código PHP:
Ver original
  1. /*Insertar de tu class NEmpleados*/
  2.         public static int Insertar(String parNombre_Empleado, String parApellido_Empleado,
  3.             String parDireccion, String parCiudad, String parRegion, String parPais, String parTelefono)
  4.         {
  5.             int resultado = 0;
  6.             ArrayList array = new ArrayList();
  7.             array.Add(parNombre_Empleado);
  8.             array.Add(parApellido_Empleado);
  9.             array.Add(parDireccion);
  10.             array.Add(parCiudad);
  11.             array.Add(parRegion);
  12.             array.Add(parPais);
  13.             array.Add(parTelefono);
  14.             resultado = ado.Create("RecursosHumanos.InsertarEmpleado", array);
  15.  
  16.             return resultado;
  17.         }