Example #1
0
 /// <summary>
 /// eliminar un registro de la base de datos
 /// </summary>
 /// <param name="pkusuario"></param>
 public void eliminar(int pkCliente)
 {
     try
     {
         using (var ctx = new DataModel())
         {
             clientes user = ctx.clientes.Single(r => r.pkCliente == pkCliente);
             ctx.Entry(user).State = EntityState.Deleted;
             ctx.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #2
0
 public void guardar(clientes nCliente, int pkGrupo = 0)//Agregamos primero la funcion para guardar un nuevo cliente
 {
     try
     {
         using (var ctx = new DataModel())
         {
             if (nCliente.pkCliente > 0)
             {
                 ctx.Entry(nCliente).State = EntityState.Modified;
             }
             else
             {
                 ctx.Entry(nCliente).State = EntityState.Added;
             }
             ctx.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #3
0
 public void guardar(ventas nVentas, int pkVentas = 0)//Agregamos primero la funcion para guardar un nuevo cliente
 {
     try
     {
         using (var ctx = new DataModel())
         {
             autos    nautos    = new autos();
             clientes nclientes = new clientes();
             if (nVentas.pkVenta > 0)
             {
                 ctx.Entry(nVentas).State = EntityState.Modified;
             }
             else
             {
                 ctx.Entry(nVentas).State = EntityState.Added;
             }
             ctx.SaveChanges();
         }
     }
     catch (Exception)
     {
         throw;
     }
 }