Exemplo n.º 1
0
 public void Update(User user)
 {
     try
     {
         string query = "UPDATE Users " +
                        "SET Password = @password, " +
                        "PermisoUsuario = @permisoUsuario, " +
                        "Permisoitems = @permisoItems, " +
                        "PermisoInventario = @permisoInventario, " +
                        "PermisoAlmacen = @permisoAlmacen " +
                        "WHERE Nombre = @nombre";
         connection.Open();
         SqlCommand command = new SqlCommand(query, connection);
         command.Parameters.AddWithValue("@nombre", user.UserName);
         command.Parameters.AddWithValue("@password", user.Password);
         command.Parameters.AddWithValue("@permisoUsuario", user.IntPermitUserMang());
         command.Parameters.AddWithValue("@permisoItems", user.IntPermitCatalogMang());
         command.Parameters.AddWithValue("@permisoInventario", user.IntPermitInventoryMng());
         command.Parameters.AddWithValue("@permisoAlmacen", user.IntPermitStorageMng());
         command.ExecuteNonQuery();
         connection.Close();
     }
     catch (Exception)
     {
         connection.Close();
         throw new DoesNotExist();
     }
 }
Exemplo n.º 2
0
 public void Insert(User user)
 {
     try
     {
         string query = "Insert INTO Users (Nombre, Password, PermisoUsuario, Permisoitems, PermisoInventario, PermisoAlmacen)" +
                        "Values (@nombre, @password, @permisoUsuario, @permisoItems, @permisoInventario, @permisoAlmacen)";
         connection.Open();
         SqlCommand command = new SqlCommand(query, connection);
         command.Parameters.AddWithValue("@nombre", user.UserName);
         command.Parameters.AddWithValue("@password", user.Password);
         command.Parameters.AddWithValue("@permisoUsuario", user.IntPermitUserMang());
         command.Parameters.AddWithValue("@permisoitems", user.IntPermitCatalogMang());
         command.Parameters.AddWithValue("@permisoInventario", user.IntPermitInventoryMng());
         command.Parameters.AddWithValue("@permisoAlmacen", user.IntPermitStorageMng());
         command.ExecuteNonQuery();
         connection.Close();
     }
     catch (Exception)
     {
         connection.Close();
         throw new AlreadyExists();
     }
 }